public async void Should_Return_Vehicle_By_Id() { // Arrange var vehicles = DataProvider.GetVehicles(); var bookingsMock = new List <Booking>().AsQueryable().BuildMock(); var vehicleRepositoryMock = new Mock <IGenericRepository <Vehicle, int> >(); vehicleRepositoryMock.Setup(m => m.GetById(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(vehicles.SingleOrDefault(v => v.Id == id))); var bookingRepositoryMock = new Mock <IGenericRepository <Booking, int> >(); bookingRepositoryMock.Setup(m => m.Get()) .Returns(bookingsMock.Object); var vehicleController = new VehicleController(vehicleRepositoryMock.Object, Mock.Of <IGenericRepository <VehicleModel, int> >(), bookingRepositoryMock.Object, Mock.Of <IGenericRepository <Insurance, int> >(), MapperProvider.GetMapper()); // Act var request = await vehicleController.GetById(1); var result = request as OkObjectResult; // Assert Assert.NotNull(result); Assert.True(result.StatusCode == 200); }