예제 #1
0
        public void GetCarInformationAsync_PassingNullForCarOptions_ShouldThrowArgumentException()
        {
            //Arrange
            var mockLogger = new Mock <ILog>();
            var carDealershipRepositoryMock = new Mock <ICarDealershipRepository>();
            var CarDealershipService        = new CarDealershipService(mockLogger.Object, carDealershipRepositoryMock.Object);

            //Act
            Func <Task> result = async() =>
            {
                await CarDealershipService.GetCarInformationAsync(null);
            };

            //Assert
            result.ShouldThrow <ArgumentException>();
        }
예제 #2
0
        public void GetCarInformationAsync_GivenCarOptions_ShouldCallGetCarInformationAsyncWithOptionsPassed()
        {
            //Arrange
            var mockLogger = new Mock <ILog>();
            var carDealershipRepositoryMock = new Mock <ICarDealershipRepository>();

            carDealershipRepositoryMock
            .Setup(sut => sut.GetCarInformationAsync(It.IsAny <Car>()))
            .ReturnsAsync(new Models.ViewModel.CarViewModel());

            var carOptions = new Car();

            //Act
            var CarDealershipService = new CarDealershipService(mockLogger.Object, carDealershipRepositoryMock.Object);
            var result = CarDealershipService.GetCarInformationAsync(carOptions);

            //Assert
            carDealershipRepositoryMock.Verify(repo => repo.GetCarInformationAsync(carOptions));
        }