public async void ShouldAddTrip() { //Given var now = DateTime.Now; var companyName = "New One"; var calendar = await CalendarRepository.Add(now); var company = await CompanyRepository.Add(new Company { Name = companyName }, true); var vehicle = await VehicleRepository.Add(new Vehicle { Name = "Vehicle" }, true); var vehicleType = await VehicleTypeRepository.Add(new VehicleType { Name = "VehicleType" }, true); var neighborhood = await NeighborhoodRepository.Add(new Neighborhood { Name = "Neighborhood" }, true); var patternArea = await PatternAreaRepository.Add(new PatternArea { Name = "Pattern Area" }, true); var paymentType = await PaymentTypeRepository.Add(new PaymentType { Name = "Payment" }, true); var controller = new TripController( new Mock <ILogger <TripController> >().Object, TripRepository, CalendarRepository, CompanyRepository, VehicleRepository ); var tripDTO = new TripDTO { StartTime = now, EndTime = now.AddHours(2), CompanyName = companyName, VehicleName = vehicle.Name, VehicleTypeKey = Convert.ToByte(vehicleType.Key), NeighborhoodStartKey = neighborhood.Key, NeighborhoodEndKey = neighborhood.Key, PatternAreaStartKey = patternArea.Key, PatternAreaEndKey = patternArea.Key, PaymentTypeKey = Convert.ToByte(paymentType.Key), PaymentAccessKey = Convert.ToByte(paymentType.Key) }; //When var result = await controller.PostAsync(tripDTO); var dbTrip = await TripRepository.Find(1); //Then var viewResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsType <TripDTO>(viewResult.Value); Assert.NotNull(model); Assert.Equal(tripDTO.EndTime.TimeOfDay, dbTrip.EndTime); }