static void Main(string[] args) { ICarService carService = new CarService(); ICarService mockCarService = new MockCarService(); mockCarService.RepairCar(new Car()); carService.RepairCar(new MockCar()); carService.RepairCar(new Car()); }
public async void CarsController_GetById_Empty() { // Arrange var mockCarYear = 1980; var mockCar = MockCarData.GetSingleEmptyModelAsync(); var mockCarService = new MockCarService().MockGetById(mockCar); var mockLogging = new Mock <ILogger <CarsController> >(); var controller = new CarsController(mockCarService.Object, mockLogging.Object); // Act var result = await controller.Get(mockCarYear); // Assert result.Should().BeOfType <NotFoundResult>(); mockCarService.VerifyGetById(Times.Once()); }
public async void CarsController_GetById_Valid() { // Arrange var mockCarYear = 2020; var mockCar = MockCarData.GetSingleModelAsync(); var mockCarService = new MockCarService().MockGetById(mockCar); var mockLogging = new Mock <ILogger <CarsController> >(); var controller = new CarsController(mockCarService.Object, mockLogging.Object); // Act var result = await controller.Get(mockCarYear); // Assert Assert.IsAssignableFrom <IActionResult>(result); mockCarService.VerifyGetById(Times.Once()); }
public async void CarsController_GetAll_Valid() { // Arrange var mockCar = MockCarData.GetAllModelListAsync(); CarsResourceParameters parameters = new CarsResourceParameters { }; var mockCarService = new MockCarService().MockGetAll(mockCar); var mockLogging = new Mock <ILogger <CarsController> >(); var controller = new CarsController(mockCarService.Object, mockLogging.Object); // Act var result = await controller.Get(parameters); // Assert Assert.IsAssignableFrom <IActionResult>(result); mockCarService.VerifyGetAll(Times.Once()); }
public async void CarsController_GetAll_Empty() { // Arrange var mockCar = MockCarData.GetEmptyModelListAsync(); CarsResourceParameters parameters = new CarsResourceParameters { }; var mockCarService = new MockCarService().MockGetAll(mockCar); var mockLogging = new Mock <ILogger <CarsController> >(); var controller = new CarsController(mockCarService.Object, mockLogging.Object); // Act var result = await controller.Get(parameters); // Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var car = okResult.Value.Should().BeAssignableTo <IEnumerable <CarDto> >().Subject; car.Count().Should().Be(0); mockCarService.VerifyGetAll(Times.Once()); }