Exemple #1
0
        public void TestCast()
        {
            dynamic test = new SimpleResultSet(new[] { "Hello", "World" });
            IEnumerable <string> strings = test.Cast <string>();

            Assert.AreEqual(2, strings.Count());
        }
 public void TestCastWithClass()
 {
     var dict = new Dictionary<string, object> {{"Name", "Bob"}};
     dynamic test = new SimpleResultSet(new[] {new SimpleRecord(dict)});
     IEnumerable<Foo> foos = test.Cast<Foo>();
     Assert.AreEqual(1, foos.Count());
 }
Exemple #3
0
        public void CastToGenericCreatesTypedList()
        {
            dynamic list = new SimpleResultSet(Records(1));
            IEnumerable <TestType> converted = list.Cast <TestType>();

            Assert.IsNotNull(converted);
            Assert.AreEqual(1, converted.Count());
            Assert.AreEqual("0", converted.First().Data);
        }
Exemple #4
0
        public void TestCastWithClass()
        {
            var dict = new Dictionary <string, object>(HomogenizedEqualityComparer.DefaultInstance)
            {
                { "Name", "Bob" }
            };
            dynamic           test = new SimpleResultSet(new[] { new SimpleRecord(dict) });
            IEnumerable <Foo> foos = test.Cast <Foo>();

            Assert.AreEqual(1, foos.Count());
        }
Exemple #5
0
        public void CastToGenericCreatesTypedListWithSubTypes()
        {
            var firstRecord = new SimpleRecord(new Dictionary <string, object>
            {
                { "Data", "First" },
                { "List", new List <string> {
                      "First-One", "First-Two"
                  } }
            });

            var list = new SimpleResultSet(new List <dynamic> {
                firstRecord
            });

            var result = list.Cast <TestType2>().First();

            Assert.AreEqual(2, result.List.Count);
        }
        public void CastToGenericCreatesTypedList()
        {
            dynamic list = new SimpleResultSet(Records(1));
            IEnumerable<TestType> converted = list.Cast<TestType>();

            Assert.IsNotNull(converted);
            Assert.AreEqual(1, converted.Count());
            Assert.AreEqual("0", converted.First().Data);
        }
 public void TestCast()
 {
     dynamic test = new SimpleResultSet(new[] {"Hello", "World"});
     IEnumerable<string> strings = test.Cast<string>();
     Assert.AreEqual(2, strings.Count());
 }
        public void CastToGenericCreatesTypedListWithSubTypes()
        {
            var firstRecord = new SimpleRecord(new Dictionary<string, object>
            {
                { "Data", "First" },
                { "List", new List<string> { "First-One", "First-Two" } }
            });

            var list = new SimpleResultSet(new List<dynamic> { firstRecord });

            var result = list.Cast<TestType2>().First();

            Assert.AreEqual(2, result.List.Count);
        }