Beispiel #1
0
        public async Task CanHandleNulllListTypes()
        {
            var mock1 = new MockModel1
            {
                Id = "a1",
            };

            await _modelTransformerProvider.TransformAsync(new ModelTransformArguments
            {
                Action = MutationActions.BatchCreate,
                Models = new List <object> {
                    mock1
                }
            });

            _modelTransformer.List1.Count.ShouldBe(1);
            _modelTransformer.List1.SingleOrDefault(x => x.Id == "a1").ShouldNotBeNull();
        }
Beispiel #2
0
        public async Task CanHandleNestedListTypes()
        {
            var mock1 = new MockModel1
            {
                Id         = "a1",
                Model2List = new List <MockModel2>
                {
                    new MockModel2
                    {
                        Id         = "b1a",
                        Model3List = new List <MockModel3>
                        {
                            new MockModel3
                            {
                                Id    = "c1a",
                                Value = "c1a"
                            }
                        },
                        SomeMock = new MockModel4
                        {
                            Id    = "d1a",
                            Value = "d1a"
                        }
                    },
                    new MockModel2
                    {
                        Id         = "b1b",
                        Model3List = new List <MockModel3>
                        {
                            new MockModel3
                            {
                                Id    = "c1b",
                                Value = "c1b"
                            }
                        },
                        SomeMock = new MockModel4
                        {
                            Id    = "d1b",
                            Value = "d1b"
                        }
                    }
                }
            };

            var mock2 = new MockModel1
            {
                Id         = "a2",
                Model2List = new List <MockModel2>
                {
                    new MockModel2
                    {
                        Id         = "b2",
                        Model3List = new List <MockModel3>
                        {
                            new MockModel3
                            {
                                Id    = "c2",
                                Value = "c2"
                            }
                        }
                    }
                }
            };

            await _modelTransformerProvider.TransformAsync(new ModelTransformArguments
            {
                Action = MutationActions.BatchCreate,
                Models = new List <object> {
                    mock1, mock2
                }
            });

            _modelTransformer.List1.Count.ShouldBe(2);
            _modelTransformer.List1.SingleOrDefault(x => x.Id == "a1").ShouldNotBeNull();
            _modelTransformer.List1.SingleOrDefault(x => x.Id == "a2").ShouldNotBeNull();

            _modelTransformer.List2.Count.ShouldBe(3);
            _modelTransformer.List2.SingleOrDefault(x => x.Id == "b1a").ShouldNotBeNull();
            _modelTransformer.List2.SingleOrDefault(x => x.Id == "b1b").ShouldNotBeNull();
            _modelTransformer.List2.SingleOrDefault(x => x.Id == "b2").ShouldNotBeNull();

            _modelTransformer.List3.Count.ShouldBe(3);
            _modelTransformer.List3.SingleOrDefault(x => x.Id == "c1a").ShouldNotBeNull();
            _modelTransformer.List3.SingleOrDefault(x => x.Id == "c1b").ShouldNotBeNull();
            _modelTransformer.List3.SingleOrDefault(x => x.Id == "c2").ShouldNotBeNull();

            _modelTransformer.List4.Count.ShouldBe(2);
            _modelTransformer.List4.SingleOrDefault(x => x.Id == "d1a").ShouldNotBeNull();
            _modelTransformer.List4.SingleOrDefault(x => x.Id == "d1b").ShouldNotBeNull();
        }