public void GetName()
        {
            // act
            var descriptor = new ArgumentDescriptor(Context, "args");

            // assert
            Assert.Equal("args", descriptor.CreateDefinition().Name);
        }
        public void SetDescription()
        {
            // arrange
            string expectedDescription = Guid.NewGuid().ToString();
            var    descriptor          = new ArgumentDescriptor(Context, "Type");

            // act
            descriptor.Description(expectedDescription);

            // assert
            Assert.Equal(expectedDescription,
                         descriptor.CreateDefinition().Description);
        }
        public void GetNameAndType()
        {
            // act
            var descriptor = new ArgumentDescriptor(
                Context, "args", typeof(string));

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

            Assert.Equal("args", description.Name);
            Assert.Equal(typeof(string),
                         Assert.IsType <ExtendedTypeReference>(description.Type).Type.Source);
        }
        public void SetDefaultValueNull()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "args");

            // act
            descriptor.DefaultValue(null);

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

            Assert.Equal(NullValueNode.Default, description.DefaultValue);
            Assert.Null(description.NativeDefaultValue);
        }
        public void SetTypeInstance()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "Type");

            // act
            descriptor.Type(new StringType());

            // assert
            ArgumentDefinition description = descriptor.CreateDefinition();
            ITypeReference     typeRef     = description.Type;

            Assert.IsType <StringType>(
                Assert.IsType <SchemaTypeReference>(typeRef).Type);
        }
        public void SetNonGenericType()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "Type");

            // act
            descriptor.Type(typeof(StringType));

            // assert
            ArgumentDefinition description = descriptor.CreateDefinition();
            ITypeReference     typeRef     = description.Type;

            Assert.Equal(
                typeof(StringType),
                Assert.IsType <ExtendedTypeReference>(typeRef).Type.Source);
        }
        public void OverwriteDefaultValueLiteralWithNativeDefaultValue()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "args");

            // act
            descriptor
            .DefaultValue(new StringValueNode("123"))
            .DefaultValue("string");

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

            Assert.Null(description.DefaultValue);
            Assert.Equal("string", description.NativeDefaultValue);
        }
        public void SetDefaultValueAndInferType()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "args");

            // act
            descriptor.DefaultValue("string");

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

            Assert.Equal(typeof(string),
                         Assert.IsType <ExtendedTypeReference>(description.Type).Type.Source);
            Assert.Equal("string",
                         description.NativeDefaultValue);
        }
        public void DotNetTypesDoNotOverwriteSchemaTypes()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "Type");

            // act
            descriptor
            .Type <ListType <StringType> >()
            .Type <NativeType <IReadOnlyDictionary <string, string> > >();

            // assert
            ArgumentDefinition description = descriptor.CreateDefinition();
            ITypeReference     typeRef     = description.Type;

            Assert.Equal(typeof(ListType <StringType>),
                         Assert.IsType <ExtendedTypeReference>(typeRef).Type.Source);
        }
        public void SettingTheNativeDefaultValueToNullCreatesNullLiteral()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "args");

            // act
            descriptor
            .DefaultValue(new StringValueNode("123"))
            .DefaultValue("string")
            .DefaultValue(null);

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

            Assert.IsType <NullValueNode>(description.DefaultValue);
            Assert.Null(description.NativeDefaultValue);
        }
Пример #11
0
        public void OverwriteNativeDefaultValueWithDefaultValueLiteral()
        {
            // arrange
            var descriptor = new ArgumentDescriptor(Context, "args");

            // act
            descriptor
            .DefaultValue("string")
            .DefaultValue(new StringValueNode("123"));

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

            Assert.IsType <StringValueNode>(description.DefaultValue);
            Assert.Equal("123", ((StringValueNode)description.DefaultValue).Value);
            Assert.Null(description.RuntimeDefaultValue);
        }