Пример #1
0
        public void Name()
        {
            var methods = typeof(MethodClass).GetMethods();
            var method  = methods.Single(x => x.Name == "VoidMethod");

            QUnit.IsTrue(true);
        }
Пример #2
0
        public void Visibility()
        {
            var type                   = typeof(FieldClass);
            var fields                 = type.GetFields();
            var stringField            = fields.Single(x => x.Name == "StringField");
            var intField               = fields.Single(x => x.Name == "IntField");
            var staticField            = fields.Single(x => x.Name == "StaticField");
            var protectedField         = fields.Single(x => x.Name == "ProtectedField");
            var privateField           = fields.Single(x => x.Name == "PrivateField");
            var internalField          = fields.Single(x => x.Name == "InternalField");
            var protectedInternalField = fields.Single(x => x.Name == "ProtectedInternalField");
            var readonlyField          = fields.Single(x => x.Name == "ReadonlyField");
            var constantField          = fields.Single(x => x.Name == "ConstantField");

            QUnit.IsTrue(stringField.IsPublic);
            QUnit.IsTrue(intField.IsPublic);
            QUnit.IsTrue(staticField.IsPublic);
            QUnit.IsTrue(staticField.IsStatic);
            QUnit.IsTrue(protectedField.IsFamily);
            QUnit.IsTrue(!protectedField.IsPublic);
            QUnit.IsTrue(privateField.IsPrivate);
            QUnit.IsTrue(!privateField.IsPublic);
            QUnit.IsTrue(internalField.IsAssembly);
            QUnit.IsTrue(!internalField.IsPublic);
            QUnit.IsTrue(!protectedInternalField.IsPublic);
            QUnit.IsTrue(protectedInternalField.IsFamilyOrAssembly);
            QUnit.IsTrue(readonlyField.IsInitOnly);
            QUnit.IsTrue(constantField.IsLiteral);
        }
Пример #3
0
        public void TypeByNameIgnoreCase()
        {
            var assembly = AppDomain.CurrentDomain.GetAssemblies().Last();
            var type     = assembly.GetType("WOOTZJS.COMPILER.TESTS.REFLECTION.ASSEMBLYTESTS.TESTCLASS", false, true);

            QUnit.IsTrue(type != null);
        }
Пример #4
0
        public void TypeByName()
        {
            var assembly = AppDomain.CurrentDomain.GetAssemblies().Last();
            var type     = assembly.GetType("WootzJs.Compiler.Tests.Reflection.AssemblyTests.TestClass");

            QUnit.IsTrue(type != null);
        }
Пример #5
0
        public void SequenceEqual()
        {
            var ints1 = new[] { 1, 2, 3 };
            var ints2 = new[] { 1, 2, 3 };

            QUnit.IsTrue(ints1.SequenceEqual(ints2));
        }
Пример #6
0
        public void ContainsKey()
        {
            var dictionary = new Dictionary <string, int>();

            dictionary.Add("one", 1);
            QUnit.IsTrue(dictionary.ContainsKey("one"));
            QUnit.IsTrue(!dictionary.ContainsKey("two"));
        }
Пример #7
0
        public void Contains()
        {
            IEnumerable <string> values = new[] { "one", "two", "three" };

            QUnit.IsTrue(values.Contains("one"));
            QUnit.IsTrue(values.Contains("two"));
            QUnit.IsTrue(values.Contains("three"));
        }
Пример #8
0
        public void Property()
        {
            Expression <Func <ClassWithMembers, string> > lambda = x => x.StringProperty;
            var memberExpression = (MemberExpression)lambda.Body;

            QUnit.AreEqual(memberExpression.Expression, lambda.Parameters[0]);
            QUnit.IsTrue(memberExpression.Member is PropertyInfo);
            QUnit.AreEqual(memberExpression.Member.Name, "StringProperty");
        }
Пример #9
0
        public void OnNext()
        {
            var  subject = new Subject <TestEvent>();
            bool flagged = false;

            subject.Subscribe(x => flagged = true);
            subject.OnNext(new TestEvent());
            QUnit.IsTrue(flagged);
        }
Пример #10
0
        public void Keys()
        {
            var dictionary = new Dictionary <string, int>();

            dictionary.Add("one", 1);
            dictionary.Add("two", 2);
            var keys = dictionary.Keys.ToArray();

            QUnit.IsTrue(keys[0] == "one" || keys[1] == "one");
            QUnit.IsTrue(keys[0] == "two" || keys[1] == "two");
        }
Пример #11
0
        public void Contains()
        {
            var list = new List <string>();

            list.Add("one");
            list.Add("two");
            list.Add("three");
            QUnit.IsTrue(list.Contains("one"));
            QUnit.IsTrue(list.Contains("two"));
            QUnit.IsTrue(list.Contains("three"));
            QUnit.IsTrue(!list.Contains("four"));
        }
Пример #12
0
        public void PeekEmpty()
        {
            var queue = new Queue <string>();

            try
            {
                queue.Peek();
                QUnit.IsTrue(false);
            }
            catch (Exception e)
            {
                QUnit.IsTrue(true);
            }
        }
Пример #13
0
        public void PeekEmpty()
        {
            var stack = new Stack <string>();

            try
            {
                stack.Peek();
                QUnit.IsTrue(false);
            }
            catch (Exception e)
            {
                QUnit.IsTrue(true);
            }
        }
Пример #14
0
        public void TypeByNameThrowsOnNotFound()
        {
            var assembly = AppDomain.CurrentDomain.GetAssemblies().Last();

            try
            {
                var type = assembly.GetType("WootzJs.Compiler.Tests.Reflection.AssemblyTests.InvalidClass", true);
                QUnit.IsTrue(false);
            }
            catch (Exception e)
            {
                QUnit.IsTrue(true);
            }
        }
Пример #15
0
        public void SingleThrowsWhenContainsMany()
        {
            var ints1 = new[] { 1, 2 };

            try
            {
                var int1 = ints1.Single();
                QUnit.IsTrue(false);
            }
            catch (Exception e)
            {
                QUnit.IsTrue(true);
            }
        }
Пример #16
0
        public void SingleThrowsWhenEmpty()
        {
            var ints1 = new int[0];

            try
            {
                var int1 = ints1.Single();
                QUnit.IsTrue(false);
            }
            catch (Exception e)
            {
                QUnit.IsTrue(true);
            }
        }
Пример #17
0
        public void Empty()
        {
            var enumerator = Enumerable.Empty <string>().GetEnumerator();

            QUnit.IsTrue(!enumerator.MoveNext());
        }