Exemple #1
0
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: Get hash code for an empty struct");

        try
        {
            Empty test  = new Empty();
            Empty test1 = new Empty();

            if (test.GetHashCode() != test1.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("101", "Hash code for two Empty struct instances does not equal");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Exemple #2
0
        public void CreateEmptyEntity_ReturnExpressionAsString()
        {
            var empty      = new Empty();
            var expression = empty.AsExpression();
            var result     = expression.DefaultSerializer.Serialize();
            var expected   = $"\"{empty.GetType().Name}.{empty.GetHashCode()}\"";

            Assert.Single(expression);
            Assert.Equal(expected, result);
        }
Exemple #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Empty.GetHashCode();
         hashCode = (hashCode * 397) ^ Color.GetHashCode();
         hashCode = (hashCode * 397) ^ Metallic.GetHashCode();
         hashCode = (hashCode * 397) ^ Smoothness.GetHashCode();
         hashCode = (hashCode * 397) ^ Emission.GetHashCode();
         return(hashCode);
     }
 }
Exemple #4
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked             // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)

                hashCode = hashCode * 59 + Type.GetHashCode();

                hashCode = hashCode * 59 + Empty.GetHashCode();

                hashCode = hashCode * 59 + Direction.GetHashCode();

                hashCode = hashCode * 59 + RotatorDirection.GetHashCode();

                hashCode = hashCode * 59 + Level.GetHashCode();

                hashCode = hashCode * 59 + Order.GetHashCode();
                return(hashCode);
            }
        }
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: Get hash code for an empty struct");

        try
        {
            Empty test = new Empty();
            Empty test1 = new Empty();

            if (test.GetHashCode() != test1.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("101", "Hash code for two Empty struct instances does not equal");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
 public void ShouldGenerateHashCodeForEmptyObject()
 {
     var value = new Empty();
     Assert.That(value.GetHashCode(), Is.EqualTo(HashCode.Seed));
 }