public void GenericExtensionMethodOnClosedGenericType2() { var options = new Options(); options.AddExtensionMethods(typeof(ObservableExtensions)); var engine = new Engine(options); NameObservable observable = new NameObservable(); observable.Where((text) => { System.Console.WriteLine("GenericExtensionMethodOnClosedGenericType2: NameObservable: Where: text: " + text); return(true); }); engine.SetValue("observable", observable); var result = engine.Evaluate(@" var result = observable.Where(function(text){ return true; }); observable.UpdateName('testing yo'); observable.CommitName(); return result; "); var nameObservableResult = result.ToObject() as NameObservable; Assert.NotNull(nameObservableResult); Assert.Equal("testing yo", nameObservableResult.Last); }
public void GenericTypeExtension() { var options = new Options(); options.AddExtensionMethods(typeof(ObservableExtensions)); var engine = new Engine(options); engine.SetValue("log", new System.Action <object>(System.Console.WriteLine)); NameObservable observable = new NameObservable(); engine.SetValue("observable", observable); engine.Evaluate(@" log('before'); observable.Subscribe((name) =>{ log('observable: subscribe: name: ' + name); }); observable.UpdateName('foobar'); log('after'); "); Assert.Equal("foobar", observable.Last); }
public void GenericExtensionMethodOnClosedGenericType() { var options = new Options(); options.AddExtensionMethods(typeof(ObservableExtensions)); var engine = new Engine(options); engine.SetValue("log", new System.Action <object>(System.Console.WriteLine)); NameObservable observable = new NameObservable(); engine.SetValue("observable", observable); var result = engine.Evaluate(@" log('before calling Select'); var result = observable.Select('some text'); log('result: ' + result); return result; "); //System.Console.WriteLine("GenericExtensionMethodOnGenericType: result: " + result + " result.ToString(): " + result.ToString()); Assert.Equal("some text", result); }