示例#1
0
        static void ExceptionTraceIsCorrect(bool reallyDie, Exception e, ICollection <string> patterns)
        {
            if (reallyDie)
            {
                Fail("expected failure did not occur");
            }
            if (O.isEmpty(patterns))
            {
                Bomb.toss("expected failure occurred, provide regex to Bombs\nEXPECTED:" + e);
            }
            var exceptions = O.list <Exception>();

            exceptions.Add(e);
            while (e != e.GetBaseException())
            {
                e = e.GetBaseException();
                exceptions.Add(e);
            }
            var messages = O.convert(exceptions, anE => anE.Message);

            try {
                Bomb.when(
                    patterns.Count > exceptions.Count,
                    () => "exception stack not deep enough for " + patterns.Count + " patterns:\n" + e
                    );
                O.each(patterns, messages, Matches);
            } catch (Exception matchFailed) {
                Bomb.toss("expected patterns:\n" + O.toShortString(patterns) +
                          "\ndid not match exception messages:\n" + O.toShortString(messages), matchFailed);
            }
        }
示例#2
0
 public static void HaveSameCount <T1, T2>(T1[] ones, T2[] twos)
 {
     if (ones.GetLength(0) == twos.GetLength(0))
     {
         return;
     }
     throw Bomb.toss("lists have different counts - \nONES: \n" + O.toShortString(ones) + "\nTWOS:\n" + O.toShortString(twos));
 }
示例#3
0
 public void testShortString()
 {
     AreEqual("[a, b, c]", O.toShortString(O.list("a", "b", "c")));
     AreEqual("2.34K", O.toShortString(2341));
     AreEqual("2.34u", O.toShortString(.000002341));
     AreEqual("1.00G", O.toShortString(1000002341));
     AreEqual("1.00M", O.toShortString(1002341));
 }
示例#4
0
 public static void HaveSameCount <T1, T2>(List <T1> ones, List <T2> twos)
 {
     if (ones.Count == twos.Count)
     {
         return;
     }
     throw Bomb.toss("lists have different counts - \nONES: \n" + O.toShortString(ones) + "\nTWOS:\n" + O.toShortString(twos));
 }
示例#5
0
        public void testMultiThreadDictionaryLookup()
        {
            var refDict = new WeakRefDictionary <Bar, double>();

            O.zeroTo(10000000, i => {
                refDict[new Bar(1, 1, 1, 1)] = 0.0;
                refDict[new Bar(2, 2, 2, 2)] = 1.0;
                new Thread(() => O.toShortString(refDict.Keys)).Start();
                O.toShortString(refDict.Keys);
            });
        }