Example #1
0
        public async void CountryShouldUpdateCorrect()
        {
            var updatedCountry = new UpdateCountryCommand {
                Id = countryId, Name = GConst.UpdatedName
            };

            var status = Task <Unit> .FromResult(await sut.Handle(updatedCountry, CancellationToken.None));

            var resultId = context.Countries.SingleOrDefault(x => x.Name == GConst.UpdatedName).Id;

            Assert.Equal(countryId, resultId);
            Assert.Equal(GConst.SuccessStatus, status.Status.ToString());
            Assert.Equal(GConst.ValidCount, context.Countries.Count());
        }
Example #2
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>();
        }
Example #3
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();
        }