Example #1
0
            public async Task Basic()
            {
                var model = new TestModelWithNested();

                var result = await _fixture.AugmentAsync(model) as AObject;

                result["Foo"].Cast <string>().Should().Be("42");
                var nested = result["Nested"].Cast <AObject>();

                nested["Foo"].Cast <string>().Should().Be("43");
                var nestedNested = nested["Nested"].Cast <AObject>();

                nestedNested["Foo"].Cast <string>().Should().Be("44");
            }
Example #2
0
        public void ConfigureNested_AddState()
        {
            var tc = new TypeConfiguration <TestModelWithNested>();

            tc.ConfigureNested(x => x.Nested, ntc =>
            {
                ntc.SetAddState((x, s1, s2) =>
                {
                    s2["ParentId"] = x.Id;
                });
            });

            var nested = tc.NestedConfigurations.Value.First();
            var state1 = new State();
            var state2 = new State();
            var model  = new TestModelWithNested();

            nested.Value.AddState(model, state1, state2);

            state2["ParentId"].Should().Be(model.Id);
        }
Example #3
0
            public async Task Nested()
            {
                var model = new TestModelWithNested();

                _configuration = new AugmenterConfiguration();
                _configuration.Configure <TestModelNested>(c =>
                {
                    c.Add("Foo", (x, state) =>
                    {
                        return(state["key"]);
                    });
                });
                _configuration.Build();
                _fixture = MocksHelper.Augmenter(_configuration);

                var result = await _fixture.AugmentAsync(model, addState : state =>
                {
                    state.Add("key", "foo");
                }) as AObject;

                result["Nested"].Cast <AObject>()["Foo"].Cast <string>().Should().Be("foo");
            }