コード例 #1
0
        public static ISchemaBuilder AddResolver(
            this ISchemaBuilder builder,
            FieldCoordinate field,
            FieldResolverDelegate resolver,
            Type?resultType = null)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (!field.HasValue)
            {
                throw new ArgumentException(
                          TypeResources.SchemaBuilderExtensions_AddResolver_EmptyCooridnates,
                          nameof(builder));
            }

            if (resolver is null)
            {
                throw new ArgumentNullException(nameof(resolver));
            }

            return(AddResolverConfigInternal(builder, field, resolver, resultType));
        }
コード例 #2
0
        public void ToString_Field()
        {
            // arrange
            var fieldCoordinate = new FieldCoordinate("abc", "def");

            // act
            // assert
            Assert.Equal("abc.def", fieldCoordinate.ToString());
        }
コード例 #3
0
        public void HasValue_True()
        {
            // arrange
            var fieldCoordinate = new FieldCoordinate("abc", "def");

            // act
            // assert
            Assert.True(fieldCoordinate.HasValue);
        }
コード例 #4
0
        public void HasValue_False()
        {
            // arrange
            var fieldCoordinate = new FieldCoordinate();

            // act
            // assert
            Assert.False(fieldCoordinate.HasValue);
        }
コード例 #5
0
        public void CreateWithoutTypeName()
        {
            // arrange
            // act
            var fieldCoordinate = FieldCoordinate.CreateWithoutType("abc");

            // assert
            Assert.Equal("__Empty.abc", fieldCoordinate.ToString());
        }
コード例 #6
0
        public void GetHashCode_Field_Argument()
        {
            // arrange
            var a = new FieldCoordinate("abc", "def", "ghi");
            var b = new FieldCoordinate("abc", "def", "ghi");

            // act
            // assert
            Assert.Equal(a.GetHashCode(), b.GetHashCode());
        }
コード例 #7
0
        public void Object_Equals_Argument_False()
        {
            // arrange
            var a = new FieldCoordinate("abc", "def", "ghi");
            var b = new FieldCoordinate("abc", "def", "xyz");

            // act
            // assert
            Assert.False(a.Equals((object)b));
        }
コード例 #8
0
        public void Equals_Argument_True()
        {
            // arrange
            var a = new FieldCoordinate("abc", "def", "ghi");
            var b = new FieldCoordinate("abc", "def", "ghi");

            // act
            // assert
            Assert.True(a.Equals(b));
        }
コード例 #9
0
        public void Equals_Field_To_Arg_False()
        {
            // arrange
            var a = new FieldCoordinate("abc", "def");
            var b = new FieldCoordinate("abc", "def", "ghi");

            // act
            // assert
            Assert.False(a.Equals(b));
        }
コード例 #10
0
        public void With_FieldName()
        {
            // arrange
            var fieldCoordinate = new FieldCoordinate("abc", "def");

            // act
            fieldCoordinate = fieldCoordinate.With(fieldName: new NameString("xyz"));

            // assert
            Assert.Equal("abc.xyz", fieldCoordinate.ToString());
        }
コード例 #11
0
        public void With_Argument()
        {
            // arrange
            var fieldCoordinate = new FieldCoordinate("abc", "def");

            // act
            fieldCoordinate = fieldCoordinate.With(argumentName: new NameString("xyz"));

            // assert
            Assert.Equal("abc.def(xyz)", fieldCoordinate.ToString());
        }
コード例 #12
0
        public void Deconstruct_Coordinates()
        {
            // arrange
            var a = new FieldCoordinate("abc", "def", "ghi");
            var b = new FieldCoordinate("abc", "def");

            // act
            (NameString at, NameString af, NameString? aa) = a;
            (NameString bt, NameString bf, NameString? ba) = b;

            // assert
            Assert.Equal(a.TypeName, at);
            Assert.Equal(a.FieldName, af);
            Assert.Equal(a.ArgumentName, aa);
            Assert.Equal(b.TypeName, bt);
            Assert.Equal(b.FieldName, bf);
            Assert.Equal(b.ArgumentName, ba);
        }