コード例 #1
0
        public void SequenceInfoNode_GetAttribute_Works()
        {
            // setup
            var sequenceInfo = new SequenceInfo();

            sequenceInfo.AllowedAttributes.Should().HaveCount(3);
            sequenceInfo.Attributes.Should().BeEmpty();

            sequenceInfo
            .AddAttributes(
                new Fb2Attribute(AttributeNames.Name, "Test Sequence"),
                new Fb2Attribute(AttributeNames.Number, "1"))
            .AddAttribute(() => new Fb2Attribute(AttributeNames.Language, "eng"));

            sequenceInfo.Attributes.Should().HaveCount(3);

            // query

            //sequenceInfo.GetAttribute(AttributeNames.Name)
            //    .Should()
            //    .Be(new KeyValuePair<string, string>(AttributeNames.Name, "Test Sequence"));

            var expectedAttr = new Fb2Attribute(AttributeNames.Name, "Test Sequence");

            sequenceInfo.GetAttribute(AttributeNames.Name)
            .Should()
            .Be(new Fb2Attribute(AttributeNames.Name, "Test Sequence"));
            //sequenceInfo.GetAttribute(AttributeNames.Number)
            //    .Should()
            //    .Be(new KeyValuePair<string, string>(AttributeNames.Number, "1"));
            sequenceInfo.GetAttribute(AttributeNames.Number)
            .Should()
            .Be(new Fb2Attribute(AttributeNames.Number, "1"));

            //sequenceInfo.GetAttribute(AttributeNames.Language)
            //    .Should()
            //    .Be(new KeyValuePair<string, string>(AttributeNames.Language, "eng"));
            sequenceInfo.GetAttribute(AttributeNames.Language)
            .Should()
            .Be(new Fb2Attribute(AttributeNames.Language, "eng"));

            //sequenceInfo.GetAttribute("NaMe").Should().Be(default(KeyValuePair<string, string>));
            //sequenceInfo.GetAttribute("NuMbEr").Should().Be(default(KeyValuePair<string, string>));
            //sequenceInfo.GetAttribute("LaNg").Should().Be(default(KeyValuePair<string, string>));

            sequenceInfo.GetAttribute("NaMe").Should().Be(null);
            sequenceInfo.GetAttribute("NuMbEr").Should().Be(null);
            sequenceInfo.GetAttribute("LaNg").Should().Be(null);

            sequenceInfo.GetAttribute("NaMe", true)
            .Should()
            .Be(new Fb2Attribute(AttributeNames.Name, "Test Sequence"));
            sequenceInfo.GetAttribute("NuMbEr", true)
            .Should()
            .Be(new Fb2Attribute(AttributeNames.Number, "1"));
            sequenceInfo.GetAttribute("LaNg", true)
            .Should()
            .Be(new Fb2Attribute(AttributeNames.Language, "eng"));

            //sequenceInfo.GetAttribute("NaMe", true)
            //    .Should()
            //    .Be(new KeyValuePair<string, string>(AttributeNames.Name, "Test Sequence"));
            //sequenceInfo.GetAttribute("NuMbEr", true)
            //    .Should()
            //    .Be(new KeyValuePair<string, string>(AttributeNames.Number, "1"));
            //sequenceInfo.GetAttribute("LaNg", true)
            //    .Should()
            //    .Be(new KeyValuePair<string, string>(AttributeNames.Language, "eng"));
        }