Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable <ApplicationUser> clients = factoryTest.GetUsers();

            Assert.IsTrue(clients != null);
        }