public void Name() { var methods = typeof(MethodClass).GetMethods(); var method = methods.Single(x => x.Name == "VoidMethod"); QUnit.IsTrue(true); }
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); }
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); }
public void TypeByName() { var assembly = AppDomain.CurrentDomain.GetAssemblies().Last(); var type = assembly.GetType("WootzJs.Compiler.Tests.Reflection.AssemblyTests.TestClass"); QUnit.IsTrue(type != null); }
public void SequenceEqual() { var ints1 = new[] { 1, 2, 3 }; var ints2 = new[] { 1, 2, 3 }; QUnit.IsTrue(ints1.SequenceEqual(ints2)); }
public void ContainsKey() { var dictionary = new Dictionary <string, int>(); dictionary.Add("one", 1); QUnit.IsTrue(dictionary.ContainsKey("one")); QUnit.IsTrue(!dictionary.ContainsKey("two")); }
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")); }
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"); }
public void OnNext() { var subject = new Subject <TestEvent>(); bool flagged = false; subject.Subscribe(x => flagged = true); subject.OnNext(new TestEvent()); QUnit.IsTrue(flagged); }
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"); }
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")); }
public void PeekEmpty() { var queue = new Queue <string>(); try { queue.Peek(); QUnit.IsTrue(false); } catch (Exception e) { QUnit.IsTrue(true); } }
public void PeekEmpty() { var stack = new Stack <string>(); try { stack.Peek(); QUnit.IsTrue(false); } catch (Exception e) { QUnit.IsTrue(true); } }
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); } }
public void SingleThrowsWhenContainsMany() { var ints1 = new[] { 1, 2 }; try { var int1 = ints1.Single(); QUnit.IsTrue(false); } catch (Exception e) { QUnit.IsTrue(true); } }
public void SingleThrowsWhenEmpty() { var ints1 = new int[0]; try { var int1 = ints1.Single(); QUnit.IsTrue(false); } catch (Exception e) { QUnit.IsTrue(true); } }
public void Empty() { var enumerator = Enumerable.Empty <string>().GetEnumerator(); QUnit.IsTrue(!enumerator.MoveNext()); }