public void SendOutEmailsAboutEventUsesNotificationSettings() { //arrange _userPresentationProviderMock.Setup(provider => provider.GetUserEventSettings(42, It.IsAny <string>())) .Returns(NotificationSettingValue.SendNotificationAndMail); _userPresentationProviderMock.Setup(provider => provider.GetUserEventSettings(52, It.IsAny <string>())) .Returns(NotificationSettingValue.SendNotificationAndMail); _userPresentationProviderMock.Setup(provider => provider.GetUserEventSettings(77, It.IsAny <string>())) .Returns(NotificationSettingValue.SendOnlyNotification); _distributionPolicyFactoryMock.Setup(factory => factory.GetAdminRelatedPolicy()) .Returns(new DistributionPolicy(new[] { 42 })); _distributionPolicyFactoryMock.Setup(factory => factory.GetProjectRelatedPolicy(It.IsAny <int>())) .Returns(new DistributionPolicy(new[] { 52, 77 })); _projectsEventSink = new ProjectsEventSink( _distributionPolicyFactoryMock.Object, _eventRepositoryMock.Object, _mailerMock.Object, _userPresentationProviderMock.Object); var developerOnProjectEvent = new NewDeveloperOnProject(11, 10); //act _projectsEventSink.ConsumeEvent(developerOnProjectEvent); //assert _mailerMock.Verify(mailer => mailer.SendNotificationEmail(new[] { 52, 42 }, developerOnProjectEvent), Times.Once); }
private string Describe(NewDeveloperOnProject @event) { Require.NotNull(@event, nameof(@event)); var developer = _userRepository.GetAccount(@event.UserId); var developerFullName = developer.Firstname + " " + developer.Lastname; var project = _projectRepository.GetProject(@event.ProjectId); return(string.Format(EventDescriptionResources.NewDeveloperOnProject, project.Name, developerFullName)); }
public void AddUserToProject(int projectId, int userId, string role) { Require.Positive(projectId, nameof(projectId)); Require.Positive(userId, nameof(userId)); var project = GetProject(projectId); if (project.ProjectMemberships.Any(developer => developer.DeveloperId == userId)) { throw new InvalidOperationException("Attempt to add developer who is already on project"); } project.ProjectMemberships.Add(new ProjectMembership( userId, role)); UpdateProject(project); var @event = new NewDeveloperOnProject(userId, projectId); _eventBus.PublishEvent("Notification", "new_developer_on_project", @event); }
public void NotifyAboutNewDeveloperOnProject(NewDeveloperOnProject @event) { NotifyAboutNewEvent(@event); }