예제 #1
0
        public void String()
        {
            var s = "foo";

            QUnit.IsTrue(s is string);
            QUnit.IsTrue(!(s is int));
        }
예제 #2
0
        public void GetEnumerator()
        {
            var array = new[] { 1, 2, 3 };

            array.GetEnumerator();
            QUnit.IsTrue(true);     // Just making sure the method is present
        }
예제 #3
0
        public void IsAssignableFrom()
        {
            var subClass  = typeof(SubClass);
            var baseClass = typeof(TestClass);

            QUnit.IsTrue(baseClass.IsAssignableFrom(subClass));
        }
예제 #4
0
 public void IsDigit()
 {
     QUnit.IsTrue(char.IsDigit('0'));
     QUnit.IsTrue(char.IsDigit('3'));
     QUnit.IsTrue(char.IsDigit('9'));
     QUnit.IsTrue(!char.IsDigit('a'));
 }
예제 #5
0
        public void IsInstanceOfType()
        {
            var subClass  = new SubClass();
            var baseClass = typeof(TestClass);

            QUnit.IsTrue(baseClass.IsInstanceOfType(subClass));
        }
예제 #6
0
        public void TestClass()
        {
            var o = new MyClass();

            QUnit.IsTrue(o is MyClass);
            QUnit.IsTrue(o is object);
            QUnit.IsTrue(!(o is string));
        }
예제 #7
0
        public void IntTryParse()
        {
            var s = "1";
            int i;

            QUnit.IsTrue(int.TryParse(s, out i));
            QUnit.AreEqual(i, 1);
        }
예제 #8
0
 public void IsWhiteSpace()
 {
     QUnit.IsTrue(char.IsWhiteSpace(' '));
     QUnit.IsTrue(char.IsWhiteSpace('\t'));
     QUnit.IsTrue(char.IsWhiteSpace('\r'));
     QUnit.IsTrue(char.IsWhiteSpace('\n'));
     QUnit.IsTrue(!char.IsWhiteSpace('a'));
 }
예제 #9
0
        public void String()
        {
            object o = "foo";
            var    s = o as string;

            QUnit.IsTrue(s is string);
            QUnit.IsTrue(!(s is int));
        }
예제 #10
0
        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));
        }
예제 #11
0
        public void SimpleUsing()
        {
            var foo = new Foo();

            using (foo)
            {
            }
            QUnit.IsTrue(foo.IsDisposed);
        }
예제 #12
0
        public void BasicEventExplicitThis()
        {
            var o       = new EventClass();
            var success = false;

            o.FooThis += () => success = true;
            o.OnFooThis();
            QUnit.IsTrue(success);
        }
예제 #13
0
        public void Declaration()
        {
            Foo _foo;

            using (var foo = new Foo())
            {
                _foo = foo;
            }
            QUnit.IsTrue(_foo.IsDisposed);
        }
예제 #14
0
        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);
        }
예제 #15
0
        public void Casts()
        {
            object o = null;

            o = (int)o;
            o = (string)o;
            o = (int[])o;
            o = (float[])o;
            o = (bool[])o;
            QUnit.IsTrue(true);
        }
예제 #16
0
 public void FormatException()
 {
     try
     {
         int.Parse("a");
         QUnit.IsTrue(false);
     }
     catch (FormatException e)
     {
         QUnit.IsTrue(true);
     }
 }
예제 #17
0
 public void NakedCatchClause()
 {
     try
     {
         throw new Exception();
         QUnit.IsTrue(false);
     }
     catch
     {
         QUnit.IsTrue(true);
     }
 }
예제 #18
0
 public void ExceptionCaught()
 {
     try
     {
         throw new Exception();
         QUnit.IsTrue(false);
     }
     catch (Exception e)
     {
         QUnit.IsTrue(true);
     }
 }
예제 #19
0
        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);
        }
예제 #20
0
        public void MulticastEventRemove()
        {
            var    o        = new EventClass();
            var    success1 = false;
            var    success2 = false;
            Action foo1     = () => success1 = true;

            o.Foo += foo1;
            o.Foo += () => success2 = true;
            o.Foo -= foo1;
            o.OnFoo();
            QUnit.IsTrue(!success1);
            QUnit.IsTrue(success2);
        }
예제 #21
0
        public void EventAccessor()
        {
            var    eventClass = new EventClass();
            var    ran        = false;
            Action evt        = () => ran = true;

            eventClass.Bar += evt;
            eventClass.OnBar();
            QUnit.IsTrue(ran);

            ran             = false;
            eventClass.Bar -= evt;
            eventClass.OnBar();
            QUnit.IsTrue(!ran);
        }
예제 #22
0
        public void TryFinallyThrowsException()
        {
            var enumerator = YieldClass.TryFinallyThrowsException(true).GetEnumerator();

            QUnit.IsTrue(enumerator.MoveNext());
            QUnit.AreEqual(enumerator.Current, 1);
            try
            {
                enumerator.MoveNext();
                QUnit.IsTrue(false);
            }
            catch (Exception)
            {
                QUnit.IsTrue(true);
            }
        }
예제 #23
0
        public void RemoveMethodHandler()
        {
            var eventClass    = new EventClass();
            var eventHandlers = new EventHandlers();

            eventClass.Foo += eventHandlers.M1;
            eventClass.Foo += eventHandlers.M2;
            eventClass.OnFoo();

            QUnit.AreEqual(eventHandlers.m1, "M1");
            QUnit.AreEqual(eventHandlers.m2, "M2");

            eventHandlers.m1 = null;
            eventHandlers.m2 = null;
            eventClass.Foo  -= eventHandlers.M1;
            eventClass.OnFoo();

            QUnit.AreEqual(eventHandlers.m2, "M2");
            QUnit.IsTrue(eventHandlers.m1 == null);
        }
예제 #24
0
        public void FinallyExecuted()
        {
            bool success = false;

            try
            {
                try
                {
                    throw new Exception();
                }
                finally
                {
                    success = true;
                }
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch (Exception e)
            {
            }
            QUnit.IsTrue(success);
        }
예제 #25
0
        public void StartsWith()
        {
            var s = "HelloWorld";

            QUnit.IsTrue(s.StartsWith("Hello"));
        }
예제 #26
0
        public void EndsWith()
        {
            var s = "HelloWorld";

            QUnit.IsTrue(s.EndsWith("World"));
        }
예제 #27
0
 public void ExportArray()
 {
     Jsni.reference("window").memberset("ExportTest", Jsni.@object(new { Values = Jsni.array() }));
     ExportTest.Values[0] = Tuple.Create("foo", 1);
     QUnit.IsTrue(ExportTest.Values is Tuple <string, int>[]);
 }
예제 #28
0
        public void Contains()
        {
            var s = "hello world";

            QUnit.IsTrue(s.Contains("world"));
        }
예제 #29
0
        public void ThreeFlags()
        {
            var oneAndTwo = FlagsEnum.One | FlagsEnum.Two | FlagsEnum.Three;

            QUnit.IsTrue((oneAndTwo & FlagsEnum.One) == FlagsEnum.One);
        }
예제 #30
0
        public void GetTypeByName()
        {
            var type = Type.GetType("WootzJs.Compiler.Tests.TypeTests.TestClass");

            QUnit.IsTrue(type != null);
        }