public TrafficDetector Add(TrafficDetector trafficDetector) { return(_context .TrafficDetectors .Add(trafficDetector) .Entity); }
public async Task should_add_new_item() { var testTrafficDetector = new TrafficDetector { Name = "Zakrzowek", Latitude = 50.080852F, Longitude = 19.950825F }; _repo.Add(testTrafficDetector); await _repo.UnitOfWork.SaveEntitiesAsync(); await _context.TrafficDetectors.FirstOrDefaultAsync(_ => _.Id == testTrafficDetector.Id).ShouldNotBeNull(); }
public async Task should_update_traffic_detector() { var testTrafficDetector = new TrafficDetector { Id = new Guid("f8de7cdc-c94c-4f94-9577-9613087e00b5"), Name = "Zakrzowek", Latitude = 50.080852F, Longitude = 19.950825F }; _repo.Update(testTrafficDetector); await _repo.UnitOfWork.SaveEntitiesAsync(); _context.TrafficDetectors.FirstOrDefaultAsync(x => x.Id == testTrafficDetector.Id)?.Result.Name.ShouldBe("Zakrzowek"); }
public TrafficDetector Update(TrafficDetector trafficDetector) { _context.Entry(trafficDetector).State = EntityState.Modified; return(trafficDetector); }