Esempio n. 1
0
        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");
            }
        }
Esempio n. 2
0
        // 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;
        }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
        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");
            }
        }
Esempio n. 5
0
        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");
            }
        }
Esempio n. 6
0
        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");
        }
Esempio n. 7
0
        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");
            }
        }
Esempio n. 8
0
        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");
            }
        }
Esempio n. 9
0
        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");
        }
Esempio n. 10
0
        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");
            }
        }
Esempio n. 11
0
        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");
            }
        }