public async Task GetById_Sucess() { Guid request = new Guid(); var mock = new Mock <IVehicleService>(); mock.Setup(service => service.GetByIdAsync(It.IsAny <VehicleId>())); VehiclesController controller = new VehiclesController(mock.Object); var result = await controller.GetGetById(request); mock.Verify(service => service.GetByIdAsync(It.IsAny <VehicleId>()), Times.AtLeastOnce()); }
public async Task GetById_NormalId_Sucess() { Guid id = new Guid(); var mockRepository = new Mock <IVehicleRepository>(); mockRepository.Setup(repository => repository.GetByIdAsync(It.IsAny <VehicleId>())); var mockUnit = new Mock <IUnitOfWork>(); VehicleService VehicleService = new VehicleService(mockUnit.Object, mockRepository.Object); VehiclesController controller = new VehiclesController(VehicleService); var result = await controller.GetGetById(id); mockRepository.Verify(repository => repository.GetByIdAsync(It.IsAny <VehicleId>()), Times.AtLeastOnce()); Assert.IsInstanceOfType(result, typeof(ActionResult <VehicleDto>)); }