public async Task ReturnesAllCarsByOwner_WithCorrectOwner() { // Arrange var mock = new Mock <CarOwnerRepository>(); mock.Setup(r => r.CarsByOwner(testOwner())).Returns(GetListCars()); var controller = new CarOwnerController(mock.Object); // Act var result = controller.CarsByOwner(testOwner()); // Assert Assert.NotNull(result); Assert.IsType <JsonResult>(result); Assert.Equal(result.ToString(), new JsonResult(GetListCars()).ToString()); }
public async Task ReturnsAllOwners_WithCorrectCarNumber() { // Arrange string carNumber = "AA0000AA"; var mock = new Mock <CarOwnerRepository>(); mock.Setup(r => r.OwnersByCar(carNumber)).Returns(GetListOwner()); var controller = new CarOwnerController(mock.Object); // Act var result = controller.OwnersByCar(carNumber); // Assert Assert.NotNull(result); Assert.IsType <JsonResult>(result); Assert.Equal(result.ToString(), new JsonResult(GetListOwner()).ToString()); }