示例#1
0
        public void FilterService_FilterExpiringAnnualCheckUp_VerifyThatTheMethodIsCalledExactOneTime_WhenPassedParametersAreCorrect()
        {
            // Arrange
            var collectionOfCars = new List <Car>
            {
                new Car()
                {
                    Id = Guid.NewGuid(), Manufacturer = "VW", Model = "Golf", ValidUntilAnnualCheckUp = DateTime.Now
                },
                new Car()
                {
                    Id = Guid.NewGuid(), Manufacturer = "BMW", Model = "e40", ValidUntilAnnualCheckUp = DateTime.Now
                },
                new Car()
                {
                    Id = Guid.NewGuid(), Manufacturer = "Lada", Model = "2105", ValidUntilAnnualCheckUp = DateTime.Now
                }
            };
            var mockedRepo = new Mock <IEfGenericRepository <Car> >();

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

            // Act
            service.FilterExpiringAnnualCheckUpInTheNextSevenDays();

            // Assert
            mockedRepo.Verify(m => m.All(), Times.Exactly(1));
        }
示例#2
0
        public void FilterService_FilterExpiringAnnualCheckUp_ShouldReturnIEnumerableCollection_WhenPassedParametersAreCorrect()
        {
            // Arrange
            var collectionOfCars = new List <Car>
            {
                new Car()
                {
                    Id = Guid.NewGuid(), Manufacturer = "VW", Model = "Golf", ValidUntilAnnualCheckUp = DateTime.Now
                },
                new Car()
                {
                    Id = Guid.NewGuid(), Manufacturer = "BMW", Model = "e40", ValidUntilAnnualCheckUp = DateTime.Now
                },
                new Car()
                {
                    Id = Guid.NewGuid(), Manufacturer = "Lada", Model = "2105", ValidUntilAnnualCheckUp = DateTime.Now
                }
            };
            var mockedRepo = new Mock <IEfGenericRepository <Car> >();

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

            // Act
            var result = service.FilterExpiringAnnualCheckUpInTheNextSevenDays().ToList();

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