Esempio n. 1
0
        public void TestDeleteEnvrironment()
        {
            int listCount = _controller.Delete(1);

            Assert.AreEqual(0, listCount);

            listCount = _controller.Delete(7);
            Assert.AreEqual(0, listCount);

            IEnumerable <EnvironmentClass> EnvList = _controller.Get();

            Assert.AreEqual(6, EnvList.Count()); // Passed, but check again to be sure
        }
        public void Delete_NotFoundIdEnvironment()
        {
            var context = _contextFake.GetContext("Delete_NotFoundIdEnvironment")
                          .AddFakeEnvironments();

            var repo = new EnvironmentRepository(context);

            var controller = new EnvironmentController(repo, _mapper);

            var result       = controller.Delete(int.MaxValue);
            var actionResult = Assert.IsType <NotFoundResult>(result);
        }
        public void Delete_ShouldWork()
        {
            var context = _contextFake.GetContext("Delete_ShouldWork")
                          .AddFakeEnvironments();
            var repo = new EnvironmentRepository(context);

            var controller        = new EnvironmentController(repo, _mapper);
            var deleteEnvironment = context.Environments.FirstOrDefault();

            var result       = controller.Delete(deleteEnvironment.Id);
            var actionResult = Assert.IsType <NoContentResult>(result);

            var actual = context.Environments.SingleOrDefault(x => x.Id == deleteEnvironment.Id);

            Assert.Null(actual);
        }
        public void Should_Be_Ok_When_Delete(int id)
        {
            var fakes = new FakeContext("EnvironmentTest");

            var fakeEnvironmentService = fakes.FakeEnvironmentService().Object;

            var expected = fakes.Mapper.Map <CentralErros.Models.Environment>(fakeEnvironmentService.FindById(id));

            var contexto = new CentralErroContexto(fakes.FakeOptions);

            var controller = new EnvironmentController(fakeEnvironmentService,
                                                       fakes.Mapper, contexto);

            var result = controller.Delete(id);

            Assert.IsType <OkObjectResult>(result.Result);
            var actual = (result.Result as OkObjectResult).Value as CentralErros.Models.Environment;

            Assert.NotNull(actual);
            Assert.Equal(expected, actual, new EnvironmentIdComparer());
        }