public async Task Post(Shared.Airport airport) { try { await _airportService.Create(airport); } catch (Exception) { throw; } }
public void AddExistingAirport() { var s = new AirportService(new TestStorageService()); var a = new Airport { IataCode = "BLL", Name = "Billund", Latitude = 50.1234, Longitude = 51.456, }; s.Create(a); }
public void AirportService_CheckInsert_ThrowNameException() { // Arrange var mock = new Mock <IAirportRepository>(); mock.Setup(repo => repo.Create(new AirportEntity())) .Returns(() => Task.CompletedTask); var service = new AirportService(mock.Object); // Act var ex = Assert.ThrowsAnyAsync <NameException>(() => service.Create(new Airport())); // Assert Assert.Equal("The Airport have not empty or null name.", ex.Result.Message); }
public void AirportService_CheckInsert_Created() { // Arrange var mock = new Mock <IAirportRepository>(); mock.Setup(repo => repo.Create(StubsObjects.Airport.ToEntity())) .Returns(() => Task.CompletedTask); var service = new AirportService(mock.Object); // Act var result = service.Create(StubsObjects.Airport).Result; // Assert Assert.Equal(StatusCode.Created, result); }
public void AddAirport() { var s = new AirportService(new TestStorageService()); var a = new Airport { IataCode = "ARN", Name = "Arlanda", Latitude = 50.1234, Longitude = 51.456, }; s.Create(a); var na = s.GetByIataCode("ARN"); Assert.AreEqual <string>("ARN", a.IataCode); }