public async Task ArtifactsPublishedActionHelper_ReturnsFalse_WhenWorkflowStateIdDoesNotMatchConditionalStateId() { // non-matching State IDs const int conditionalStateId = 1 + WorkflowStateId; var states = new List <SqlWorkFlowStateInformation> { new SqlWorkFlowStateInformation { WorkflowStateId = WorkflowStateId, ArtifactId = 0, EndRevision = 0, ItemId = 0, ItemTypeId = 0, LockedByUserId = 0, Name = "", ProjectId = 0, Result = 0, StartRevision = 0, WorkflowId = 0, WorkflowName = "", WorkflowStateName = "" } }; var emailNotification = new EmailNotificationAction { ConditionalStateId = conditionalStateId, PropertyTypeId = PropertyTypeId }; emailNotification.Emails.Add(""); var notificationActions = new List <EmailNotificationAction> { emailNotification }; _repositoryMock.Setup(m => m.GetWorkflowPropertyTransitionsForArtifactsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IEnumerable <int> >())).ReturnsAsync(_triggers); _repositoryMock.Setup(m => m.GetWorkflowStatesForArtifactsAsync(It.IsAny <int>(), It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>())).ReturnsAsync(states); _repositoryMock.Setup(m => m.GetProjectNameByIdsAsync(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_projects); _repositoryMock.Setup(m => m.GetInstancePropertyTypeIdsMap(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_instancePropertyTypeIds); var actionsParserMock = new Mock <IActionsParser>(); actionsParserMock.Setup(m => m.GetNotificationActions(It.IsAny <IEnumerable <SqlWorkflowEvent> >())).Returns(notificationActions); var actionHelper = new ArtifactsPublishedActionHelper(actionsParserMock.Object); var result = await actionHelper.HandleAction(_tenantInformation, _messageWithModifiedProperties, _repositoryMock.Object); Assert.IsFalse(result); }
public async Task ArtifactsPublishedActionHelper_ReturnsFalse_WhenNoPublishedArtifactsAreFound() { // empty array of artifacts var message = new ArtifactsPublishedMessage { Artifacts = new PublishedArtifactInformation[] { } }; _repositoryMock.Setup(m => m.GetWorkflowPropertyTransitionsForArtifactsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IEnumerable <int> >())).ReturnsAsync(_triggers); var actionHelper = new ArtifactsPublishedActionHelper(); var result = await actionHelper.HandleAction(_tenantInformation, message, _repositoryMock.Object); Assert.IsFalse(result, "Message should not be processed successfully"); }
public async Task ArtifactsPublishedActionHelper_ReturnsFalse_WhenNoWorkflowStatesAreFound() { var message = new ArtifactsPublishedMessage { Artifacts = new[] { new PublishedArtifactInformation() } }; _repositoryMock.Setup(m => m.GetWorkflowPropertyTransitionsForArtifactsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IEnumerable <int> >())).ReturnsAsync(_triggers); // empty list of states var emptyStatesList = new List <SqlWorkFlowStateInformation>(); _repositoryMock.Setup(m => m.GetWorkflowStatesForArtifactsAsync(It.IsAny <int>(), It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>())).ReturnsAsync(emptyStatesList); var actionHelper = new ArtifactsPublishedActionHelper(); var result = await actionHelper.HandleAction(_tenantInformation, message, _repositoryMock.Object); Assert.IsFalse(result, "Message should not be processed successfully"); }
public async Task ArtifactsPublishedActionHelper_ReturnsFalse_WhenThereIsATriggerWithModifiedProperties() { // message with a list of modified properties var message = _messageWithModifiedProperties; _repositoryMock.Setup(m => m.GetWorkflowPropertyTransitionsForArtifactsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IEnumerable <int> >())).ReturnsAsync(_triggers); _repositoryMock.Setup(m => m.GetWorkflowStatesForArtifactsAsync(It.IsAny <int>(), It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>())).ReturnsAsync(_states); _repositoryMock.Setup(m => m.GetProjectNameByIdsAsync(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_projects); _repositoryMock.Setup(m => m.GetInstancePropertyTypeIdsMap(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_instancePropertyTypeIds); var actionsParserMock = new Mock <IActionsParser>(); actionsParserMock.Setup(m => m.GetNotificationActions(It.IsAny <IEnumerable <SqlWorkflowEvent> >())).Returns(_notificationActions); var actionHelper = new ArtifactsPublishedActionHelper(actionsParserMock.Object); var result = await actionHelper.HandleAction(_tenantInformation, message, _repositoryMock.Object); Assert.IsFalse(result); }
public async Task ArtifactsPublishedActionHelper_ReturnsFalse_WhenNoNotificationActionsAreFound() { var message = new ArtifactsPublishedMessage { Artifacts = new[] { new PublishedArtifactInformation() } }; _repositoryMock.Setup(m => m.GetWorkflowPropertyTransitionsForArtifactsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IEnumerable <int> >())).ReturnsAsync(_triggers); _repositoryMock.Setup(m => m.GetWorkflowStatesForArtifactsAsync(It.IsAny <int>(), It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>())).ReturnsAsync(_states); _repositoryMock.Setup(m => m.GetProjectNameByIdsAsync(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_projects); var actionsParserMock = new Mock <IActionsParser>(); // empty list of notification actions var emptyNotificationActionsList = new List <EmailNotificationAction>(); actionsParserMock.Setup(m => m.GetNotificationActions(It.IsAny <IEnumerable <SqlWorkflowEvent> >())).Returns(emptyNotificationActionsList); var actionHelper = new ArtifactsPublishedActionHelper(actionsParserMock.Object); var result = await actionHelper.HandleAction(_tenantInformation, message, _repositoryMock.Object); Assert.IsFalse(result); }
public async Task ArtifactsPublishedActionHelper_ReturnsFalse_WhenPropertyTypeIdDoesNotMatchNotificationPropertyTypeId() { // non-matching PropertyChange Type IDs const int notificationPropertyTypeId = 1 + PropertyTypeId; var emailNotification = new EmailNotificationAction { ConditionalStateId = WorkflowStateId, PropertyTypeId = notificationPropertyTypeId }; emailNotification.Emails.Add(""); var notificationActions = new List <EmailNotificationAction> { emailNotification }; var message = new ArtifactsPublishedMessage { Artifacts = new[] { new PublishedArtifactInformation { ModifiedProperties = new List <PublishedPropertyInformation> { new PublishedPropertyInformation { TypeId = PropertyTypeId } } } } }; _repositoryMock.Setup(m => m.GetWorkflowPropertyTransitionsForArtifactsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IEnumerable <int> >())).ReturnsAsync(_triggers); _repositoryMock.Setup(m => m.GetWorkflowStatesForArtifactsAsync(It.IsAny <int>(), It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>())).ReturnsAsync(_states); _repositoryMock.Setup(m => m.GetProjectNameByIdsAsync(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_projects); _repositoryMock.Setup(m => m.GetInstancePropertyTypeIdsMap(It.IsAny <IEnumerable <int> >())).ReturnsAsync(_instancePropertyTypeIds); var actionsParserMock = new Mock <IActionsParser>(); actionsParserMock.Setup(m => m.GetNotificationActions(It.IsAny <IEnumerable <SqlWorkflowEvent> >())).Returns(notificationActions); var actionHelper = new ArtifactsPublishedActionHelper(actionsParserMock.Object); var result = await actionHelper.HandleAction(_tenantInformation, message, _repositoryMock.Object); Assert.IsFalse(result); }