Beispiel #1
0
        public void test_factory_mocking2()
        {
            List <TimeSlot> timeSlots = new List <TimeSlot>()
            {
                new TimeSlot()
                {
                    TimeSlotId = 1, Description = "Mustang"
                },
                new TimeSlot()
                {
                    TimeSlotId = 2, Description = "Corvette"
                }
            };

            Mock <ITimeSlotRepository> mockTimeSlotRepository = new Mock <ITimeSlotRepository>();

            mockTimeSlotRepository.Setup(obj => obj.Get()).Returns(timeSlots);

            Mock <IDataRepositoryFactory> mockDataRepository = new Mock <IDataRepositoryFactory>();

            mockDataRepository.Setup(obj => obj.GetDataRepository <ITimeSlotRepository>()).Returns(mockTimeSlotRepository.Object);

            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object);

            IEnumerable <TimeSlot> ret = factoryTest.GetTimeSlots();

            Assert.IsTrue(ret == timeSlots);
        }
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable<TimeSlot> timeSlots = factoryTest.GetTimeSlots();

            Assert.IsTrue(timeSlots != null);
        }
Beispiel #3
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable <TimeSlot> timeSlots = factoryTest.GetTimeSlots();

            Assert.IsTrue(timeSlots != null);
        }
        public void test_factory_mocking1()
        {
            List<TimeSlot> timeSlots = new List<TimeSlot>()
            {
                new TimeSlot() { TimeSlotId = 1, Description = "Mustang" },
                new TimeSlot() { TimeSlotId = 2, Description = "Corvette" }
            };

            Mock<IDataRepositoryFactory> mockDataRepository = new Mock<IDataRepositoryFactory>();
            mockDataRepository.Setup(obj => obj.GetDataRepository<ITimeSlotRepository>().Get()).Returns(timeSlots);

            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object);

            IEnumerable<TimeSlot> ret = factoryTest.GetTimeSlots();

            Assert.IsTrue(ret == timeSlots);
        }