public void EqualsObject()
        {
            // arrange
            var a = new BooleanValueNode(false);
            var b = new BooleanValueNode(false);
            var c = new BooleanValueNode(true);
            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(
     BooleanValueNode node,
     ISyntaxNode parent,
     IReadOnlyList <object> path,
     IReadOnlyList <ISyntaxNode> ancestors)
 {
     return(GetDefaultAction(node.Kind));
 }
        public void CreateBooleanValue(bool value)
        {
            // act
            var booleanValueNode = new BooleanValueNode(value);

            // assert
            Assert.Equal(value, booleanValueNode.Value);
            Assert.Equal(NodeKind.BooleanValue, booleanValueNode.Kind);
            Assert.Null(booleanValueNode.Location);
        }
        public void BooleanValue_WithNewValue_NewValueIsSet()
        {
            // arrange
            var booleanValueNode = new BooleanValueNode(false);

            // act
            booleanValueNode = booleanValueNode.WithValue(true);

            // assert
            Assert.True(booleanValueNode.Value);
        }
        public void CreateBooleanValueWithLocation(bool value)
        {
            // arrange
            var location = new Location(0, 0, 0, 0);

            // act
            var booleanValueNode = new BooleanValueNode(location, value);

            // assert
            Assert.Equal(value, booleanValueNode.Value);
            Assert.Equal(SyntaxKind.BooleanValue, booleanValueNode.Kind);
            Assert.Equal(location, booleanValueNode.Location);
        }
        public void StringRepresentation()
        {
            // arrange
            var a = new BooleanValueNode(false);
            var b = new BooleanValueNode(true);

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

            // assert
            Assert.Equal("False", astring);
            Assert.Equal("True", bstring);
        }
Пример #7
0
        /// <summary>
        /// Determines whether the specified <see cref="BooleanValueNode"/>
        /// is equal to the current <see cref="BooleanValueNode"/>.
        /// </summary>
        /// <param name="other">
        /// The <see cref="BooleanValueNode"/> to compare with the current
        /// <see cref="BooleanValueNode"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="BooleanValueNode"/> is equal
        /// to the current <see cref="BooleanValueNode"/>;
        /// otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(BooleanValueNode other)
        {
            if (other is null)
            {
                return(false);
            }

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

            return(other.Value.Equals(Value));
        }
        public void CreateBooleanValueWithLocation(bool value)
        {
            // arrange
            var token = new SyntaxToken(
                TokenKind.StartOfFile, 0, 0, 0, 0, null);
            var location = new Location(new Source("{}"), token, token);

            // act
            var booleanValueNode = new BooleanValueNode(location, value);

            // assert
            Assert.Equal(value, booleanValueNode.Value);
            Assert.Equal(NodeKind.BooleanValue, booleanValueNode.Kind);
            Assert.Equal(location, booleanValueNode.Location);
        }
        public void CompareGetHashCode()
        {
            // arrange
            var a = new BooleanValueNode(false);
            var b = new BooleanValueNode(false);
            var c = new BooleanValueNode(true);

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

            // assert
            Assert.Equal(ahash, bhash);
            Assert.NotEqual(ahash, chash);
        }
        public void BooleanArg(string arg, bool expected)
        {
            // arrange
            byte[] sourceText = Encoding.UTF8.GetBytes(
                "{ a(b:" + arg + ") }");

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

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

            Assert.Equal(expected, value.Value);
        }
        public void EqualsBooleanValueNode()
        {
            // arrange
            var a = new BooleanValueNode(false);
            var b = new BooleanValueNode(false);
            var c = new BooleanValueNode(true);

            // 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(BooleanValueNode));

            // assert
            Assert.True(ab_result);
            Assert.True(aa_result);
            Assert.False(ac_result);
            Assert.False(anull_result);
        }
        public void EqualsIValueNode()
        {
            // arrange
            var a = new BooleanValueNode(false);
            var b = new BooleanValueNode(false);
            var c = new BooleanValueNode(true);
            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);
        }
Пример #13
0
 protected override void VisitBooleanValue(BooleanValueNode node)
 {
     _writer.Write(node.Value.ToString().ToLowerInvariant());
 }
 public static void WriteBooleanValue(
     this DocumentWriter writer,
     BooleanValueNode node)
 {
     writer.Write(node.Value.ToString().ToLowerInvariant());
 }
Пример #15
0
 protected virtual void VisitBooleanValue(BooleanValueNode node)
 {
 }
Пример #16
0
 protected virtual BooleanValueNode RewriteBooleanValue(
     BooleanValueNode node,
     TContext context)
 {
     return(node);
 }
Пример #17
0
 protected virtual void VisitBooleanValue(
     BooleanValueNode node,
     TContext context)
 {
 }