public async Task <PresidentDto> UpdatePresidentAsync(string id, PresidentDto dto) { if (string.IsNullOrEmpty(id)) { RaiseNotification(nameof(id)); } if (dto == null) { RaiseNotification(nameof(dto)); } if (Notification.HasNotification()) { return(new PresidentDto()); } var builder = new PresidentBuilder(Notification) .WithId(id) .WithName(dto.Name) .WithAddress(dto.Address); await _whiteHouserService.UpdatePresidentAsync(builder); dto.Id = id; return(dto); }
public void Create_Valid_President() { // Arrange var builder = new PresidentBuilder(LocalNotification) .WithId("1") .WithName("George Washington") .WithAddress("Rua de teste", "123", "APT 12", "99380000"); // Act builder.Build(); // Assert Assert.False(LocalNotification.HasNotification()); }
public async Task WhiteHouse_Service_Update_Valid_President() { // Arrange var builder = new PresidentBuilder(LocalNotification) .WithId("1") .WithName("George Washington") .WithAddress(new Address("Rua de teste", "123", "APT 12", new ZipCode("12345678"))); // Act await _whiteHouseService.UpdatePresidentAsync(builder); // Assert Assert.False(LocalNotification.HasNotification()); }
public void Create_President_With_Invalid_Address_Number() { // Arrange var builder = new PresidentBuilder(LocalNotification) .WithId("1") .WithName("George Washington") .WithAddress("Rua de teste", null, "APT 12", "99380000"); // Act builder.Build(); // Assert Assert.True(LocalNotification.HasNotification()); var notifications = LocalNotification.GetAll(); Assert.True(notifications.Any(a => a.Message == President.Error.PresidentAddressNumberMustHaveValue.ToString())); }
public async Task WhiteHouse_Service_Update_Not_Accept_Non_Existing_President() { // Arrange var builder = new PresidentBuilder(LocalNotification) .WithId("99") .WithName("George Washington") .WithAddress(new Address("Rua de teste", "123", "APT 12", new ZipCode("12345678"))); // Act await _whiteHouseService.UpdatePresidentAsync(builder); // Assert Assert.True(LocalNotification.HasNotification()); var notifications = LocalNotification.GetAll(); Assert.True(notifications.Any(a => a.Message == President.Error.CouldNotFindPresident.ToString())); }
public async Task <PresidentDto> InsertPresidentAsync(PresidentDto dto) { if (dto == null) { RaiseNotification(nameof(dto)); } if (Notification.HasNotification()) { return(new PresidentDto()); } var builder = new PresidentBuilder(Notification) .WithId(dto.Id) .WithName(dto.Name) .WithAddress(dto.Address); dto.Id = await _whiteHouserService.InsertPresidentAsync(builder); return(dto); }
public async Task WhiteHouse_Service_Insert_Valid_Presidents() { //Arrange LocalEventBus.Register <PresidentCreatedEvent>( eventData => { var presidentEvent = eventData.President; Assert.True(presidentEvent.Id == "1" || presidentEvent.Id == "2"); }); var builder = new PresidentBuilder(LocalNotification) .WithId("1") .WithName("George Washington") .WithAddress(new Address("Rua de teste", "123", "APT 12", new ZipCode("12345678"))); // Act await _whiteHouseService.InsertPresidentAsync(builder); // Assert Assert.False(LocalNotification.HasNotification()); }