void TestMe(NonGen g, string[] args, bool mustThrow)
        {
            var d = new Dictionary <string, bool>();

            foreach (var a in args)
            {
                d.Add(a, mustThrow);
            }
            try {
                var z = g.ExecuteBindingAsync(d);
                if (mustThrow)
                {
                    throw new ArgumentNullException();
                }
            }
            catch (AggregateException ae) {
                if (ae.InnerException is ArgumentException)
                {
                    if (!mustThrow)
                    {
                        throw;
                    }
                }
                else
                {
                    throw;
                }
            }
        }
    void Test()
    {
      var g = new NonGen();
      TestMe(g, new[]{"a", "b"}, false);

      if (!behave) {
        TestMe(g, new[]{"a", "b", "c", "e", "f", "g"}, true);
      }
    }
    void Test()
    {
      var g = new NonGen();
      TestMe(g, 20, false);
      TestMe(g, 5, true);

      if (!behave) {
        TestMe(g, 5, false);
      }
    }
        void Test()
        {
            var g = new NonGen();

            TestMe(g, new[] { "a", "b" }, false);

            if (!behave)
            {
                TestMe(g, new[] { "a", "b", "c", "e", "f", "g" }, true);
            }
        }
        void Test()
        {
            var g = new NonGen();

            TestMe(g, 20, false);
            TestMe(g, 5, true);

            if (!behave)
            {
                TestMe(g, 5, false);
            }
        }
    void TestMe(NonGen g, int limit, bool mustThrow) {
      try {
        var z = g.FooAsync(limit);
 
        foreach (var i in z.Result) {
          Console.WriteLine("Result = {0}", i);
        }

        if (mustThrow) {
          throw new Exception("failed to throw");
        }
      }
      catch (AggregateException ae) {
        if (!mustThrow) {
            throw;
        }
      }
    }
 void TestMe(NonGen g, string[] args, bool mustThrow) {
   var d = new Dictionary<string,bool>();
   foreach (var a in args) { d.Add(a, mustThrow); }
   try {
     var z = g.ExecuteBindingAsync(d);
     if (mustThrow) {
       throw new ArgumentNullException();
     }
   }
   catch (AggregateException ae) {
     if (ae.InnerException is ArgumentException) {
       if (!mustThrow){
         throw;
       }
     }
     else {
       throw;
     }
   }
 }
Exemple #8
0
        public async Task <IEnumerable <int> > TPTest <T, Q>(T[] values, Q value, int limit)
            where Q : T
        {
            Contract.Requires(values != null);
            Contract.Requires(Contract.ForAll(0, values.Length, i => !values[i].Equals(value)));
            Contract.Ensures(Contract.ForAll(Contract.Result <Task <IEnumerable <int> > >().Result, i => i < limit && Contract.Result <Task <IEnumerable <int> > >() != null));
            Contract.EnsuresOnThrow <ArgumentException>(limit == 10);

            if (values.Length == 3)
            {
                throw new ArgumentException();
            }

            var x = await NonGen.CountThem(values, value);

            if (x == 5)
            {
                throw new ArgumentException();
            }

            return(GetValues(x, limit));
        }
        void TestMe(NonGen g, int limit, bool mustThrow)
        {
            try {
                var z = g.FooAsync(limit);

                foreach (var i in z.Result)
                {
                    Console.WriteLine("Result = {0}", i);
                }

                if (mustThrow)
                {
                    throw new Exception("failed to throw");
                }
            }
            catch (AggregateException ae) {
                if (!mustThrow)
                {
                    throw;
                }
            }
        }