Пример #1
0
        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));
 }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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());
        }
Пример #7
0
        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);
        }
Пример #8
0
        /// <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));
        }
Пример #9
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #15
0
        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);
 }