Exemplo n.º 1
0
        public void Should_be_able_to_reconfigure_using_anonymous_type()
        {
            var item = new
            {
                MyInt    = 42,
                MyString = "Foo"
            };

            var structure = UnitUnderTest.CreateStructure(item);

            structure.Name.Should().Contain("Anonymous");
            structure.Indexes.Should().HaveCount(2);
            structure.Indexes.Should()
            .Contain(i => i.Name == nameof(item.MyInt))
            .Which.Value.Should().Be(item.MyInt);
            structure.Indexes.Should()
            .Contain(i => i.Name == nameof(item.MyString))
            .Which.Value.Should().Be(item.MyString);

            UnitUnderTest.ConfigureUsingTemplate(item, cfg => cfg.Members(i => i.MyInt).UsingIndexMode(IndexMode.Inclusive));

            structure = UnitUnderTest.CreateStructure(item);
            structure.Name.Should().Contain("Anonymous");
            structure.Indexes.Should().HaveCount(1);
            structure.Indexes.Should()
            .Contain(i => i.Name == nameof(item.MyInt))
            .Which.Value.Should().Be(item.MyInt);
        }