Esempio n. 1
0
            public async Task Null_ReturnsNull()
            {
                var    fixture = MocksHelper.AugmenterBase(CreateBuiltConfiguration());
                object model   = null;

                var result = await fixture.AugmentAsync(model);

                result.Should().BeNull();
            }
Esempio n. 2
0
            public void AugmenterConfigurationNotBuild_Throw()
            {
                var configration = new AugmenterConfiguration();

                Assert.ThrowsAny <Exception>(() =>
                {
                    MocksHelper.AugmenterBase(configration);
                });
            }
Esempio n. 3
0
            public async Task State_FallsThrough()
            {
                var fixture   = MocksHelper.AugmenterBase(CreateCommonConfiguration());
                var model     = new TestModelC();
                var someValue = "bars";

                await fixture.AugmentAsync(model, addState : state =>
                {
                    state.Add("key", someValue);
                });

                fixture.Contexts.First().State["key"].Should().Be(someValue);
            }
Esempio n. 4
0
            public async Task AlwaysAugmentsIfUsingAWrapper()
            {
                var configuration = new AugmenterConfiguration();

                configuration.Build();
                var fixture = MocksHelper.AugmenterBase(configuration);
                var model   = new TestModel1();
                var wrapper = new AugmenterWrapper <TestModel1>(model);

                var result = await fixture.AugmentAsync(wrapper);

                fixture.Contexts.Should().HaveCount(1);
                fixture.Contexts.First().TypeConfiguration.Augments.Should().HaveCount(0);
                fixture.Contexts.First().TypeConfiguration.Properties.Should().HaveCount(3);
            }
Esempio n. 5
0
                public async Task SupportsArrays()
                {
                    var fixture = MocksHelper.AugmenterBase(CreateCommonConfiguration());
                    var arr     = new TestModelC[]
                    {
                        new TestModelC(),
                        new TestModelC()
                    };

                    await fixture.AugmentAsync(arr);

                    fixture.Contexts.Should().HaveCount(arr.Length);
                    var context = fixture.Contexts.First();

                    context.Type.Should().Be(typeof(TestModelC));
                    context.TypeConfiguration.Type.Should().Be(typeof(TestModelC));
                }
Esempio n. 6
0
                public async Task SupportsEnumerable()
                {
                    var fixture = MocksHelper.AugmenterBase(CreateCommonConfiguration());
                    var list    = new List <TestModelC>
                    {
                        new TestModelC(),
                        new TestModelC()
                    };

                    await fixture.AugmentAsync(list);

                    fixture.Contexts.Should().HaveCount(list.Count);
                    var context = fixture.Contexts.First();

                    context.Type.Should().Be(typeof(TestModelC));
                    context.TypeConfiguration.Type.Should().Be(typeof(TestModelC));
                }
Esempio n. 7
0
            public async Task AlwaysAugmentsIfConfigureIsProvided()
            {
                var configuration = new AugmenterConfiguration();

                configuration.Build();
                var fixture = MocksHelper.AugmenterBase(configuration);
                var model   = new TestModel1();

                var result = await fixture.AugmentAsync(model, c =>
                {
                    c.Add("Bar", (x, state) => "bar");
                });

                fixture.Contexts.Should().HaveCount(1);
                fixture.Contexts.First().EphemeralTypeConfiguration.Augments.Should().HaveCount(1);
                fixture.Contexts.First().TypeConfiguration.Properties.Should().HaveCount(3);
            }
Esempio n. 8
0
                public async Task PicksUpWrapperState()
                {
                    var fixture = MocksHelper.AugmenterBase(CreateCommonConfiguration());
                    var model   = new TestModel1();
                    var wrapper = new AugmenterWrapper <TestModel1>(model);

                    wrapper.SetAddState((x, s) =>
                    {
                        s["Baz"] = x.Id;
                    });

                    await fixture.AugmentAsync(wrapper);

                    fixture.Contexts.Should().HaveCount(1);
                    var context = fixture.Contexts.First();

                    context.State["Baz"].Cast <int>().Should().Be(model.Id);
                }
Esempio n. 9
0
                public async Task PicksUpWrapperConfiguration()
                {
                    var fixture = MocksHelper.AugmenterBase(CreateCommonConfiguration());
                    var model   = new TestModel1();
                    var wrapper = new AugmenterWrapper <TestModel1>(model);

                    wrapper.SetTypeConfiguration(c =>
                    {
                        c.Add("Baz", (x, state) => x.Id);
                    });

                    await fixture.AugmentAsync(wrapper);

                    fixture.Contexts.Should().HaveCount(1);
                    var context = fixture.Contexts.First();

                    context.Type.Should().Be(typeof(TestModel1));
                    context.TypeConfiguration.Type.Should().Be(typeof(TestModel1));
                    context.EphemeralTypeConfiguration.Type.Should().Be(typeof(TestModel1));
                    context.EphemeralTypeConfiguration.Augments.Should().HaveCount(1);
                }