public void ShouldShowEmptyForumFormOnLoadWithNoId()
 {
     var view = _repository.DynamicMock<IForumFormView>();
     var provider = _repository.DynamicMock<IForumProvider>();
     var loader = default(IEventRaiser);
     var id = 0;
     var data = new ForumInput();
     With.Mocks(_repository).
         ExpectingInSameOrder(() =>
                                  {
                                      view.Load += null;
                                      loader = LastCall.IgnoreArguments().GetEventRaiser();
                                      Expect.Call(view.IsPostBack).Return(false);
                                      Expect.Call(view.CurrentId).Return(id).Repeat.Any();
                                      Expect.Call(view.Forum = data);
                                      LastCall.IgnoreArguments();
                                      SetupResult.For(view.Forum).Return(data);
                                  }).
         Verify(() =>
                    {
                        new ForumFormPresenter(view, provider);
                        loader.Raise(null, new EventArgs());
                        Assert.IsNotNull(view.Forum);
                        Assert.AreEqual(data.Name, view.Forum.Name);
                    });
 }
 public void ShouldGoToShowForumOnCreateWithNoId()
 {
     var view = _repository.DynamicMock<IForumFormView>();
     var provider = _repository.DynamicMock<IForumProvider>();
     var loader = default(IEventRaiser);
     var creator = default(IEventRaiser);
     var input = new ForumInput {Name = "New Forum"};
     var data = new ForumMapper().FromInput(input);
     var newId = 321;
     With.Mocks(_repository).
         ExpectingInSameOrder(() =>
                                  {
                                      view.Load += null;
                                      loader = LastCall.IgnoreArguments().GetEventRaiser();
                                      view.Create += null;
                                      creator = LastCall.IgnoreArguments().GetEventRaiser();
                                      Expect.Call(view.IsPostBack).Return(true);
                                      Expect.Call(view.IsValid).Return(true);
                                      Expect.Call(view.Forum).Return(input);
                                      Expect.Call(provider.Create(data)).IgnoreArguments().Return(newId);
                                      Expect.Call(() => view.GoToShowForum(newId));
                                  }).
         Verify(() =>
                    {
                        new ForumFormPresenter(view, provider);
                        loader.Raise(null, new EventArgs());
                        creator.Raise(null, new EventArgs());
                    });
 }
 public void ShouldMapForumEntityFromInput()
 {
     // Arrange
     var input = new ForumInput {Id = 1423, Name = "FromInput name"};
     // Act
     var data = new ForumMapper().FromInput(input);
     // Assert
     Assert.AreEqual(input.Id, data.Id);
     Assert.AreEqual(input.Name, data.Name);
 }