public void test_factory_mocking2() { List <ApplicationUser> users = new List <ApplicationUser>() { new ApplicationUser() { UserName = "******" }, new ApplicationUser() { UserName = "******" } }; Mock <IUserRepository> mockCarRepository = new Mock <IUserRepository>(); mockCarRepository.Setup(obj => obj.Get()).Returns(users); Mock <IDataRepositoryFactory> mockDataRepository = new Mock <IDataRepositoryFactory>(); mockDataRepository.Setup(obj => obj.GetDataRepository <IUserRepository>()).Returns(mockCarRepository.Object); RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object); IEnumerable <ApplicationUser> ret = factoryTest.GetUsers(); Assert.IsTrue(ret == users); }
public void test_repositoryFactory_mockUsage() { var userAccounts = new List <UserAccount> { new UserAccount { AccountId = Guid.Parse("3A557B7B-073F-4CCA-B834-CDA95850213E"), CorrelationGuid = Guid.Parse("3A557B7B-073F-4CCA-B834-CDA95850213E"), LoginEmail = "*****@*****.**" }, new UserAccount { AccountId = Guid.Parse("07971F9F-14D8-4127-A5F8-D1B77DCBC218"), CorrelationGuid = Guid.Parse("07971F9F-14D8-4127-A5F8-D1B77DCBC218"), LoginEmail = "*****@*****.**" } }; Mock <IDataRepositoryFactory> dataRepositoryMock = new Mock <IDataRepositoryFactory>(); dataRepositoryMock.Setup(obj => obj.GetDataRepository <IAccountRepository>().Get()).Returns(userAccounts); RepositoryFactoryTestClass repositoryFactoryTest = new RepositoryFactoryTestClass(dataRepositoryMock.Object); var accounts = repositoryFactoryTest.GetUserAccounts(); Assert.IsTrue(Equals(accounts, userAccounts)); }
public void test_repositoryFactory_usage_Integration() { RepositoryFactoryTestClass repositoryFactoryTest = new RepositoryFactoryTestClass(); var accounts = repositoryFactoryTest.GetUserAccounts(); Assert.IsTrue(accounts != null, "Returned Accounts is null"); }
public void test_repository_factory_usage() { RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(); IEnumerable <ApplicationUser> clients = factoryTest.GetUsers(); Assert.IsTrue(clients != null); }