public void ForLoopTwoVariablesTwoIncrementors() { var ints = YieldClass.ForLoopTwoVariablesTwoIncrementors().ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 3); QUnit.AreEqual(ints[2], 5); }
public void ForLoop() { var ints = YieldClass.ForLoop().ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 0); QUnit.AreEqual(ints[1], 1); QUnit.AreEqual(ints[2], 2); }
public void ForLoopNoVariableNoInitializerNoIncrementor() { var ints = YieldClass.ForLoopNoVariableNoInitializerNoIncrementor().ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 0); QUnit.AreEqual(ints[1], 1); QUnit.AreEqual(ints[2], 2); }
public void SwitchThree() { var ints = YieldClass.Switch("three").ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 2); QUnit.AreEqual(ints[2], 3); }
public void TestClass() { object o = new MyClass(); var myClass = o as MyClass; QUnit.IsTrue(myClass is MyClass); QUnit.IsTrue(myClass is object); QUnit.IsTrue(!(myClass is string)); }
public void Foreach() { var strings = YieldClass.Foreach().ToArray(); QUnit.AreEqual(strings.Length, 3); QUnit.AreEqual(strings[0], "one"); QUnit.AreEqual(strings[1], "two"); QUnit.AreEqual(strings[2], "three"); }
public void Nested() { var o = new OnePropertyClass { NestedProperty = new OnePropertyClass { MyProperty = "foo" } }; QUnit.AreEqual(o.NestedProperty.MyProperty, "foo"); }
public void Foreach() { var s = "1234"; var chars = s.ToArray(); QUnit.AreEqual(chars[0], '1'); QUnit.AreEqual(chars[1], '2'); QUnit.AreEqual(chars[2], '3'); QUnit.AreEqual(chars[3], '4'); }
public void ConstructorsWithOverloads() { var test1 = new TestClass(); var test2 = new TestClass("foo"); var test3 = new TestClass(5); QUnit.AreEqual(test1.Arg1, "none"); QUnit.AreEqual(test2.Arg1, "string"); QUnit.AreEqual(test3.Arg1, "int"); }
public void Override() { var baseClass = new BaseClass(); var subClass = new SubClass(); BaseClass subClassAsBaseClass = subClass; QUnit.AreEqual(baseClass.Foo(), "base"); QUnit.AreEqual(subClass.Foo(), "sub"); QUnit.AreEqual(subClassAsBaseClass.Foo(), "sub"); }
public void SplitCharArrayWithCount() { var s = "12a34b56c78"; var parts = s.Split(new[] { 'a', 'b', 'c' }, 3); QUnit.AreEqual(parts.Length, 3); QUnit.AreEqual(parts[0], "12"); QUnit.AreEqual(parts[1], "34"); QUnit.AreEqual(parts[2], "56"); }
public void TopLevelGenericClasses() { var stringClass = new TopLevelGenericClass <string>(); var intClass = new TopLevelGenericClass <int>(); var simpleClass = new TopLevelGenericClass <SimpleClass>(); QUnit.AreEqual(stringClass.GetName(), "String"); QUnit.AreEqual(intClass.GetName(), "Int32"); QUnit.AreEqual(simpleClass.GetName(), "SimpleClass"); }
public void IndexOf() { var s = "12341234"; String two = "2"; QUnit.AreEqual(s.IndexOf(two), 1); QUnit.AreEqual(s.IndexOf("2", 4), 5); QUnit.AreEqual(s.IndexOf('2'), 1); QUnit.AreEqual(s.IndexOf('2', 4), 5); }
public void Declaration() { Foo _foo; using (var foo = new Foo()) { _foo = foo; } QUnit.IsTrue(_foo.IsDisposed); }
public void CollidingFor() { var ints = YieldClass.CollidingForeach().ToArray(); QUnit.AreEqual(ints.Length, 4); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 2); QUnit.AreEqual(ints[2], 3); QUnit.AreEqual(ints[3], 4); }
public void SimpleLambda() { var myClass = new MyClass { Name = "foo" }; var lambda = myClass.CreateLambda(); var name = lambda(); QUnit.AreEqual(name, "foo"); }
public void ReturnAfterIfTrue() { var strings = YieldClass.ReturnAfterIf(true).ToArray(); QUnit.AreEqual(strings.Length, 5); QUnit.AreEqual(strings[0], "zero"); QUnit.AreEqual(strings[1], "one"); QUnit.AreEqual(strings[2], "two"); QUnit.AreEqual(strings[3], "five"); QUnit.AreEqual(strings[4], "six"); }
public void CollisionImplementationOneExplicit() { var o = new CollisionImplementationOneExplicit(); ITestInterface test = o; ITestInterface2 test2 = o; var s = test.Method(); var s2 = test2.Method(); QUnit.AreEqual(s, "ITestInterface"); QUnit.AreEqual(s2, "ITestInterface2"); }
public void Casts() { object o = null; o = (int)o; o = (string)o; o = (int[])o; o = (float[])o; o = (bool[])o; QUnit.IsTrue(true); }
public void ReturnAfterIfFalse() { var strings = YieldClass.ReturnAfterIf(false).ToArray(); QUnit.AreEqual(strings.Length, 5); QUnit.AreEqual(strings[0], "zero"); QUnit.AreEqual(strings[1], "three"); QUnit.AreEqual(strings[2], "four"); QUnit.AreEqual(strings[3], "five"); QUnit.AreEqual(strings[4], "six"); }
public void SplitCharArray() { var s = "12a34b56c78"; var parts = s.Split('a', 'b', 'c'); QUnit.AreEqual(parts.Length, 4); QUnit.AreEqual(parts[0], "12"); QUnit.AreEqual(parts[1], "34"); QUnit.AreEqual(parts[2], "56"); QUnit.AreEqual(parts[3], "78"); }
public void MulticastEventKeepsDelegateType() { var i = 0; var eventClass = new EventClass(); eventClass.Foo += () => i++; eventClass.Foo += () => i++; var action = eventClass.GetFoo(); QUnit.IsTrue(action is Action); }
public void NamedArguments() { var result = ClassWithStaticMethods.Add(one: 1, two: 2, three: 3, four: 4); QUnit.AreEqual(result, 4321); result = ClassWithStaticMethods.Add(two: 1, three: 2, four: 3); QUnit.AreEqual(result, 3210); result = ClassWithStaticMethods.Add(four: 1, three: 2, two: 3, one: 4); QUnit.AreEqual(result, 1234); }
public void NakedCatchClause() { try { throw new Exception(); QUnit.IsTrue(false); } catch { QUnit.IsTrue(true); } }
public void CreateDate() { var date = new DateTime(2014, 1, 2, 15, 3, 5, 30); QUnit.AreEqual(date.Year, 2014); QUnit.AreEqual(date.Month, 1); QUnit.AreEqual(date.Day, 2); QUnit.AreEqual(date.Hour, 15); QUnit.AreEqual(date.Minute, 3); QUnit.AreEqual(date.Second, 5); QUnit.AreEqual(date.Millisecond, 30); }
public void MulticastEvent() { var o = new EventClass(); var success1 = false; var success2 = false; o.Foo += () => success1 = true; o.Foo += () => success2 = true; o.OnFoo(); QUnit.IsTrue(success1); QUnit.IsTrue(success2); }
public void LabeledStatementGotoFirst() { var ints = YieldClass.LabeledStatementGotoFirst(true).ToArray(); QUnit.AreEqual(ints.Length, 1); QUnit.AreEqual(ints[0], 1); ints = YieldClass.LabeledStatementGotoFirst(false).ToArray(); QUnit.AreEqual(ints.Length, 2); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 2); }
public void MethodTargets() { var methodClass1 = new MethodClass("foo1"); var methodClass2 = new MethodClass("foo2"); Func <string> delegate1 = methodClass1.M; Func <string> delegate2 = methodClass2.M; QUnit.AreEqual(delegate1(), "foo1"); QUnit.AreEqual(delegate2(), "foo2"); QUnit.AreEqual(delegate1.Target, methodClass1); QUnit.AreEqual(delegate2.Target, methodClass2); }
public void FormatException() { try { int.Parse("a"); QUnit.IsTrue(false); } catch (FormatException e) { QUnit.IsTrue(true); } }
public void ExceptionCaught() { try { throw new Exception(); QUnit.IsTrue(false); } catch (Exception e) { QUnit.IsTrue(true); } }