public void EqualsObject()
        {
            // arrange
            var a = new FloatValueNode(1.0);
            var b = new FloatValueNode(1.0);
            var c = new FloatValueNode(2.0);
            var d = "foo";
            var e = 1;

            // act
            bool ab_result    = a.Equals((object)b);
            bool aa_result    = a.Equals((object)a);
            bool ac_result    = a.Equals((object)c);
            bool ad_result    = a.Equals((object)d);
            bool ae_result    = a.Equals((object)e);
            bool anull_result = a.Equals(default(object));

            // assert
            Assert.True(ab_result);
            Assert.True(aa_result);
            Assert.False(ac_result);
            Assert.False(ad_result);
            Assert.False(ae_result);
            Assert.False(anull_result);
        }
示例#2
0
 public virtual VisitorAction Leave(
     FloatValueNode node,
     ISyntaxNode parent,
     IReadOnlyList <object> path,
     IReadOnlyList <ISyntaxNode> ancestors)
 {
     return(GetDefaultAction(node.Kind));
 }
        public void Convert_Value_Float_To_Span_To_String()
        {
            // act
            var    a = new FloatValueNode(2.5);
            var    b = a.WithValue(a.AsSpan(), FloatFormat.FixedPoint);
            string c = b.Value;

            // assert
            Assert.Equal("2.50", c);
        }
        public void CreateFloatValue(string value)
        {
            // act
            var floatValueNode = new FloatValueNode(value);

            // assert
            Assert.Equal(value, floatValueNode.Value);
            Assert.Equal(NodeKind.FloatValue, floatValueNode.Kind);
            Assert.Null(floatValueNode.Location);
        }
        public void CreateFloatValueWithLocation(string value)
        {
            // arrange
            var location = new Location(0, 0, 0, 0);

            // act
            var floatValueNode = new FloatValueNode(location, value);

            // assert
            Assert.Equal(value, floatValueNode.Value);
            Assert.Equal(NodeKind.FloatValue, floatValueNode.Kind);
            Assert.Equal(location, floatValueNode.Location);
        }
        public void ToDecimal(string value, decimal expected)
        {
            // arrange
            byte[] buffer   = Encoding.UTF8.GetBytes(value);
            var    location = new Location(0, 0, 0, 0);

            // act
            var floatValueNode = new FloatValueNode(
                location, buffer, FloatFormat.FixedPoint);

            // assert
            Assert.Equal(expected, floatValueNode.ToDecimal());
        }
        public void CreateFloatValue(string value)
        {
            // arrange
            byte[] buffer = Encoding.UTF8.GetBytes(value);

            // act
            var floatValueNode = new FloatValueNode(
                buffer, FloatFormat.FixedPoint);

            // assert
            Assert.Equal(value, floatValueNode.Value);
            Assert.Equal(NodeKind.FloatValue, floatValueNode.Kind);
            Assert.Null(floatValueNode.Location);
        }
        /// <summary>
        /// Determines whether the specified <see cref="FloatValueNode"/>
        /// is equal to the current <see cref="FloatValueNode"/>.
        /// </summary>
        /// <param name="other">
        /// The <see cref="FloatValueNode"/> to compare with the current
        /// <see cref="FloatValueNode"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="FloatValueNode"/> is equal
        /// to the current <see cref="FloatValueNode"/>;
        /// otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(FloatValueNode other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(other, this))
            {
                return(true);
            }

            return(other.Value.Equals(Value, StringComparison.Ordinal));
        }
        public void StringRepresentation()
        {
            // arrange
            var a = new FloatValueNode(1.0);
            var b = new FloatValueNode(2.0);

            // act
            string astring = a.ToString();
            string bstring = b.ToString();

            // assert
            Assert.Equal("1.00", astring);
            Assert.Equal("2.00", bstring);
        }
示例#10
0
        public void CreateFloatValueWithLocation(string value)
        {
            // arrange
            var token = new SyntaxToken(
                TokenKind.StartOfFile, 0, 0, 0, 0, null);
            var location = new Location(new Source("{}"), token, token);

            // act
            var floatValueNode = new FloatValueNode(location, value);

            // assert
            Assert.Equal(value, floatValueNode.Value);
            Assert.Equal(NodeKind.FloatValue, floatValueNode.Kind);
            Assert.Equal(location, floatValueNode.Location);
        }
示例#11
0
        public void CreateFloatValueWithLocation(string value)
        {
            // arrange
            byte[] buffer   = Encoding.UTF8.GetBytes(value);
            var    location = new Location(0, 0, 0, 0);

            // act
            var floatValueNode = new FloatValueNode(
                location, buffer, FloatFormat.FixedPoint);

            // assert
            Assert.Equal(value, floatValueNode.Value);
            Assert.Equal(SyntaxKind.FloatValue, floatValueNode.Kind);
            Assert.Equal(location, floatValueNode.Location);
        }
        public void CompareGetHashCode()
        {
            // arrange
            var a = new FloatValueNode(1.0);
            var b = new FloatValueNode(1.0);
            var c = new FloatValueNode(2.0);

            // act
            int ahash = a.GetHashCode();
            int bhash = b.GetHashCode();
            int chash = c.GetHashCode();

            // assert
            Assert.Equal(ahash, bhash);
            Assert.NotEqual(ahash, chash);
        }
        public void EqualsFloatValueNode()
        {
            // arrange
            var a = new FloatValueNode(1.0);
            var b = new FloatValueNode(1.0);
            var c = new FloatValueNode(3.0);

            // act
            bool ab_result    = a.Equals(b);
            bool aa_result    = a.Equals(a);
            bool ac_result    = a.Equals(c);
            bool anull_result = a.Equals(default(FloatValueNode));

            // assert
            Assert.True(ab_result);
            Assert.True(aa_result);
            Assert.False(ac_result);
            Assert.False(anull_result);
        }
        public void FloatArg(string arg)
        {
            // arrange
            byte[] sourceText = Encoding.UTF8.GetBytes(
                "{ a(b:" + arg + ") }");

            // act
            var parser = new Utf8GraphQLParser(
                sourceText, ParserOptions.Default);
            DocumentNode document = parser.Parse();

            // assert
            FloatValueNode value = Assert.IsType <FloatValueNode>(
                document.Definitions.OfType <OperationDefinitionNode>().First()
                .SelectionSet.Selections.OfType <FieldNode>().First()
                .Arguments.First().Value);

            Assert.Equal(arg, value.Value);
        }
        public void EqualsIValueNode()
        {
            // arrange
            var a = new FloatValueNode(1.0);
            var b = new FloatValueNode(1.0);
            var c = new FloatValueNode(2.0);
            var d = new StringValueNode("foo");

            // act
            bool ab_result    = a.Equals((IValueNode)b);
            bool aa_result    = a.Equals((IValueNode)a);
            bool ac_result    = a.Equals((IValueNode)c);
            bool ad_result    = a.Equals((IValueNode)d);
            bool anull_result = a.Equals(default(IValueNode));

            // assert
            Assert.True(ab_result);
            Assert.True(aa_result);
            Assert.False(ac_result);
            Assert.False(ad_result);
            Assert.False(anull_result);
        }
示例#16
0
 protected virtual void VisitFloatValue(
     FloatValueNode node,
     TContext context)
 {
 }
示例#17
0
 protected virtual FloatValueNode RewriteFloatValue(
     FloatValueNode node,
     TContext context)
 {
     return(node);
 }
示例#18
0
 protected virtual void VisitFloatValue(FloatValueNode node)
 {
 }
示例#19
0
 protected override void VisitFloatValue(FloatValueNode node)
 {
     _writer.Write(node.Value);
 }
 public static void WriteFloatValue(
     this DocumentWriter writer,
     FloatValueNode node)
 {
     writer.Write(node.Value);
 }