コード例 #1
0
 public void AssertNull <T>(T actualValue, string name) where T : class
 {
     if (null != actualValue)
     {
         throw AssertionFailedException.Create(actualValue, null, name);
     }
 }
コード例 #2
0
 public void AssertEqual <T>(T actualValue, T expectedValue, string name)
 {
     if (!object.Equals(actualValue, expectedValue))
     {
         throw AssertionFailedException.Create(actualValue, expectedValue, name);
     }
 }
コード例 #3
0
        public static void TestArray <T>(T[] Expected, IReadOnlyList <T> Actual, string ArrayName, string test)
        {
            string AnnotatedName = ArrayName;

            if (test != null)
            {
                AnnotatedName = String.Format("{0}-{1}", test, ArrayName);
            }

            if (!SequenceCompare(Expected, Actual))
            {
                throw AssertionFailedException.Create(EnumerableToString(Actual), EnumerableToString(Expected), AnnotatedName);
            }

            if (Expected.Length != Actual.Count)
            {
                throw AssertionFailedException.Create(Actual.Count, Expected.Length, AnnotatedName + ".Count");
            }

            for (int i = 0; i < Expected.Length; ++i)
            {
                if ((Expected[i] != null && !Expected[i].Equals(Actual[i])) ||
                    (Expected[i] == null && Actual[i] != null))
                {
                    throw AssertionFailedException.Create(Actual[i], Expected[i], String.Format("{0}[{1}]", AnnotatedName, i));
                }
            }
        }