Exemplo n.º 1
0
        public void FilterService_FilterExpiringInsurance_VerifyThatTheMethodIsCalledExactOneTime_WhenPassedParametersAreCorrect()
        {
            var collectionOfCars = new List <Car>
            {
                new Car()
                {
                    Id = 1, Manufacturer = "VW", Model = "Golf", ValidUntilInsurance = DateTime.Now
                },
                new Car()
                {
                    Id = 2, Manufacturer = "BMW", Model = "e40", ValidUntilInsurance = DateTime.Now
                },
                new Car()
                {
                    Id = 3, Manufacturer = "Lada", Model = "2105", ValidUntilInsurance = DateTime.Now
                }
            };
            var mockedRepo = new Mock <IRepository <Car> >();

            mockedRepo.Setup(m => m.All()).Returns(collectionOfCars);
            var service = new FilterService(mockedRepo.Object);

            service.FilterExpiringInsurance();

            mockedRepo.Verify(m => m.All(), Times.Exactly(1));
        }
Exemplo n.º 2
0
        public void FilterService_FilterExpiringInsurance_ShouldReturnIEnumerableCollection_WhenPassedParametersAreCorrect()
        {
            var collectionOfCars = new List <Car>
            {
                new Car()
                {
                    Id = 1, Manufacturer = "VW", Model = "Golf", ValidUntilInsurance = DateTime.Now
                },
                new Car()
                {
                    Id = 2, Manufacturer = "BMW", Model = "e40", ValidUntilInsurance = DateTime.Now
                },
                new Car()
                {
                    Id = 3, Manufacturer = "Lada", Model = "2105", ValidUntilInsurance = DateTime.Now
                }
            };
            var mockedRepo = new Mock <IRepository <Car> >();

            mockedRepo.Setup(m => m.All()).Returns(collectionOfCars);
            var service = new FilterService(mockedRepo.Object);

            var result = service.FilterExpiringInsurance().ToList();

            Assert.AreEqual(collectionOfCars.Count, result.Count);
        }