/// <summary> /// Create variation records /// </summary> /// <param name="products"></param> /// <param name="recList"></param> private void CreateVariations(Product[] products, ref List <IRecord> recList, ref List <ulong> indexList) { //for each product... for (int x = 0; x < products.Length; x++) { //if the list is null skip iteration if (products[x].variations == null) { continue; } //for each variation in said product... for (int y = 0; y < products[x].variations.Length; y++) { //if the list is null skip iteration if (products[x].variations[y].attributes == null) { continue; } //for each variation in said product... for (int z = 0; z < products[x].variations[y].attributes.Length; z++) { //variation record VariationRecord varRec = new VariationRecord(indexList[x], products[x].variations[y].asin, products[x].variations[y].attributes[z].dimension, products[x].variations[y].attributes[z].value); //add variation record recList.Add(varRec); } } } }
public override void EndVariation(string variationName) { currentVariation.Log = variationLogBuilder.ToString(); variationLogBuilder.Length = 0; currentVariation.EndTime = new InfraTime(DateTime.Now); currentVariation = null; }
internal static TimeSpan GetVariationDuration(VariationRecord variation) { if (variation.EndTime != null && variation.StartTime != null) { return(variation.EndTime.DateTime - variation.StartTime.DateTime); } return(TimeSpan.MinValue); }
public override void BeginVariation(string variationName) { currentVariation = new VariationRecord(); currentVariation.StartTime = new InfraTime(DateTime.Now); currentVariation.VariationId = currentTest.Variations.Count + 1; currentTest.Variations.Add(currentVariation); currentVariation.VariationName = variationName; variationLogBuilder.Length = 0; }
private static void WriteVariationNode(XmlTableWriter tableWriter, VariationRecord variation, string variationLogPath) { bool logTruncated = false; tableWriter.WriteStartElement("Variation"); tableWriter.WriteAttributeString("Variation", variation.VariationName); tableWriter.WriteAttributeString("VariationId", variation.VariationId.ToString(CultureInfo.InvariantCulture)); tableWriter.WriteAttributeString("Duration", ReportingUtilities.FormatTimeSpanAsSeconds(ReportingUtilities.GetVariationDuration(variation))); tableWriter.WriteAttributeString("Result", variation.Result.ToString()); tableWriter.WriteAttributeString("Log", ReportingUtilities.ProcessLongLog(variation.Log, variationLogPath, ref logTruncated)); if (logTruncated) { tableWriter.WriteAttributeString("LogPath", Path.Combine(ReportingUtilities.TestLogsDir, Path.GetFileName(variationLogPath))); } tableWriter.WriteAttributeString("LogDir", ReportingUtilities.ReportPaths(variation.LoggedFiles)); tableWriter.WriteEndElement(); }
/// <summary> /// Write one test. /// </summary> /// <param name="tableWriter">Writer</param> /// <param name="areaReportsPath">Area path</param> /// <param name="area">Area name</param> /// <param name="test">TestRecord</param> /// <param name="testIndex">Index of the test</param> private static void WriteTestNode(XmlTableWriter tableWriter, string areaReportsPath, string area, TestRecord test, int testIndex) { TestInfo testInfo = test.TestInfo; string testLogsDirectory = Path.Combine(areaReportsPath, ReportingUtilities.TestLogsDir); string testInfosDirectory = Path.Combine(areaReportsPath, ReportingUtilities.TestInfosDir); //Test Layer with attribute needed for all variation. tableWriter.WriteStartElement("Test"); tableWriter.WriteAttributeString("Name", Escape(testInfo.Name)); tableWriter.WriteAttributeString("KnownBugs", test.TestInfo.Bugs.ToCommaSeparatedList()); tableWriter.WriteAttributeString("Priority", test.TestInfo.Priority.ToString()); tableWriter.WriteAttributeString("Machine", ReportingUtilities.ReportMachine(test.Machine)); string testInfoPath = Path.Combine(testInfosDirectory, String.Format("{0}_{1}.xml", area, testIndex)); if (ReportingUtilities.InterpretTestOutcome(test) == Result.Fail) { ReportingUtilities.SaveTestInfo(testInfoPath, testInfo); tableWriter.WriteAttributeString("TestInfo", Path.Combine(ReportingUtilities.TestInfosDir, Path.GetFileName(testInfoPath))); } for (int variationIndex = 0; variationIndex < test.Variations.Count; variationIndex++) { VariationRecord variation = test.Variations[variationIndex]; string variationLogPath = Path.Combine(testLogsDirectory, String.Format("{0}_{1}_{2}.log", area, testIndex, variationIndex)); WriteVariationNode(tableWriter, variation, variationLogPath); } //SEMI HACK: Create a node to hold information for test, that are not needed for most variation. // This solves three problems: // 1 - Allows us to provide Test level information in tabular form // 2 - Allows us to include Test level execution logs in these reports // Note - To nest these things attribute in parent Test node, while less hacky, would create a different semantic from the perspective of any XML viewer, which would be bad. very bad. string testLogPath = Path.Combine(testLogsDirectory, String.Format("{0}_{1}.log", area, testIndex)); WriteChildTestNode(tableWriter, test, testInfo, testLogPath); tableWriter.WriteEndElement(); }