public void CanAddManyPartsInStartedPolicy() { AdmContentBuilder builder = new AdmContentBuilder(); builder.StartCategory("category"); builder.StartPolicy("policy", "key"); builder.AddPart(new AdmTextPart("text1")); builder.AddPart(new AdmTextPart("text2")); builder.EndPolicy(); builder.EndCategory(); AdmContent content = builder.GetContent(); Assert.IsNotNull(content); IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator(); Assert.IsTrue(categoriesEnumerator.MoveNext()); Assert.AreEqual("category", categoriesEnumerator.Current.Name); IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator(); Assert.IsTrue(policiesEnumerator.MoveNext()); IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator(); Assert.IsTrue(partsEnumerator.MoveNext()); Assert.AreSame(typeof(AdmTextPart), partsEnumerator.Current.GetType()); Assert.AreEqual("text1", ((AdmTextPart)partsEnumerator.Current).PartName); Assert.IsTrue(partsEnumerator.MoveNext()); Assert.AreSame(typeof(AdmTextPart), partsEnumerator.Current.GetType()); Assert.AreEqual("text2", ((AdmTextPart)partsEnumerator.Current).PartName); Assert.IsFalse(partsEnumerator.MoveNext()); Assert.IsFalse(policiesEnumerator.MoveNext()); Assert.IsFalse(categoriesEnumerator.MoveNext()); }
public void AddPartWithoutStartedPolicyThrows() { AdmContentBuilder builder = new AdmContentBuilder(); builder.AddPart(new AdmTextPart("text")); }