public void CanEditPerson()
        {
            Mock<IRepository<Person>> mock_person = new Mock<IRepository<Person>>();
            Mock<IRepository<Section>> mock_section = new Mock<IRepository<Section>>();
            mock_section.Setup(m => m.Repository).Returns(CreateSectionTab().AsQueryable());
            mock_person.Setup(m => m.Repository).Returns(CreatePersonTab().AsQueryable());

            PersonController controller = new PersonController(mock_person.Object, mock_section.Object);
            PersonSectionAddEditModel personSection = new PersonSectionAddEditModel();

            personSection.id = 5;
            personSection.name = "Zbigniew";
            personSection.surname = "Strzelec";
            personSection.area_code = 44;
            personSection.email = "*****@*****.**";
            personSection.section_name = "4";
            personSection.phone_number = 12345;
            personSection.phone_number2 = 666666;

            var redirectToRouteResult = controller.Edit(personSection) as RedirectToRouteResult;

            Person temp = mock_person.Object.Repository.FirstOrDefault(x => x.id == 5);
            Assert.AreEqual(temp.name, "ZBIGNIEW");
            Assert.AreEqual(temp.surname, "STRZELEC");
            Assert.AreEqual(temp.area_code, 44);
            Assert.AreEqual(temp.email, "*****@*****.**");
            Assert.AreEqual(temp.id_section, 4);
            Assert.AreEqual(temp.phone_number, 12345);
            Assert.AreEqual(temp.phone_number2, 666666);

            mock_person.Verify(m => m.EditObject(temp), Times.Once());

            Assert.IsNotNull(redirectToRouteResult);
            Assert.AreEqual("Index", redirectToRouteResult.RouteValues["Action"]);
        }
        public void CantEditPerson()
        {
            Mock<IRepository<Person>> mock_person = new Mock<IRepository<Person>>();
            Mock<IRepository<Section>> mock_section = new Mock<IRepository<Section>>();
            mock_section.Setup(m => m.Repository).Returns(CreateSectionTab().AsQueryable());
            mock_person.Setup(m => m.Repository).Returns(CreatePersonTab().AsQueryable());

            PersonController controller = new PersonController(mock_person.Object, mock_section.Object);
            PersonSectionAddEditModel personSection = null;

            var redirectToRouteResult = controller.Edit(personSection) as RedirectToRouteResult;

            mock_person.Verify(m => m.EditObject(It.IsAny<Person>()), Times.Never());

            Assert.IsNotNull(redirectToRouteResult);
            Assert.AreEqual("Index", redirectToRouteResult.RouteValues["Action"]);
        }