public void ValidateGenerateActionData_ChildArtifacts_CalledRespectiveValidationMethod() { // Arrange var result = new WorkflowDataValidationResult(); var action = new IeGenerateAction { GenerateActionType = GenerateActionTypes.Children }; _dataValidatorMock.Setup(m => m.ValidateGenerateChildArtifactsActionData(result, action, true)).Verifiable(); // Act _dataValidatorMock.Object.ValidateGenerateActionData(result, action, true); // Assert _dataValidatorMock.Verify(); }
public void ValidateActionData_GenerateAction_CalledRespectiveValidationMethod() { // Arrange var result = new WorkflowDataValidationResult(); var action = new IeGenerateAction(); _dataValidatorMock.Setup(m => m.ValidateGenerateActionData(result, action, true)).Verifiable(); // Act _dataValidatorMock.Object.ValidateActionData(result, action, true); // Assert _dataValidatorMock.Verify(); }
public void ValidateGenerateChildArtifactsActionData_ArtifcatTypeFound_Success() { // Arrange const string artifactType = "some"; var result = new WorkflowDataValidationResult(); result.StandardArtifactTypeMapByName.Add(artifactType, new ItemType()); var action = new IeGenerateAction { GenerateActionType = GenerateActionTypes.Children, ArtifactType = artifactType }; // Act _dataValidatorMock.Object.ValidateGenerateChildArtifactsActionData(result, action, true); // Assert Assert.AreEqual(false, result.HasErrors); }
public void ValidateGenerateChildArtifactsActionData_ArtifcatTypeNotFound_Error() { // Arrange const string artifactType = "some"; var result = new WorkflowDataValidationResult(); var action = new IeGenerateAction { GenerateActionType = GenerateActionTypes.Children, ArtifactType = artifactType }; // Act _dataValidatorMock.Object.ValidateGenerateChildArtifactsActionData(result, action, true); // Assert Assert.AreEqual(true, result.HasErrors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual(WorkflowDataValidationErrorCodes.GenerateChildArtifactsActionArtifactTypeNotFoundByName, result.Errors[0].ErrorCode); Assert.AreEqual(artifactType, result.Errors[0].Element as string); }
public virtual void ValidateGenerateChildArtifactsActionData(WorkflowDataValidationResult result, IeGenerateAction action, bool ignoreIds) { if (action == null) { return; } // Update Name where Id is present (to null if Id is not found) if (!ignoreIds && action.ArtifactTypeId.HasValue) { ItemType itemType; if (!result.StandardArtifactTypeMapById.TryGetValue(action.ArtifactTypeId.Value, out itemType)) { result.Errors.Add(new WorkflowDataValidationError { Element = action.ArtifactTypeId.Value, ErrorCode = WorkflowDataValidationErrorCodes.GenerateChildArtifactsActionArtifactTypeNotFoundById }); } action.ArtifactType = itemType?.Name; } if (action.ArtifactType == null) { return; } if (!result.StandardArtifactTypeMapByName.ContainsKey(action.ArtifactType)) { result.Errors.Add(new WorkflowDataValidationError { Element = action.ArtifactType, ErrorCode = WorkflowDataValidationErrorCodes.GenerateChildArtifactsActionArtifactTypeNotFoundByName }); } }
private static XmlGenerateAction ToXmlModel(IeGenerateAction ieAction, IDictionary <string, int> artifactTypeMap) { if (ieAction == null) { return(null); } var xmlAction = new XmlGenerateAction { Name = ieAction.Name, GenerateActionType = ieAction.GenerateActionType }; switch (ieAction.GenerateActionType) { case GenerateActionTypes.Children: xmlAction.ChildCount = ieAction.ChildCount; int artifactTypeId; if (!artifactTypeMap.TryGetValue(ieAction.ArtifactType, out artifactTypeId)) { throw new ExceptionWithErrorCode(I18NHelper.FormatInvariant("Id of Standard Artifact Type '{0}' is not found.", ieAction.ArtifactType), ErrorCodes.UnexpectedError); } xmlAction.ArtifactTypeId = artifactTypeId; break; case GenerateActionTypes.UserStories: case GenerateActionTypes.TestCases: break; default: throw new ArgumentOutOfRangeException(); } return(xmlAction); }
public virtual void ValidateGenerateActionData(WorkflowDataValidationResult result, IeGenerateAction action, bool ignoreIds) { if (action == null) { return; } switch (action.GenerateActionType) { case GenerateActionTypes.Children: ValidateGenerateChildArtifactsActionData(result, action, ignoreIds); break; case GenerateActionTypes.UserStories: case GenerateActionTypes.TestCases: // No data validation is required. break; default: throw new ArgumentOutOfRangeException(nameof(action.GenerateActionType)); } }