protected override XElement CreateTestTypeXml(MethodInfo testMethod) { MChessOptions mchessOpts = new MChessOptions(); if (_MaxSchedules.HasValue) { mchessOpts.MaxExecs = MaxSchedules; } if (_MaxRunTime.HasValue) { mchessOpts.MaxChessTime = MaxRunTime; } if (_MaxPreemptions.HasValue) { mchessOpts.MaxPreemptions = MaxPreemptions; } if (_PreemptAllAccesses.HasValue) { mchessOpts.PreemptAllAccesses = PreemptAllAccesses; } var xopts = mchessOpts.ToXElement(); return(new XElement(XNames.ScheduleTest , xopts.HasAttributes || xopts.HasElements ? xopts : null )); }
protected override XElement CreateXTestCase() { XElement xtestCase = base.CreateXTestCase(); // Add the MChessOptions if (MChessOptions != null) { var xopts = MChessOptions.ToXElement(); if (xopts.HasAttributes || xopts.HasElements) { xtestCase.Add(xopts); } } return(xtestCase); }
protected override void UpdateXTestCaseFromPreviousRun(XElement xtestCase) { base.UpdateXTestCaseFromPreviousRun(xtestCase); // The MChessOptions has already been merged from the prev run in SetupMChessOptions() // Just remove the old options element so it can be replaced with the new settings var oldxopts = xtestCase.Element(XChessNames.MChessOptions); if (oldxopts != null) { oldxopts.Remove(); } // Add the new settings if (MChessOptions != null) { var xopts = MChessOptions.ToXElement(); if (xopts.HasAttributes || xopts.HasElements) { xtestCase.Add(xopts); } } }
internal static XElement TestContextToXElement(ChessTestContext chessCtx) { XElement xctx = new XElement(XNames.ChessContext , XmlUtil.CreateAttributeIfNotNull(XNames.AName, chessCtx.Name) , XmlUtil.CreateAttributeIfNotNull(XNames.AExpectedResultKey, chessCtx.ExpectedResultKey) , XmlUtil.CreateAttributeIfNotNull(XNames.AExpectedChessResultKey, chessCtx.ExpectedChessResultKey) ); if (!String.IsNullOrWhiteSpace(chessCtx.PreRunScript)) { xctx.Add(new XElement(XNames.MChessPreRunScript, chessCtx.PreRunScript)); } // Add mchess options MChessOptions opts = chessCtx.Options; XElement xopts = opts.ToXElement(); if (xopts.HasAttributes) { // Add the serialized options, keeping the same attribute names foreach (var attr in xopts.Attributes()) { xctx.Add(new XAttribute(attr)); } } if (xopts.HasElements) { // Add the serialized options, keeping the same element names and namespaces foreach (var el in xopts.Elements()) { xctx.Add(new XElement(el)); } } return(xctx); }