public void OnEngineClosed() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine = new VsaEngine(); engine.RootMoniker = "com.foo://path/to/nowhere"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; engine.Close(); int size; try { size = items.Count; } catch (VsaException e) { Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#1"); } try { item = items.CreateItem("itemx", VsaItemType.Code, VsaItemFlag.Class); } catch (VsaException e) { Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#2"); } }
// inititalize engine public void createVsaEngine() { vsaEngine = new VsaEngine(); vsaEngine.RootMoniker = "ScriptGlobals://JScript"; vsaEngine.Site = this; vsaEngine.InitNew(); vsaEngine.RootNamespace = "emu"; // add system references IVsaReferenceItem refItem = (IVsaReferenceItem)vsaEngine.Items.CreateItem("mscorlib", VsaItemType.Reference, VsaItemFlag.None); refItem.AssemblyName = "mscorlib.dll"; refItem = (IVsaReferenceItem)vsaEngine.Items.CreateItem("system", VsaItemType.Reference, VsaItemFlag.None); refItem.AssemblyName = "System.dll"; //// add propertybag for script variables //IVsaGlobalItem item = (IVsaGlobalItem)vsaEngine.Items.CreateItem("oldvars", VsaItemType.AppGlobal, VsaItemFlag.None); //item.TypeString = "System.Collections.HashTable"; //globalItemLookupTable["oldvars"] = scriptVariables; // add object for eval results IVsaGlobalItem item = (IVsaGlobalItem)vsaEngine.Items.CreateItem("scrEvalResult", VsaItemType.AppGlobal, VsaItemFlag.None); item.TypeString = evalResult.GetType().FullName; globalItemLookupTable["scrEvalResult"] = evalResult; vsaEngine.GenerateDebugInfo = false; VSAEngineCreated = true; }
public void OnItemFlagNotSupported() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine = new VsaEngine(); engine.RootMoniker = "com.foo://path/to/nowhere"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; try { item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.Class); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemFlagNotSupported, e.ErrorCode, "#8"); } try { item = items.CreateItem("item2", VsaItemType.Reference, VsaItemFlag.Module); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemFlagNotSupported, e.ErrorCode, "#9"); } try { item = items.CreateItem("item3", VsaItemType.AppGlobal, VsaItemFlag.Class); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemFlagNotSupported, e.ErrorCode, "#10"); } try { item = items.CreateItem("item4", VsaItemType.AppGlobal, VsaItemFlag.Module); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemFlagNotSupported, e.ErrorCode, "#11"); } }
public void OnItemNotFound() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine = new VsaEngine(); engine.RootMoniker = "com.foo://path/to/nowhere"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; try { item = items [-1]; } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#3"); } try { item = items [20]; } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#4"); } try { item = items ["IamNotHere"]; } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#5"); } try { items.Remove(20); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#6"); } try { items.Remove(-1); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#7"); } }
public void SetOptionOnOptionNotSupported() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine.RootMoniker = "foo://nowhere/path"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); try { item.SetOption("OptionNotSupportedByThisScriptingEngine", true); } catch (VsaException e) { Assert.AreEqual(VsaError.OptionNotSupported, e.ErrorCode, "#9"); } }
public void IsDirtyOnCreateItem() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine.RootMoniker = "foo://nowhere/path"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); Assert.AreEqual(true, item.IsDirty, "#2"); item = items.CreateItem("item2", VsaItemType.AppGlobal, VsaItemFlag.None); Assert.AreEqual(true, item.IsDirty, "#3"); item = items.CreateItem("item3", VsaItemType.Code, VsaItemFlag.Module); Assert.AreEqual(true, item.IsDirty, "#4"); }
public void IsDirtyOnEngineClosed() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine.RootMoniker = "foo://nowhere/path"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); engine.Close(); try { bool dirty = item.IsDirty; } catch (VsaException e) { Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#1"); } }
public void CreateItemOnRepeatedName() { VsaEngine engine = new VsaEngine(); IVsaItems items; engine = new VsaEngine(); engine.RootMoniker = "com.foo://path/to/nowhere"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; items.CreateItem("item2", VsaItemType.AppGlobal, VsaItemFlag.None); try { items.CreateItem("item2", VsaItemType.Reference, VsaItemFlag.None); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNameInUse, e.ErrorCode, "#20"); } }
public void Retrieve() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine = new VsaEngine(); engine.RootMoniker = "com.foo://path/to/nowhere"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); items.CreateItem("item2", VsaItemType.AppGlobal, VsaItemFlag.None); items.CreateItem("item3", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item4", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item5", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item6", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item7", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item8", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item9", VsaItemType.Code, VsaItemFlag.Module); items.CreateItem("item10", VsaItemType.Code, VsaItemFlag.Module); item = items [2]; Assert.AreEqual("item3", item.Name, "#16"); items.Remove("item6"); Assert.AreEqual("item7", items [5].Name, "#17"); try { items.Remove("itemNonExistent"); } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#18"); } items.Remove(3); Assert.AreEqual("item5", items [3].Name, "#19"); }
public void GetOptionOnEngineClosed() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine.RootMoniker = "foo://nowhere/path"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); engine.Close(); try { object opt = item.GetOption("AlwaysGenerateIL"); } catch (VsaException e) { Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#6"); } }
public void Remove() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine = new VsaEngine(); engine.RootMoniker = "com.foo://path/to/nowhere"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); items.CreateItem("item2", VsaItemType.AppGlobal, VsaItemFlag.None); items.CreateItem("item3", VsaItemType.Code, VsaItemFlag.Module); Assert.AreEqual(3, items.Count, "#12"); try { item = items [4]; } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#13"); } string ERASED_ITEM = "item2"; items.Remove(ERASED_ITEM); Assert.AreEqual(2, items.Count, "#14"); try { item = items [ERASED_ITEM]; } catch (VsaException e) { Assert.AreEqual(VsaError.ItemNotFound, e.ErrorCode, "#15"); } }