コード例 #1
0
ファイル: CollectionTests.cs プロジェクト: kinimatt/dashing
        public void SingleCollectionAwkwardObjectWorks()
        {
            var funcFac = GenerateSingleAwkwardMapper();
            var post1   = new PostWithoutCollectionInitializerInConstructor {
                PostWithoutCollectionInitializerInConstructorId = 1
            };
            var post2 = new PostWithoutCollectionInitializerInConstructor {
                PostWithoutCollectionInitializerInConstructorId = 2
            };
            var comment1 = new CommentTwo {
                CommentTwoId = 1
            };
            var comment2 = new CommentTwo {
                CommentTwoId = 2
            };
            var comment3 = new CommentTwo {
                CommentTwoId = 3
            };
            PostWithoutCollectionInitializerInConstructor         currentRoot = null;
            IList <PostWithoutCollectionInitializerInConstructor> results     = new List <PostWithoutCollectionInitializerInConstructor>();
            var func = (Func <object[], PostWithoutCollectionInitializerInConstructor>)funcFac.DynamicInvoke(currentRoot, results);

            func(new object[] { post1, comment1 });
            func(new object[] { post1, comment2 });
            func(new object[] { post2, comment3 });
            Assert.Equal(1, results[0].Comments.First().CommentTwoId);
            Assert.Equal(2, results[0].Comments.Last().CommentTwoId);
            Assert.Equal(3, results[1].Comments.First().CommentTwoId);
        }
コード例 #2
0
ファイル: CollectionTests.cs プロジェクト: Polylytics/dashing
 public void SingleCollectionAwkwardObjectWorks() {
     var funcFac = GenerateSingleAwkwardMapper();
     var post1 = new PostWithoutCollectionInitializerInConstructor { PostWithoutCollectionInitializerInConstructorId = 1 };
     var post2 = new PostWithoutCollectionInitializerInConstructor { PostWithoutCollectionInitializerInConstructorId = 2 };
     var comment1 = new CommentTwo { CommentTwoId = 1 };
     var comment2 = new CommentTwo { CommentTwoId = 2 };
     var comment3 = new CommentTwo { CommentTwoId = 3 };
     PostWithoutCollectionInitializerInConstructor currentRoot = null;
     IList<PostWithoutCollectionInitializerInConstructor> results = new List<PostWithoutCollectionInitializerInConstructor>();
     var func = (Func<object[], PostWithoutCollectionInitializerInConstructor>)funcFac.DynamicInvoke(currentRoot, results);
     func(new object[] { post1, comment1 });
     func(new object[] { post1, comment2 });
     func(new object[] { post2, comment3 });
     Assert.Equal(1, results[0].Comments.First().CommentTwoId);
     Assert.Equal(2, results[0].Comments.Last().CommentTwoId);
     Assert.Equal(3, results[1].Comments.First().CommentTwoId);
 }