public async Task WrapperAroundArray() { var wrapper = new AugmenterWrapper <TestModelForWrapping>(new[] { new TestModelForWrapping() { Id = 42, Model = new TestModel1() }, new TestModelForWrapping() { Id = 43, Model = new TestModel1() } }); wrapper.SetTypeConfiguration(c => { c.Add("Foo", (x, state) => $"{x.Id}-foo"); }); var model = new { Models = wrapper }; var result = await _fixture.AugmentAsync(model) as AObject; result["Models"].GetType().Should().Be(typeof(AArray)); var list = result["Models"] as AArray; list.Should().HaveCount(2); list[0].Cast <AObject>()["Foo"].Cast <string>().Should().Be("42-foo"); list[1].Cast <AObject>()["Foo"].Cast <string>().Should().Be("43-foo"); }
public async Task WrapperAroundArray_Direct() { var wrapper = new AugmenterWrapper <TestModelForWrapping>(new[] { new TestModelForWrapping() { Id = 42, Model = new TestModel1() }, new TestModelForWrapping() { Id = 43, Model = new TestModel1() } }); wrapper.SetTypeConfiguration(c => { c.Add("Foo", (x, state) => $"{x.Id}-foo"); }); var result = await _fixture.AugmentAsync(wrapper) as AArray; result.Should().NotBeNull().And.Subject.Should().HaveCount(2); result[0].Cast <AObject>()["Foo"].Cast <string>().Should().Be("42-foo"); result[1].Cast <AObject>()["Foo"].Cast <string>().Should().Be("43-foo"); }
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); }