public void ResponseReceivedForNewUserGroup_PublishesCorrectEvent() { var suitableParents = new[] { new UserGroupDto { Id = Guid.NewGuid() } }; var userGroup = new UserGroupDto { Name = "some group", ParentId = suitableParents[0].Id }; Presenter.BindingModel.Populate(suitableParents, userGroup); var newId = Guid.NewGuid(); RequestDispatcherStub.SetResponsesToReturn(new SaveUserGroupResponse { NewUserGroupId = newId }); Presenter.PersistChanges(); RequestDispatcherStub.ReturnResponses(); var publishedEvent = EventAggregatorStub.GetPublishedEvents <UserGroupChangedEvent>()[0]; Assert.AreEqual(newId, publishedEvent.Id); Assert.AreEqual(userGroup.Name, publishedEvent.Name); Assert.AreEqual(userGroup.ParentId.Value, publishedEvent.ParentId.Value); Assert.IsTrue(publishedEvent.IsNew); }
public void DealWithSelectedUserGroup_PublishesEvent() { var userGroup = new HierarchicalUserGroupBindingModel { Id = Guid.NewGuid() }; Presenter.DealWithSelectedUserGroup(userGroup); Assert.AreEqual(userGroup.Id, EventAggregatorStub.GetPublishedEvents <UserGroupSelectedEvent>()[0].SelectedUserGroupId); }
public void PublishesUserGroupDeletedEventWhenResponseIsReturned() { Presenter.BindingModel.Id = Guid.NewGuid(); RequestDispatcherStub.SetResponsesToReturn(new DeleteUserGroupResponse()); Presenter.Delete(); RequestDispatcherStub.ReturnResponses(); Assert.AreEqual(Presenter.BindingModel.Id.Value, EventAggregatorStub.GetPublishedEvents <UserGroupDeletedEvent>()[0].UserGroupId); }
public void PublishesEventIfRemoteExceptionOccurred() { var exception = new ExceptionInfo(); Presenter.Handle(new UserGroupNeedsToBeCreatedEvent()); RequestDispatcherStub.SetResponsesToReturn(new GetSuitableParentUserGroupsResponse { Exception = exception }); RequestDispatcherStub.ReturnResponses(); Assert.AreEqual(exception, EventAggregatorStub.GetPublishedEvents <RemoteExceptionOccurredEvent>()[0].ExceptionInfo); }
public void PublishesEventIfRemoteExceptionOccurred() { var exception = new ExceptionInfo(); Presenter.Initialize(); RequestDispatcherStub.SetResponsesToReturn(new GetAllUserGroupsResponse { Exception = exception }); RequestDispatcherStub.ReturnResponses(); Assert.AreEqual(exception, EventAggregatorStub.GetPublishedEvents <RemoteExceptionOccurredEvent>()[0].ExceptionInfo); }
public void PublishesEventIfRemoteExceptionOccurred() { Presenter.BindingModel.Id = Guid.NewGuid(); var exception = new ExceptionInfo(); RequestDispatcherStub.SetResponsesToReturn(new DeleteUserGroupResponse { Exception = exception }); Presenter.Delete(); RequestDispatcherStub.ReturnResponses(); Assert.AreEqual(exception, EventAggregatorStub.GetPublishedEvents <RemoteExceptionOccurredEvent>()[0].ExceptionInfo); }
public void PublishesEventIfRemoteExceptionOccurred() { var userGroup = new UserGroupDto { Id = Guid.NewGuid(), Name = "some group" }; Presenter.BindingModel.Populate(new UserGroupDto[0], userGroup); var exception = new ExceptionInfo(); RequestDispatcherStub.SetResponsesToReturn(new SaveUserGroupResponse { Exception = exception }); Presenter.PersistChanges(); RequestDispatcherStub.ReturnResponses(); Assert.AreEqual(exception, EventAggregatorStub.GetPublishedEvents <RemoteExceptionOccurredEvent>()[0].ExceptionInfo); }
public void PublishesEvent() { Presenter.PrepareUserGroupCreation(); Assert.AreEqual(1, EventAggregatorStub.GetPublishedEvents <UserGroupNeedsToBeCreatedEvent>().Length); }
public void Initialize_SubscribesToUserGroupNeedsToBeCreatedEvent() { Presenter.Initialize(); Assert.IsTrue(EventAggregatorStub.IsListenerSubscribedTo <UserGroupNeedsToBeCreatedEvent>(Presenter)); }
public void SubscribesToUserGroupChangedEvent() { Presenter.Initialize(); Assert.IsTrue(EventAggregatorStub.IsListenerSubscribedTo <UserGroupChangedEvent>(Presenter)); }