Exemplo n.º 1
0
        public void GraphId_Equals_Fails_When_Passsing_Null_Object()
        {
            var    id = new GraphId();
            object x  = null;

            Assert.False(id.Equals(x));
        }
Exemplo n.º 2
0
        public void NotEqualsOperator_AgainstObject(string value1, object value2, bool isSuccess)
        {
            var id1 = new GraphId(value1);

            Assert.AreEqual(isSuccess, id1 != value2);
            Assert.AreEqual(isSuccess, value2 != id1);
        }
Exemplo n.º 3
0
        public void GraphId_Equals_Fails()
        {
            var id    = new GraphId();
            var other = new GraphId();

            Assert.False(id.Equals(other));
        }
Exemplo n.º 4
0
        public void GraphId_LogicalNotEqualsOp_Fails_When_lhs_Set_To_Null()
        {
            GraphId lhs = null;
            GraphId rhs = new GraphId();

            Assert.True(lhs != rhs);
        }
Exemplo n.º 5
0
        public void GraphId_LogicalEqualsOp_Fails_When_rhs_Set_To_Null()
        {
            GraphId lhs = new GraphId();
            GraphId rhs = null;

            Assert.False(lhs == rhs);
        }
Exemplo n.º 6
0
        public void GraphId_LogicalNotEqualsOp_Works()
        {
            GraphId lhs = new GraphId();
            GraphId rhs = new GraphId();

            Assert.True(lhs != rhs);
        }
Exemplo n.º 7
0
        public void GraphId_Equals_Works_For_Same_Object()
        {
            var id    = new GraphId();
            var idObj = (object)id;

            Assert.That(id.Equals(idObj), Is.EqualTo(true));
        }
Exemplo n.º 8
0
        public void GraphId_New_Works_When_Value_Set_To(string expected)
        {
            var value = Guid.Parse(expected);
            var id    = new GraphId(value);

            Assert.That(id.Value, Is.EqualTo(value.ToUlong()));
        }
Exemplo n.º 9
0
        public void EqualsMethodAgainstOtherIdAsObject_Matches()
        {
            var id       = new GraphId("abc");
            var secondId = new GraphId("abc");

            Assert.IsTrue(id.Equals((object)secondId));
        }
Exemplo n.º 10
0
        public void EqualsMethodAgainstGraphId_Matches()
        {
            var id  = new GraphId("abc");
            var id2 = new GraphId("abc");

            Assert.IsTrue(id.Equals(id2));
        }
Exemplo n.º 11
0
        public void New_Works_When_Using_Custom_Comparer()
        {
            GraphId id = new GraphId();
            IEqualityComparer <int> comparer = new CustomIntEqualityComparer();

            Assert.That(() => new Graph <int>(id, comparer), Throws.Nothing);
        }
Exemplo n.º 12
0
        public void StringImplicitCast_IsSuccessful()
        {
            GraphId id  = new GraphId("abc");
            string  str = id;

            Assert.AreEqual("abc", str);
        }
Exemplo n.º 13
0
        public void GraphId_LogicalEqualsOp_Works()
        {
            GraphId lhs = new GraphId();
            GraphId rhs = new GraphId();

            Assert.False(lhs == rhs);
        }
Exemplo n.º 14
0
        public void GraphId_LogicalNotEqualsOp_Works_For_Equal_References()
        {
            GraphId x = new GraphId();

            #pragma warning disable 1718
            Assert.False(x != x);
            #pragma warning restore 1718
        }
Exemplo n.º 15
0
        public void ConstructorFromGraphId_YieldsIdValueThatMatches()
        {
            var id = new GraphId("abc");

            var newId = new GraphId(id);

            Assert.AreEqual(id.Value, newId.Value);
        }
Exemplo n.º 16
0
        public void EqualsMethodAgainstNonString_DoesNotMatch()
        {
            var id = new GraphId("abc");

            var idValue = (object)123;

            Assert.IsFalse(id.Equals(idValue));
        }
Exemplo n.º 17
0
        public void GraphId_CompareTo_Works_When_Value_Set_To(string expected)
        {
            var value = Guid.Parse(expected);
            var id    = new GraphId(value);
            var other = new GraphId(value);

            Assert.True(id.CompareTo(other) == 0);
        }
Exemplo n.º 18
0
        public void GraphId_CompareTo_Works()
        {
            var id    = new GraphId();
            var other = new GraphId();

            Assert.That(id, Is.Not.EqualTo(other));
            Assert.That(id.Value, Is.Not.EqualTo(other.Value));
        }
Exemplo n.º 19
0
        public void EqualsMethodAgainstStringObject_Matches()
        {
            var id = new GraphId("abc");

            var obj = (object)"abc";

            Assert.IsTrue(id.Equals(obj));
        }
Exemplo n.º 20
0
        public void NotEqualsOperatorAgainstSelf_IsFalse()
        {
            var id = new GraphId("123");

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.IsFalse(id != id);
#pragma warning restore CS1718 // Comparison made to same variable
        }
Exemplo n.º 21
0
        public void NotEqualsOperator(string value1, string value2, bool isSuccess)
        {
            var id1 = new GraphId(value1);
            var id2 = new GraphId(value2);

            Assert.AreEqual(isSuccess, id1 != id2);
            Assert.AreEqual(isSuccess, id2 != id1);
        }
Exemplo n.º 22
0
        public void GeneralPropertyCheck()
        {
            var id = new GraphId("abc");

            Assert.AreEqual("abc", id.Value);
            Assert.AreEqual("abc", id.ToString());
            Assert.AreEqual("abc".GetHashCode(), id.GetHashCode());
        }
Exemplo n.º 23
0
        public void EqualsOperatorWithNullValueAgaintNullObject_IsFalse()
        {
            var id = new GraphId(null);

            object obj = null;

            Assert.IsFalse(id == obj);
        }
Exemplo n.º 24
0
        public void EqualsOperatorAgainstSelf_IsTrue()
        {
            var id = new GraphId("123");

            // ReSharper disable once EqualExpressionComparison
#pragma warning disable CS1718 // Comparison made to same variable
            Assert.IsTrue(id == id);
#pragma warning restore CS1718 // Comparison made to same variable
        }
Exemplo n.º 25
0
        public void GraphId_Equals_Works_When_Value_Set_To(string expected)
        {
            var value = Guid.Parse(expected);
            var id    = new GraphId(value);
            var other = new GraphId(value);

            Assert.True(id.Equals(other));
            Assert.That(id.Value, Is.EqualTo(other.Value));
            Assert.That(id.GetHashCode(), Is.EqualTo(other.GetHashCode()));
        }
Exemplo n.º 26
0
        /// <summary>
        /// Create a new graph using the given GraphId.
        /// </summary>
        /// <param name="GraphId">An optional GraphId.</param>
        /// <param name="Graph">A optional Graph.</param>
        public GeraGraph CreateGraph(GraphId GraphId = null, GeraGraph Graph = null)
        {
            if (GraphId == null)
                GraphId = GraphId.NewGraphId;

            if (Graph   == null)
                Graph   = new GeraGraph(GraphId);

            _Graphs.Add(GraphId, Graph);

            return Graph;
        }
Exemplo n.º 27
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hash = 17;

                hash = hash * 29 + ScriptId.GetHashCode();
                hash = hash * 29 + Handle.GetHashCode();
                hash = hash * 29 + NodeId.GetHashCode();
                hash = hash * 29 + GraphId.GetHashCode();

                return(hash);
            }
        }
Exemplo n.º 28
0
        public async Task <IGraphActionResult> RetrieveHuman([FromGraphQL("id")] GraphId humanId)
        {
            var human = await _starWarsData.RetrieveHuman(humanId).ConfigureAwait(false);

            return(this.Ok(human));
        }
Exemplo n.º 29
0
        public async Task <IGraphActionResult> RetrieveDroid([FromGraphQL("id")] GraphId droidId)
        {
            var droid = await _starWarsData.RetrieveDroid(droidId).ConfigureAwait(false);

            return(this.Ok(droid));
        }
Exemplo n.º 30
0
        public void EqualsMethodAgainstSelfAsObject_Matches()
        {
            var id = new GraphId("abc");

            Assert.IsTrue(id.Equals((object)id));
        }
Exemplo n.º 31
0
        /// <summary>
        /// Checks if a Graph having the given GraphId already exists.
        /// </summary>
        /// <param name="GraphId">An GraphId.</param>
        public Boolean HasGraph(GraphId GraphId)
        {
            if (GraphId != null)
                return _Graphs.ContainsKey(GraphId);

            return false;
        }
Exemplo n.º 32
0
        public void EqualsMethodAgainstNullAsObject_DoesNotMatch()
        {
            var id = new GraphId("abc");

            Assert.IsFalse(id.Equals(null));
        }
Exemplo n.º 33
0
        /// <summary>
        /// Removes the Graph having the given GraphId.
        /// </summary>
        /// <param name="GraphId">An GraphId.</param>
        public Boolean RemoveGraph(GraphId GraphId)
        {
            if (GraphId != null)
                return _Graphs.Remove(GraphId);

            return false;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Return a specific graph.
        /// </summary>
        /// <param name="GraphId">The GraphId.</param>
        /// <param name="Graph">The Graph.</param>
        public Boolean TryGetGraph(GraphId GraphId, out GeraGraph Graph)
        {
            if (GraphId != null)
                return _Graphs.TryGetValue(GraphId, out Graph);

            Graph = null;
            return false;
        }