using CheffAlfredo.Data.Impl; using Microsoft.VisualStudio.TestTools.UnitTesting; using Data.Impl; using CheffAlfredo.Data; using Data.Utils; using System.Collections.Generic; using System.Data.SqlClient; using CheffAlfredo.Data.SpecializedSql; using Data; namespace UserDataProviderTest { /// ///This is a test class for UserDataProviderTest and is intended ///to contain all UserDataProviderTest Unit Tests /// [TestClass()] public class UserDataProviderTest { private TestContext testContextInstance; /// ///Gets or sets the test context which provides ///information about and functionality for the current test run. /// public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } #region Additional test attributes // //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion /// ///A test for _ReadUser /// [TestMethod()] [DeploymentItem("Data.Impl.dll")] public void _ReadUserTest() { PrivateObject param0 = null; // TODO: Initialize to an appropriate value UserDataProvider_Accessor target = new UserDataProvider_Accessor(param0); // TODO: Initialize to an appropriate value SqlDataReader dr = null; // TODO: Initialize to an appropriate value int userId = 0; // TODO: Initialize to an appropriate value User expected = null; // TODO: Initialize to an appropriate value User actual; actual = target._ReadUser(dr, userId); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); } /// ///A test for ChangePassword /// [TestMethod()] public void ChangePasswordTest() { ConnectionControl connectionControl = null; // TODO: Initialize to an appropriate value UserDataProvider target = new UserDataProvider(connectionControl); // TODO: Initialize to an appropriate value int userId = 0; // TODO: Initialize to an appropriate value string newPassword = string.Empty; // TODO: Initialize to an appropriate value EBDReport expected = new EBDReport(); // TODO: Initialize to an appropriate value EBDReport actual; //actual = target.ChangePassword(userId, newPassword); //Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); } /// ///A test for GetUser /// [TestMethod()] public void GetUserTest() { ConnectionControl connectionControl = null; // TODO: Initialize to an appropriate value UserDataProvider target = new UserDataProvider(connectionControl); // TODO: Initialize to an appropriate value string login = string.Empty; // TODO: Initialize to an appropriate value string password = string.Empty; // TODO: Initialize to an appropriate value int userId = 0; // TODO: Initialize to an appropriate value User expected = null; // TODO: Initialize to an appropriate value User actual; actual = target.GetUser(login, password, userId); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); } /// ///A test for RememberPassword /// [TestMethod()] public void RememberPasswordTest() { ConnectionControl connectionControl = null; // TODO: Initialize to an appropriate value UserDataProvider target = new UserDataProvider(connectionControl); // TODO: Initialize to an appropriate value string login = string.Empty; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value PasswordEmail actual; actual = target.RememberPassword(login); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); } /// ///Verifica casos de sucesso do updateUser e removeUser. /// [TestMethod()] public void SuccessUpdateandRemoveUserTest() { ConnectionControl connectionControl = new ConnectionControl(); // TODO: Initialize to an appropriate value IUserDataProvider target = new UserDataProvider(connectionControl); // TODO: Initialize to an appropriate value User[] usuarios = new User[6]; // criação dos usuários-teste. usuarios[0] = new User(); usuarios[0].UserId = -1; usuarios[0].Name = "eu"; usuarios[0].Login = "eeuu"; usuarios[0].Password = "123456"; usuarios[0].Sex = ESex.Male; usuarios[0].State = "Goiás"; usuarios[0].City = "Jordão"; usuarios[0].Email = "eeuu@hotmail.com"; usuarios[0].Birthday = new System.DateTime(1980, 1, 1); usuarios[1] = new User(); usuarios[1].UserId = -1; usuarios[1].Name = "Eu"; usuarios[1].Login = "Ele"; usuarios[1].Password = "dbnjuvde"; usuarios[1].Sex = ESex.Male; usuarios[1].State = "Alagoas"; usuarios[1].City = "Canapi"; usuarios[1].Email = "a@b.com"; usuarios[1].Birthday = new System.DateTime(1988, 03, 02); usuarios[2] = new User(); usuarios[2].UserId = -1; usuarios[2].Name = "igão"; usuarios[2].Login = "icd"; usuarios[2].Password = "icd"; usuarios[2].Sex = ESex.Male; usuarios[2].State = "Acre"; usuarios[2].City = "Acrelândia"; usuarios[2].Email = "icd@cin.ufpe.br"; usuarios[2].Birthday = new System.DateTime(1988, 03, 02); usuarios[3] = new User(); usuarios[3].UserId = -1; usuarios[3].Name = "Adalberto"; usuarios[3].Login = "jucajucão"; usuarios[3].Password = "icd"; usuarios[3].Sex = ESex.Male; usuarios[3].State = "Acre"; usuarios[3].City = "Acrelândia"; usuarios[3].Email = "icd@cin.ufpe.br"; usuarios[3].Birthday = new System.DateTime(1910, 03, 02); usuarios[4] = new User(); usuarios[4].UserId = -1; usuarios[4].Name = "R.C John"; usuarios[4].Login = "RCCCJ"; usuarios[4].Password = "0"; usuarios[4].Sex = ESex.Male; usuarios[4].State = "Acre"; usuarios[4].City = "Acrelândia"; usuarios[4].Email = "r@na.com"; usuarios[4].Birthday = new System.DateTime(1900, 1, 1); usuarios[5] = new User(); usuarios[5].UserId = -1; usuarios[5].Name = "juquijuqui"; usuarios[5].Login = "a"; usuarios[5].Password = "b"; usuarios[5].Sex = ESex.Male; usuarios[5].State = "Tocantins"; usuarios[5].City = "Talismã"; usuarios[5].Email = "i@i.com"; usuarios[5].Birthday = new System.DateTime(1931, 12, 30); foreach (User item in usuarios) { EBDReport expected = EBDReport.Succeed; EBDReport actual = target.UpdateUser(item); Assert.AreEqual(expected, actual); // verifica se o update foi realizado. User insertedUser = target.GetUser(item.Login, item.Password, -1); Assert.AreEqual(item.Birthday, insertedUser.Birthday); // verifica se o usuário buscado é o mesmo que foi inserido. Assert.AreEqual(item.City, insertedUser.City); Assert.AreEqual(item.Email, insertedUser.Email); Assert.AreEqual(item.FavouriteCartes, insertedUser.FavouriteCartes); Assert.AreEqual(item.FavouriteRecipes, insertedUser.FavouriteRecipes); Assert.AreEqual(item.InsertedRecipes, insertedUser.InsertedRecipes); Assert.AreEqual(item.Login, insertedUser.Login); Assert.AreEqual(item.Name, insertedUser.Name); Assert.AreEqual(item.Password, insertedUser.Password); Assert.AreEqual(item.Sex, insertedUser.Sex); Assert.AreEqual(item.State, insertedUser.State); target.RemoveUser(insertedUser.UserId); // remove o usuário-teste insertedUser = target.GetUser(item.Login, item.Password, -1); Assert.AreEqual(insertedUser, null);// verifica se o usuário-teste foi removido } } /// ///Verifica casos de erro do updateUser e removeUser. /// [TestMethod()] public void ErrorUpdateandRemoveUserTest() { ConnectionControl connectionControl = new ConnectionControl(); // TODO: Initialize to an appropriate value IUserDataProvider target = new UserDataProvider(connectionControl); // TODO: Initialize to an appropriate value User[] usuarios = new User[6]; // criação dos usuários-teste. usuarios[0] = new User(); usuarios[0].UserId = -1; usuarios[0].Name = ""; usuarios[0].Login = ""; usuarios[0].Password = ""; usuarios[0].Sex = ESex.Female; usuarios[0].State = ""; usuarios[0].City = "012"; usuarios[0].Email = "dsdsds"; usuarios[0].Birthday = new System.DateTime(1800, 1, 1); usuarios[1] = new User(); usuarios[1].UserId = -1; usuarios[1].Name = "wfdqa"; usuarios[1].Login = ""; usuarios[1].Password = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"; usuarios[1].Sex = ESex.Male; usuarios[1].State = "Alagoas"; usuarios[1].City = "Pernambuco"; usuarios[1].Email = "a@b."; usuarios[1].Birthday = new System.DateTime(1988, 03, 02); usuarios[2] = new User(); usuarios[2].UserId = -1; usuarios[2].Name = "IgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgorIgor"; usuarios[2].Login = "icd"; usuarios[2].Password = "icd"; usuarios[2].Sex = ESex.Male; usuarios[2].State = "Acre"; usuarios[2].City = "Acrelândia"; usuarios[2].Email = "icd@cin.ufpe.br"; usuarios[2].Birthday = new System.DateTime(1988, 03, 02); usuarios[3] = new User(); usuarios[3].UserId = -1; usuarios[3].Name = "Adalberto"; usuarios[3].Login = "grewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreggrewgreqwgeqrgareagreg"; usuarios[3].Password = "icd"; usuarios[3].Sex = ESex.Male; usuarios[3].State = "Acre"; usuarios[3].City = "Acrelândia"; usuarios[3].Email = "icd@cin.ufpe.br"; usuarios[3].Birthday = new System.DateTime(1988, 03, 02); usuarios[4] = new User(); usuarios[4].UserId = -1; usuarios[4].Name = "R.C John"; usuarios[4].Login = "RCCCJ"; usuarios[4].Password = "0"; usuarios[4].Sex = ESex.Male; usuarios[4].State = "Acre"; usuarios[4].City = "Recife"; usuarios[4].Email = "r@na.com"; usuarios[4].Birthday = new System.DateTime(1900, 1, 1); usuarios[5] = new User(); usuarios[5].UserId = -1; usuarios[5].Name = "Igor"; usuarios[5].Login = "a"; usuarios[5].Password = "b"; usuarios[5].Sex = ESex.Male; usuarios[5].State = "Natal"; usuarios[5].City = "Porto Alegre"; usuarios[5].Email = "i@i.com"; usuarios[5].Birthday = new System.DateTime(1800, 12, 30); usuarios[6] = new User(); usuarios[6].UserId = -1; usuarios[6].Name = "Igor"; usuarios[6].Login = "a"; usuarios[6].Password = "b"; usuarios[6].Sex = ESex.Male; usuarios[6].State = null; usuarios[6].City = "Porto Alegre"; usuarios[6].Email = "i@i.com"; usuarios[6].Birthday = new System.DateTime(1800, 12, 30); usuarios[7] = new User(); usuarios[7].UserId = -1; usuarios[7].Name = "Igor"; usuarios[7].Login = "a"; usuarios[7].Password = "b"; usuarios[7].Sex = ESex.Male; usuarios[7].State = "Pernambuco"; usuarios[7].City = null; usuarios[7].Email = "i@i.com"; usuarios[7].Birthday = new System.DateTime(1800, 12, 30); usuarios[8] = new User(); usuarios[8].UserId = -1; usuarios[8].Name = "Igor"; usuarios[8].Login = "a"; usuarios[8].Password = "b"; usuarios[8].Sex = ESex.Female; usuarios[8].State = null; usuarios[8].City = null; usuarios[8].Email = "ololo@lolo.com"; usuarios[8].Birthday = new System.DateTime(1800, 12, 30); usuarios[9] = new User(); usuarios[9].UserId = -1; usuarios[9].Name = null; usuarios[9].Login = "a"; usuarios[9].Password = "b"; usuarios[9].Sex = ESex.Female; usuarios[9].State = null; usuarios[9].City = null; usuarios[9].Email = "ololo@lolo.com"; usuarios[9].Birthday = new System.DateTime(1800, 12, 30); usuarios[10] = new User(); usuarios[10].UserId = -1; usuarios[10].Name = ""; usuarios[10].Login = "null"; usuarios[10].Password = "b"; usuarios[10].Sex = ESex.Female; usuarios[10].State = null; usuarios[10].City = null; usuarios[10].Email = "ololo@lolo.com"; usuarios[10].Birthday = new System.DateTime(1800, 12, 30); foreach (User item in usuarios) { EBDReport expected = EBDReport.ValidationError; EBDReport actual = target.UpdateUser(item); Assert.AreEqual(expected, actual); // verifica se o update falhou. if (expected.Equals(EBDReport.Succeed)) { target.RemoveUser(item.UserId); // remove o usuário-teste caso o mesmo tenha sido inserido. } } } /// ///A test for UserDataProvider Constructor /// [TestMethod()] public void UserDataProviderConstructorTest() { ConnectionControl connectionControl = null; // TODO: Initialize to an appropriate value UserDataProvider target = new UserDataProvider(connectionControl); Assert.Inconclusive("TODO: Implement code to verify target"); } } }