public void SpecifyOneValueInferTheOthers()
        {
            // arrange
            var descriptor = new EnumTypeDescriptor(Context, typeof(FooEnum));

            // act
            IEnumTypeDescriptor desc = descriptor;

            desc.Item(FooEnum.Bar1).Name("FOOBAR");

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Values,
                              t =>
            {
                Assert.Equal("FOOBAR", t.Name);
                Assert.Equal(FooEnum.Bar1, t.Value);
            },
                              t =>
            {
                Assert.Equal("BAR2", t.Name);
                Assert.Equal(FooEnum.Bar2, t.Value);
            });
        }
        public void AddDirectiveWithArgument()
        {
            // arrange
            var descriptor = new EnumTypeDescriptor(Context);

            // act
            IEnumTypeDescriptor desc = descriptor;

            desc.Directive("Bar",
                           new ArgumentNode("a", new StringValueNode("b")));

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Directives,
                              t =>
            {
                Assert.Equal("Bar", t.ParsedDirective.Name.Value);
                Assert.Collection(t.ParsedDirective.Arguments,
                                  x =>
                {
                    Assert.Equal("a", x.Name.Value);
                    Assert.IsType <StringValueNode>(x.Value);
                    Assert.Equal("b", ((StringValueNode)x.Value).Value);
                });
            });
        }
        public void InferNameFromType()
        {
            // act
            var descriptor = new EnumTypeDescriptor(Context, typeof(FooEnum));

            // assert
            Assert.Equal("FooEnum", descriptor.CreateDefinition().Name);
        }
        public void InitialName()
        {
            // act
            var descriptor = new EnumTypeDescriptor(Context, "Foo");

            // assert
            Assert.Equal("Foo", descriptor.CreateDefinition().Name);
        }
        public void AddDirectiveWithDirectiveNode()
        {
            // arrange
            var descriptor = new EnumTypeDescriptor(Context);

            // act
            IEnumTypeDescriptor desc = descriptor;

            desc.Directive(new DirectiveNode("Bar"));

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Directives,
                              t => Assert.Equal("Bar", t.ParsedDirective.Name.Value));
        }
        public void InferValuesFromType()
        {
            // act
            var descriptor = new EnumTypeDescriptor(Context, typeof(FooEnum));

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Values,
                              t =>
            {
                Assert.Equal("BAR1", t.Name);
                Assert.Equal(FooEnum.Bar1, t.Value);
            },
                              t =>
            {
                Assert.Equal("BAR2", t.Name);
                Assert.Equal(FooEnum.Bar2, t.Value);
            });
        }
        public void ExplicitValueBinding()
        {
            // arrange
            var descriptor = new EnumTypeDescriptor(Context, typeof(FooEnum));

            // act
            IEnumTypeDescriptor desc = descriptor;

            desc.Item(FooEnum.Bar1).Name("FOOBAR");
            desc.BindItems(BindingBehavior.Explicit);

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Values,
                              t =>
            {
                Assert.Equal("FOOBAR", t.Name);
                Assert.Equal(FooEnum.Bar1, t.Value);
            });
        }