Exemplo n.º 1
0
        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>();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
 public UpdateCountryCommandHandlerTests()
 {
     countryId = CommandArrangeHelper.GetCountryId(context);
     sut       = new UpdateCountryCommandHandler(context);
 }