public void ScopeFactoryTypesTest() { IScopeFactory factory = new DefaultImplementations.ScopeFactory(); IExecutionScope scope = factory.MakeScope(); Assert.IsTrue(scope.Contains("FirstType")); Assert.IsTrue(scope.IsOfType <Type>("FirstType")); Type t = scope["FirstType"] as Type; Assert.IsNotNull(t); Assert.AreEqual(typeof(FirstType), t); Assert.IsFalse(scope.Contains("SecondType")); Assert.IsTrue(scope.Contains("Another")); Assert.IsTrue(scope.IsOfType <Type>("Another")); t = scope["Another"] as Type; Assert.IsNotNull(t); Assert.AreEqual(typeof(SecondType), t); Assert.IsFalse(scope.Contains("ThirdType")); Assert.IsTrue(scope.Contains("Int32")); Assert.IsTrue(scope.IsOfType <Type>("Int32")); t = scope["Int32"] as Type; Assert.IsNotNull(t); Assert.AreEqual(typeof(int), t); Assert.IsFalse(scope.Contains("FouthType")); Assert.IsTrue(scope.Contains("BoolType")); Assert.IsTrue(scope.IsOfType <Type>("BoolType")); t = scope["BoolType"] as Type; Assert.IsNotNull(t); Assert.AreEqual(typeof(bool), t); Assert.IsFalse(scope.Contains("StringLink")); Assert.IsTrue(scope.Contains("String")); Assert.IsTrue(scope.IsOfType <Type>("String")); t = scope["String"] as Type; Assert.IsNotNull(t); Assert.AreEqual(typeof(string), t); Assert.IsTrue(scope.Contains("cr:String")); IConstantReader cr = scope["cr:String"] as IConstantReader; Assert.IsNotNull(cr); object res; Assert.IsTrue(cr.TryRead("\"test\"", out res)); Assert.AreEqual("test", res); }
public void ScopeFactoryCallsTest() { IScopeFactory factory = new DefaultImplementations.ScopeFactory(); IExecutionScope scope = factory.MakeScope(); Assert.IsTrue(scope.Contains("firstMethod")); Assert.IsTrue(scope.IsOfType <MethodInfo>("firstMethod")); var method = scope["firstMethod"] as MethodInfo; Assert.IsNotNull(method); Assert.AreEqual("OK", method.Invoke(null, new object[0])); Assert.IsFalse(scope.Contains("secondMethod")); Assert.IsTrue(scope.Contains("second")); Assert.IsTrue(scope.IsOfType <MethodInfo>("second")); method = scope["second"] as MethodInfo; Assert.IsNotNull(method); Assert.AreEqual("OKI", method.Invoke(null, new object[0])); }