コード例 #1
0
        public async Task DeletePais_NotFound()
        {
            var options = Options;

            await AdicionarPais(options);

            using (CompeticoesDbContext context = new CompeticoesDbContext(options))
            {
                var controller = new PaisesController(context);

                var result = await controller.DeletePais(Guid.NewGuid());

                Assert.IsType <NotFoundResult>(result);
            }
        }
コード例 #2
0
        public async Task DeletePaisAsync_ShouldDeletePaisBBAsync()
        {
            Thread.Sleep(2000);
            //Arrange
            var testContext    = OMSContextMocker.GetOMSContext("DBTestForPaisesDelete");
            var testController = new PaisesController(testContext);

            //Act
            var result = await testController.DeletePais("BB");

            var get = await testController.GetPais("BB");

            //Assert
            Assert.IsType <NotFoundResult>(get.Result);
            Assert.IsType <NoContentResult>(result);
        }
コード例 #3
0
        public async Task DeletePais_BadRequest_ModelState_Invalido()
        {
            var options = Options;

            using (CompeticoesDbContext context = new CompeticoesDbContext(options))
            {
                PaisesController controller = new PaisesController(context);

                controller.ModelState.AddModelError("Key", "Error");

                var result = await controller.DeletePais(Guid.Empty);

                var badRequestResult = Assert.IsType <BadRequestObjectResult>(result);
                var valueResult      = Assert.IsType <SerializableError>(badRequestResult.Value);
                var value            = Assert.IsType <string[]>(valueResult["Key"]);
                Assert.Equal("Error", value[0]);
            }
        }
コード例 #4
0
        public async Task DeltePais_Ok()
        {
            var options = Options;

            var pais = await AdicionarPais(options);

            using (CompeticoesDbContext context = new CompeticoesDbContext(options))
            {
                var controller = new PaisesController(context);

                var result = await controller.DeletePais(pais.PaisId);

                var okResult   = Assert.IsType <OkObjectResult>(result);
                var paisResult = Assert.IsType <Pais>(okResult.Value);
            }

            using (CompeticoesDbContext context = new CompeticoesDbContext(options))
            {
                Assert.True(!(await context.Paises.AnyAsync(a => a.PaisId == pais.PaisId)));
            }
        }