/// <summary> /// A function to validate if the attribute context tree & traits generated for a resolved entity is the same as the expected and saved attribute context tree & traits for a test case /// </summary> /// <param name="corpus"></param> /// <param name="expectedOutputPath"></param> /// <param name="entityName"></param> /// <param name="resolvedEntity"></param> public static void ValidateAttributeContext(CdmCorpusDefinition corpus, string expectedOutputPath, string entityName, CdmEntityDefinition resolvedEntity) { if (resolvedEntity.AttributeContext != null) { AttributeContextUtil attrCtxUtil = new AttributeContextUtil(); string actualText = attrCtxUtil.GetAttributeContextStrings(resolvedEntity, resolvedEntity.AttributeContext); string expectedStringFilePath = Path.GetFullPath(Path.Combine(expectedOutputPath, $"AttrCtx_{entityName}.txt")); string expectedText = File.ReadAllText(expectedStringFilePath); Assert.AreEqual(expectedText, actualText); } }
/// <summary> /// A function to validate if the attribute context tree & traits generated for a resolved entity is the same as the expected and saved attribute context tree & traits for a test case /// </summary> /// <param name="corpus"></param> /// <param name="expectedOutputPath"></param> /// <param name="entityName"></param> /// <param name="resolvedEntity"></param> public static void ValidateAttributeContext(CdmCorpusDefinition corpus, string expectedOutputPath, string entityName, CdmEntityDefinition resolvedEntity) { if (resolvedEntity.AttributeContext != null) { AttributeContextUtil attrCtxUtil = new AttributeContextUtil(); // Expected string expectedStringFilePath = Path.GetFullPath(Path.Combine(expectedOutputPath, $"AttrCtx_{entityName}.txt")); string expectedText = File.ReadAllText(expectedStringFilePath); // Actual string actualStringFilePath = Path.GetFullPath(Path.Combine(expectedOutputPath, "..", "ActualOutput", $"AttrCtx_{entityName}.txt")); // Save Actual AttrCtx_*.txt and Resolved_*.cdm.json string actualText = attrCtxUtil.GetAttributeContextStrings(resolvedEntity, resolvedEntity.AttributeContext); File.WriteAllText(actualStringFilePath, actualText); resolvedEntity.InDocument.SaveAsAsync($"Resolved_{entityName}.cdm.json", saveReferenced: false).GetAwaiter().GetResult(); // Test if Actual is Equal to Expected Assert.AreEqual(expectedText.Replace("\r\n", "\n"), actualText.Replace("\r\n", "\n")); } }