コード例 #1
0
 public ActionResult Index(Person per)
 {
     return View();
 }
コード例 #2
0
 public int SavePerson(Person person)
 {
     db.People.Add(person);
     return db.SaveChanges();
 }
コード例 #3
0
 public ActionResult Results(Person model)
 {
     return View("Results", model);
 }
コード例 #4
0
        public void Put_Person_Throws_When_Update_fails()
        {
            // Arrange
            var person = new Web.Models.Person {Id = ObjectId.GenerateNewId().ToString()};
            var service = new Mock<IPersonService>();
            service.Setup(s => s.Update(It.IsAny<Library.Entity.Person>())).Throws<Exception>();
            var controller = new PersonController(service.Object);

            // Act
            var result = controller.Put(person.Id, person) as ExceptionResult;

            // Assert
            Assert.NotNull(result);
        }
コード例 #5
0
        public void Put_Person_Runs_Service_Update()
        {
            // Arrange
            var person = new Web.Models.Person
            {
                FirstName = "John",
                LastName = "McClung",
                MiddleName = "Paul",
                Notes = "Crazy as can be",
                Id = ObjectId.GenerateNewId().ToString()
            };
            var service = Mock.Of<IPersonService>();
            var controller = new PersonController(service);

            // Act
            controller.Put(person.Id, person);

            // Assert
            Mock.Get(service).Verify(s =>
                s.Update(It.Is<Library.Entity.Person>
                    (e => e.Id.ToString() == person.Id)), Times.Once);
        }
コード例 #6
0
 public int SavePerson(Person person)
 {
     return repo.SavePerson(person);
 }