Beispiel #1
0
        public void TestImplicitCast()
        {
            Assert.AreEqual((byte)5, Ops.ImplicitCast <byte, byte>(5));

            {
                long rst = 5;
                Assert.AreEqual(rst, Ops.ImplicitCast <int, long>(5));
            }

            {
                long rst = new MyInt(5);
                Assert.AreEqual(rst, Ops.ImplicitCast <MyInt, long>(new MyInt(5)));
            }

            {
                MyLong rst = 5;
                Assert.AreEqual(rst, Ops.ImplicitCast <int, MyLong>(5));
            }

            {
                decimal rst = 5;
                Assert.AreEqual(rst, Ops.ImplicitCast <byte, decimal>(5));
            }

            Assert.IsTrue(Can <int, long> .ImplicitCast);
            Assert.IsFalse(Can <BigInteger, long> .ImplicitCast);
            Assert.IsTrue(Can <MyLong, Base> .ImplicitCast);
        }
Beispiel #2
0
        public void TestDecreaseAndGetOriginal()
        {
            {
                var v = 1u;
                Assert.AreEqual(1u, Ops.DecreaseAndGetOriginal(ref v));
                Assert.AreEqual(0u, v);
            }
            {
                var v = 0f;
                Assert.AreEqual(0f, Ops.DecreaseAndGetOriginal(ref v));
                Assert.AreEqual(-1f, v);
            }
            {
                var v = new MyInt(-100);
                Assert.AreEqual(new MyInt(-100), Ops.DecreaseAndGetOriginal(ref v));
                Assert.AreEqual(new MyInt(-101), v);
            }

            {
                var v = new BigInteger(-100);
                Assert.AreEqual(new BigInteger(-100), Ops.DecreaseAndGetOriginal(ref v));
                Assert.AreEqual(new BigInteger(-101), v);
            }

            {
                var v = new MyLong(-100);
                Assert.AreSame(v, Ops.DecreaseAndGetOriginal(ref v));
                Assert.AreEqual(new MyLong(-101), v);
            }
        }
 /// <summary>
 /// Returns the hashcode of this Object
 /// </summary>
 /// <returns>Hash code (int)</returns>
 public override int GetHashCode()
 {
     // Credit: http://stackoverflow.com/a/263416/677735
     unchecked             // Overflow is fine, just wrap
     {
         int hash = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hash = hash * 59 + Id.GetHashCode();
         }
         if (Name != null)
         {
             hash = hash * 59 + Name.GetHashCode();
         }
         if (Description != null)
         {
             hash = hash * 59 + Description.GetHashCode();
         }
         if (MyBoolean != null)
         {
             hash = hash * 59 + MyBoolean.GetHashCode();
         }
         if (MyCreditCard != null)
         {
             hash = hash * 59 + MyCreditCard.GetHashCode();
         }
         if (MyCurrency != null)
         {
             hash = hash * 59 + MyCurrency.GetHashCode();
         }
         if (MyDateTime != null)
         {
             hash = hash * 59 + MyDateTime.GetHashCode();
         }
         if (MyDouble != null)
         {
             hash = hash * 59 + MyDouble.GetHashCode();
         }
         if (MyEmail != null)
         {
             hash = hash * 59 + MyEmail.GetHashCode();
         }
         if (MyFloat != null)
         {
             hash = hash * 59 + MyFloat.GetHashCode();
         }
         if (MyImageUrl != null)
         {
             hash = hash * 59 + MyImageUrl.GetHashCode();
         }
         if (MyInteger != null)
         {
             hash = hash * 59 + MyInteger.GetHashCode();
         }
         if (MyLong != null)
         {
             hash = hash * 59 + MyLong.GetHashCode();
         }
         if (MyPhone != null)
         {
             hash = hash * 59 + MyPhone.GetHashCode();
         }
         if (MyPostalCode != null)
         {
             hash = hash * 59 + MyPostalCode.GetHashCode();
         }
         if (MyString != null)
         {
             hash = hash * 59 + MyString.GetHashCode();
         }
         if (MyTextArea != null)
         {
             hash = hash * 59 + MyTextArea.GetHashCode();
         }
         if (MyTicks != null)
         {
             hash = hash * 59 + MyTicks.GetHashCode();
         }
         if (MyUrl != null)
         {
             hash = hash * 59 + MyUrl.GetHashCode();
         }
         if (Comments != null)
         {
             hash = hash * 59 + Comments.GetHashCode();
         }
         if (AuditEntered != null)
         {
             hash = hash * 59 + AuditEntered.GetHashCode();
         }
         if (AuditEnteredBy != null)
         {
             hash = hash * 59 + AuditEnteredBy.GetHashCode();
         }
         if (AuditUpdated != null)
         {
             hash = hash * 59 + AuditUpdated.GetHashCode();
         }
         if (AuditUpdatedBy != null)
         {
             hash = hash * 59 + AuditUpdatedBy.GetHashCode();
         }
         return(hash);
     }
 }
 public Task <long> SubLongTask(MyLong data)
 {
     return(Task.FromResult(data.Data));
 }
Beispiel #5
0
			public static string LongCalc(MyLong p1, MyLong p2)
			{
				return MethodInfo.GetCurrentMethod().ToString();
			}