public void RefAndOutParameter() { int x = 5; int y; ClassWithStaticMethods.RefAndOutParameter(ref x, out y); QUnit.AreEqual(x, 6); QUnit.AreEqual(y, 10); }
public void CanSeeChangesToClosedVariable() { var i = 0; Action action = () => i = i + 1; i = 1; action(); QUnit.AreEqual(i, 2); }
public void ArrayCopy() { var array = new[] { "1", "2", "3" }; var newArray = new string[2]; array.CopyTo(newArray, 1); QUnit.AreEqual(newArray[0], "2"); QUnit.AreEqual(newArray[1], "3"); }
public void TwoOutParameters() { string x; string y; ClassWithStaticMethods.TwoOutParameters(out x, out y); QUnit.AreEqual(x, "foo1"); QUnit.AreEqual(y, "foo2"); }
public void MethodDelegate() { var methodClass = new MethodClass("foo"); Func <string> methodDelegate = methodClass.M; var s = methodDelegate(); QUnit.AreEqual(s, "foo"); QUnit.AreEqual(methodDelegate.Target, methodClass); }
public void TwoRefParameters() { int x = 5; int y = 6; ClassWithStaticMethods.TwoRefParameters(ref x, ref y); QUnit.AreEqual(x, 6); QUnit.AreEqual(y, 12); }
public void TryFinally() { var ints = YieldClass.TryFinally().ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 2); QUnit.AreEqual(ints[2], 3); }
public void LastIndexOf() { var s = "12341234"; QUnit.AreEqual(s.LastIndexOf("2"), 5); QUnit.AreEqual(s.LastIndexOf("2", 4), 1); QUnit.AreEqual(s.LastIndexOf('2'), 5); QUnit.AreEqual(s.LastIndexOf('2', 4), 1); }
public void LabeledStatementGotoSecond() { var ints = YieldClass.LabeledStatementGotoSecond().ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 2); QUnit.AreEqual(ints[2], 3); }
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 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 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 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 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 GetFields() { var fields = typeof(FieldsClass).GetFields(); QUnit.AreEqual(fields.Length, 1); var field = fields[0]; QUnit.AreEqual(field.Name, "MyString"); }
public void Nested() { var o = new OnePropertyClass { NestedProperty = new OnePropertyClass { MyProperty = "foo" } }; QUnit.AreEqual(o.NestedProperty.MyProperty, "foo"); }
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 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 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 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 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 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 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 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 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 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 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 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 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); }