示例#1
0
 public void SET_TestNullReferenceListProperty()
 {
     _subject.StringEnumerable = null;
     try
     {
         _reflection["StringList.1"] = "first";
     }
     catch (ReflectionException Re)
     {
         ReflectionException test = ReflectionException.NoSourceAvailable("1");
         Assert.That(Re.Message, Is.EqualTo(test.Message));
     }
 }
示例#2
0
 public void SET_TestNullReferenceDictionaryProperty()
 {
     _subject.StringDictionary = null;
     try
     {
         _reflection["StringDictionary.a"] = "first";
     }
     catch (ReflectionException Re)
     {
         Console.WriteLine(Re.Message);
         ReflectionException test = ReflectionException.NoSourceAvailable("a");
         Assert.That(Re.Message, Is.EqualTo(test.Message));
     }
 }
示例#3
0
 public void SET_TestNoSourceProvidedNested()
 {
     try
     {
         _reflection = new Reflection(_subject);
         _reflection["Nested.SimpleString"] = "a";
         Assert.Fail("Expected an exception");
     }
     catch (ReflectionException Re)
     {
         ReflectionException test = ReflectionException.NoSourceAvailable("SimpleString");
         Assert.That(Re.Message, Is.EqualTo(test.Message));
     }
 }
示例#4
0
        public void NonExistingNestedResolveTest()
        {
            var model = new TagModel(new Reflection(new Hashtable()));

            model.Model["a"] = new Hashtable();
            model.Page["a"]  = new Hashtable();

            try
            {
                object o = model["a.b"];
            }
            catch (ReflectionException Re)
            {
                Assert.That(Re.Message, Is.EqualTo(ReflectionException.NoSourceAvailable("b").Message));
            }
        }
示例#5
0
        public void NonExistingNestedResolve_Prefers_Deepest_Nesting_Second_One_Deepested_Nesting()
        {
            var model = new TagModel(new Reflection(new Hashtable()));

            model.Model["a"] = new Hashtable();
            model.Page["a"]  = new Hashtable {
                { "b", new Hashtable() }
            };
            try
            {
                object o = model["a.b.c"];
            }
            catch (ReflectionException Re)
            {
                Assert.That(Re.Message, Is.EqualTo(ReflectionException.NoSourceAvailable("c").Message));
            }
        }
示例#6
0
        public void TestSetNestedNonExistingDictionaryKey()
        {
            _subject.ComplexDictionary = new Dictionary <string, TestSubject>();
            _subject.ComplexDictionary.Add("a", new TestSubject());
            _subject.ComplexDictionary.Add("b", new TestSubject());
            _subject.ComplexDictionary.Add("c", new TestSubject());
            _subject.ComplexDictionary["a"].SimpleString = "first";
            _subject.ComplexDictionary["b"].SimpleString = "second";
            _subject.ComplexDictionary["c"].SimpleString = "third";

            try
            {
                _reflection["ComplexDictionary.e.SimpleString"] = null;
                Assert.Fail("Expected exception");
            }
            catch (ReflectionException Re)
            {
                Assert.AreEqual(Re.Message, ReflectionException.NoSourceAvailable("SimpleString").Message);
            }
        }