예제 #1
0
    public void BasicTest()
    {
        var options = new ImmutableOptionSet();

        options = options.PassThroughAllSerializers();
        options.Items.Count.Should().Be(0);

        options = options.Set("A");
        options = options.PassThroughAllSerializers();
        options.Get <string>().Should().Be("A");
        options.GetRequiredService <string>().Should().Be("A");
        options.Items.Count.Should().Be(1);

        options = options.Set("B");
        options = options.PassThroughAllSerializers();
        options.Get <string>().Should().Be("B");
        options.GetRequiredService <string>().Should().Be("B");
        options.Items.Count.Should().Be(1);

        options = options.Remove <string>();
        options = options.PassThroughAllSerializers();
        options.GetOrDefault <string>("").Should().Be("");
        options.Get <string>().Should().BeNull();
        options.GetService <string>().Should().Be(null);
        options.Items.Count.Should().Be(0);

        options = options.Set("C");
        options = ImmutableOptionSet.Empty;
        options.Items.Count.Should().Be(0);
    }
        public void BasicTest()
        {
            var options = new ImmutableOptionSet();

            options = options.PassThroughAllSerializers();
            options.Items.Count.Should().Be(0);

            options = options.Set("A");
            options = options.PassThroughAllSerializers();
            options.Get <string>().Should().Be("A");
            options.GetRequiredService <string>().Should().Be("A");
            options.Items.Count.Should().Be(1);

            options = options.Set("B");
            options = options.PassThroughAllSerializers();
            options.Get <string>().Should().Be("B");
            options.GetRequiredService <string>().Should().Be("B");
            options.Items.Count.Should().Be(1);

            options = options.Remove <string>();
            options = options.PassThroughAllSerializers();
            options.TryGet <string>().Should().Be(null);
            Assert.Throws <KeyNotFoundException>(() => {
                options.Get <string>();
            });
            options.GetService <string>().Should().Be(null);
            options.Items.Count.Should().Be(0);

            options = options.Set("C");
            options = ImmutableOptionSet.Empty;
            options.Items.Count.Should().Be(0);
        }
예제 #3
0
        public void ImmutableOptionSetSerialization()
        {
            default(ImmutableOptionSet).AssertPassesThroughAllSerializers(Out);
            var s = new ImmutableOptionSet();

            s = s.Set(3);
            s = s.Set("X");
            s = s.Set((1, "X"));
            var s1 = s.PassThroughAllSerializers(Out);

            s1.Items.Should().BeEquivalentTo(s.Items);
        }
예제 #4
0
 public PluginInfo(TypeRef type,
                   ImmutableArray <TypeRef> ancestors,
                   ImmutableArray <TypeRef> interfaces,
                   ImmutableHashSet <TypeRef> castableTo,
                   ImmutableOptionSet capabilities,
                   ImmutableHashSet <TypeRef> dependencies,
                   ImmutableHashSet <TypeRef> allDependencies,
                   int orderByDependencyIndex)
 {
     Type                   = type;
     Ancestors              = ancestors;
     Interfaces             = interfaces;
     CastableTo             = castableTo;
     Capabilities           = capabilities;
     Dependencies           = dependencies;
     AllDependencies        = allDependencies;
     OrderByDependencyIndex = orderByDependencyIndex;
 }