Я использую клиент .NET SDK (версия 16.156.0-preview доступна в NuGet), но я ищу, как мне получить шаги тестового примера, которые содержат общие шаги.Поле parameterizedString
, по-видимому, содержит все шаги теста, но когда оно содержит общие шаги, содержимое XML неясно.
Пример кода, который я использую для получения всех шагов теста для тестового примера:
private void ReadTestCaseSteps(Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.TestCase testCase)
{
foreach (var field in testCase.workItem.WorkItemFields.OfType<JObject>())
{
var stepsContent = ((JValue)((JContainer)field.First).First).Value.ToString();
using (TextReader stepsReader = new StringReader(stepsContent))
{
var serializer = new XmlSerializer(typeof(steps));
var steps = (steps)serializer.Deserialize(stepsReader);
}
}
}
Класс "steps" представляет собой XML-описание этого примера:
// NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class steps
{
private stepsStep stepField;
private stepsCompref comprefField;
private byte idField;
private byte lastField;
/// <remarks/>
public stepsStep step
{
get
{
return this.stepField;
}
set
{
this.stepField = value;
}
}
/// <remarks/>
public stepsCompref compref
{
get
{
return this.comprefField;
}
set
{
this.comprefField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte last
{
get
{
return this.lastField;
}
set
{
this.lastField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsStep
{
private stepsStepParameterizedString[] parameterizedStringField;
private object descriptionField;
private byte idField;
private string typeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("parameterizedString")]
public stepsStepParameterizedString[] parameterizedString
{
get
{
return this.parameterizedStringField;
}
set
{
this.parameterizedStringField = value;
}
}
/// <remarks/>
public object description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsStepParameterizedString
{
private bool isformattedField;
private string valueField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool isformatted
{
get
{
return this.isformattedField;
}
set
{
this.isformattedField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsCompref
{
private stepsComprefStep[] stepField;
private stepsComprefCompref comprefField;
private byte idField;
private ushort refField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("step")]
public stepsComprefStep[] step
{
get
{
return this.stepField;
}
set
{
this.stepField = value;
}
}
/// <remarks/>
public stepsComprefCompref compref
{
get
{
return this.comprefField;
}
set
{
this.comprefField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public ushort @ref
{
get
{
return this.refField;
}
set
{
this.refField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsComprefStep
{
private stepsComprefStepParameterizedString[] parameterizedStringField;
private object descriptionField;
private byte idField;
private string typeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("parameterizedString")]
public stepsComprefStepParameterizedString[] parameterizedString
{
get
{
return this.parameterizedStringField;
}
set
{
this.parameterizedStringField = value;
}
}
/// <remarks/>
public object description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsComprefStepParameterizedString
{
private bool isformattedField;
private string valueField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool isformatted
{
get
{
return this.isformattedField;
}
set
{
this.isformattedField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsComprefCompref
{
private stepsComprefComprefStep[] stepField;
private byte idField;
private ushort refField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("step")]
public stepsComprefComprefStep[] step
{
get
{
return this.stepField;
}
set
{
this.stepField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public ushort @ref
{
get
{
return this.refField;
}
set
{
this.refField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsComprefComprefStep
{
private stepsComprefComprefStepParameterizedString[] parameterizedStringField;
private object descriptionField;
private byte idField;
private string typeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("parameterizedString")]
public stepsComprefComprefStepParameterizedString[] parameterizedString
{
get
{
return this.parameterizedStringField;
}
set
{
this.parameterizedStringField = value;
}
}
/// <remarks/>
public object description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public byte id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class stepsComprefComprefStepParameterizedString
{
private bool isformattedField;
private string valueField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool isformatted
{
get
{
return this.isformattedField;
}
set
{
this.isformattedField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}
}
XML, описывающий шаги с общими шагами, может выглядеть следующим образом:
<steps id="0" last="14">
<step id="2" type="ValidateStep">
<parameterizedString isformatted="true"><DIV><DIV><P>Step 1</P></DIV></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P>Result 1</P></DIV></parameterizedString>
<description/>
</step>
<compref id="6" ref="8712">
<step id="5" type="ActionStep">
<parameterizedString isformatted="true"><DIV><P>Step 4</P></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P><BR/></P></DIV></parameterizedString>
<description/>
</step>
<step id="7" type="ActionStep">
<parameterizedString isformatted="true"><DIV><P>Step 5</P></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P><BR/></P></DIV></parameterizedString>
<description/>
</step>
<compref id="14" ref="8713">
<step id="10" type="ActionStep">
<parameterizedString isformatted="true"><DIV><DIV><P>Step 8</P></DIV></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P><BR/></P></DIV></parameterizedString>
<description/>
</step>
<step id="11" type="ActionStep">
<parameterizedString isformatted="true"><DIV><DIV><P>Step 9</P></DIV></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P><BR/></P></DIV></parameterizedString>
<description/>
</step>
<step id="12" type="ActionStep">
<parameterizedString isformatted="true"><DIV><DIV><P>Step 10</P></DIV></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P><BR/></P></DIV></parameterizedString>
<description/>
</step>
<step id="13" type="ActionStep">
<parameterizedString isformatted="true"><DIV><DIV><P><BR/></P></DIV></DIV></parameterizedString>
<parameterizedString isformatted="true"><DIV><P><BR/></P></DIV></parameterizedString>
<description/>
</step>
</compref>
</compref>
</steps>
Поэтому я не понимаю, как я могу читать и управлять шагами тестового примера с помощью общих шагов с API для преобразования этого содержимого в список подробных шагов (описание, ожидаемый результат).
Не могли бы вы мне посоветовать?