public void Handles_WillAttend_Null_Values()
 {
     // Arrange
     IRepository repo = new MockRepository();
     IPresenter<GuestResponse> target = new RsvpPresenter { Repository = repo };
     // Act
     GuestResponse dataObject
         = new GuestResponse { Name = "TEST", WillAttend = null };
     IResult result = target.GetResult(dataObject);
 }
 public void Adds_Object_To_Repository()
 {
     // Arrange
     IRepository repo = new MockRepository();
     IPresenter<GuestResponse> target = new RsvpPresenter { Repository = repo };
     GuestResponse dataObject =
         new GuestResponse { Name = "TEST", WillAttend = true };
     // Act
     IResult result = target.GetResult(dataObject);
     // Assert
     Assert.AreEqual(repo.GetAllResponses().Count(), 3);
     Assert.AreEqual(repo.GetAllResponses().Last().Name, "TEST");
     Assert.AreEqual(repo.GetAllResponses().Last().WillAttend, true);
 }
 public void Handles_WillAttend_Values()
 {
     // Arrange
     IRepository repo = new MockRepository();
     IPresenter<GuestResponse> target = new RsvpPresenter { Repository = repo };
     bool?[] values = { true, false };
     // Act & Assert
     foreach (bool? testValue in values)
     {
         GuestResponse dataObject =
             new GuestResponse { Name = "TEST", WillAttend = testValue };
         IResult result = target.GetResult(dataObject);
         Assert.IsInstanceOfType(result, typeof(RedirectResult));
     }
 }
        public void Handles_WillAttend_Values()
        {
            // Организация
            IRepository repository            = new MockRepository();
            IPresenter <GuestResponse> target = new RsvpPresenter {
                Repository = repository
            };

            bool?[] values = { true, false, null };

            // Действие и утверждение
            foreach (IResult result in values.Select(testValue => new GuestResponse {
                Name = "TEST", WillAttend = testValue
            }).Select(target.GetResult))
            {
                Assert.IsInstanceOfType(result, typeof(RedirectResult));
            }
        }
        public void Adds_Objects_To_Repository()
        {
            // Организация
            IRepository repository = new MockRepository();
            IPresenter <GuestResponse> presenter = new RsvpPresenter {
                Repository = repository
            };
            var guestResponse = new GuestResponse {
                Name = "TEST", WillAttend = true
            };

            // Действие
            presenter.GetResult(guestResponse);

            // Утверждение
            Assert.AreEqual(repository.GetAllResponses().Count(), 3);
            Assert.AreEqual(repository.GetAllResponses().Last().Name, "TEST");
            Assert.AreEqual(repository.GetAllResponses().Last().WillAttend, true);
        }