public void AirplaneTypeService_CheckInsert_ThrowNameException() { // Arrange var mock = new Mock <IAirplaneTypeRepository>(); mock.Setup(repo => repo.Create(new AirplaneTypeEntity())) .Returns(() => Task.CompletedTask); var service = new AirplaneTypeService(mock.Object); // Act var ex = Assert.ThrowsAnyAsync <NameException>(() => service.Create(new AirplaneType())); // Assert Assert.Equal("The AirplaneType have not empty or null name.", ex.Result.Message); }
public void AirplaneTypeService_CheckInsert_Created() { // Arrange var mock = new Mock <IAirplaneTypeRepository>(); mock.Setup(repo => repo.Create(StubsObjects.AirplaneType.ToEntity())) .Returns(() => Task.CompletedTask); var service = new AirplaneTypeService(mock.Object); // Act var result = service.Create(StubsObjects.AirplaneType).Result; // Assert Assert.Equal(StatusCode.Created, result); }