public async Task Update_Country_With_Wrong_Id_Should_Throw_Exception() { var command = new UpdateCountryCommand { Id = -1, Name = "Poland" }; var commandHandler = new UpdateCountryCommandHandler(_context, _mapper); await commandHandler.Handle(command, CancellationToken.None).ShouldThrowAsync <NotFoundException>(); }
public async Task Update_Country_Should_Edit_Country_In_Database() { var command = new UpdateCountryCommand { Id = 2, Name = "Poland" }; var commandHandler = new UpdateCountryCommandHandler(_context, _mapper); await commandHandler.Handle(command, CancellationToken.None); var result = _context.Countries .Where(x => x.Id.Equals(command.Id)) .Where(x => x.Name.Equals(command.Name)) .FirstOrDefault(); result.ShouldNotBeNull(); }
public UpdateCountryCommandHandlerTests() { countryId = CommandArrangeHelper.GetCountryId(context); sut = new UpdateCountryCommandHandler(context); }