public void edit_add_id_is_zero()
        {
            var controller = new SystemController(_repository);

            var result = controller.Edit(0);

            result.Should().BeViewResult().ModelAs <Domain.Entities.System>().Name.Should().NotBeNull();
            result.Should().BeViewResult().ModelAs <Domain.Entities.System>().SystemId.Should().Be(0);
        }
        public void edit_get_by_id()
        {
            var controller = new SystemController(_repository);

            _repository.Add(new Domain.Entities.System()
            {
                SystemId = 1, Name = "App 1"
            });

            var result = controller.Edit(1);

            result.Should().BeViewResult().ModelAs <Domain.Entities.System>().Name.Should().Be("App 1");
        }
        public void edit_post_add()
        {
            var controller = new SystemController(_repository);
            var entity     = new Domain.Entities.System()
            {
                SystemId = 0, Name = "App"
            };

            var result = controller.Edit(entity);

            result.Should().BeRedirectToRouteResult().WithAction("Index").WithController("System");
            _repository.All.Should().HaveCount(1);
            _repository.GetById(0).Name.Should().Be("App");
        }
        public void edit_redirect_to_action_if_id_does_not_exist()
        {
            var controller = new SystemController(_repository);

            _repository.Add(new Domain.Entities.System()
            {
                SystemId = 1, Name = "App 1"
            });
            _repository.Add(new Domain.Entities.System()
            {
                SystemId = 2, Name = "App 2"
            });

            var result = controller.Edit(3);

            result.Should().BeRedirectToRouteResult().WithAction("Index").WithController("System");
        }
        public void edit_post_removing_spaces_for_the_name_field()
        {
            var controller = new SystemController(_repository);

            _repository.Add(new Domain.Entities.System()
            {
                SystemId = 1, Name = "App 1"
            });
            var entity = new Domain.Entities.System()
            {
                SystemId = 0, Name = "  App 2  "
            };

            controller.Edit(entity);

            entity.Name.Trim().Should().Be(_repository.GetById(0).Name);
        }
        public void edit_post_update()
        {
            var controller = new SystemController(_repository);

            _repository.Add(new Domain.Entities.System()
            {
                SystemId = 1, Name = "App 1"
            });
            _repository.Add(new Domain.Entities.System()
            {
                SystemId = 2, Name = "App 2"
            });
            var entity = new Domain.Entities.System()
            {
                SystemId = 2, Name = "Test"
            };

            var result = controller.Edit(entity);

            result.Should().BeRedirectToRouteResult().WithAction("Index").WithController("System");
            _repository.GetById(2).Name.Should().Be("Test");
        }