예제 #1
0
        public void InstanceGeneratesAppropriateAdmTextWithDefault()
        {
            List <AdmDropDownListItem> items = new List <AdmDropDownListItem>();

            items.Add(new AdmDropDownListItem("key1", "value1"));
            items.Add(new AdmDropDownListItem("key2", "value2"));

            AdmDropDownListPart part = new AdmDropDownListPart("name", "key", "value", items, "key1");

            StringWriter writer = new StringWriter();

            part.Write(writer);

            StringReader contentsReader = new StringReader(writer.ToString());

            Assert.AreEqual(string.Format(AdmDropDownListPart.PartStartTemplate, "name"), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.DropDownListTemplate), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.ValueNameTemplate, "value"), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.KeyNameTemplate, "key"), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.ItemListStartTemplate), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.DefaultListItemTemplate, "key1", "value1"), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.ListItemTemplate, "key2", "value2"), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.ItemListEndTemplate), contentsReader.ReadLine());
            Assert.AreEqual(string.Format(AdmDropDownListPart.PartEndTemplate), contentsReader.ReadLine());
            Assert.IsNull(contentsReader.ReadLine());
        }
예제 #2
0
        public void AdmDropDownListPartWriteWithNullWriterThrows()
        {
            AdmDropDownListPart part = new AdmDropDownListPart("name", "key", "value", new List <AdmDropDownListItem>(), null);

            part.Write(null);
        }