Пример #1
0
 public void BundleCategoriesAddRangeTest()
 {
     var testCategory = new ToolCategory("Test", "0.0.0.1");
     var categoryToAdd = new ToolCategory("Test2", "0.0.0.1");
     ToolBundle bundle = new ToolBundle("TestBundle", "0.0.0.1");
     Assert.AreEqual(bundle.Categories.Count, 0);
     bundle.Categories.Add(categoryToAdd, testCategory);
     Assert.AreEqual(bundle.Categories.Count, 2);
 }
Пример #2
0
 public void CategoryInstanceTests()
 {
     ToolCategory category = new ToolCategory("SysInternals", "0.0.0.1");
     Assert.IsNotNull(category);
     Assert.AreNotEqual(category.ID, Guid.Empty);
     Assert.AreEqual(category.Name, "SysInternals");
     Assert.AreEqual(category.Version, "0.0.0.1");
     Assert.IsNotNull(category.Tools);
     Assert.AreEqual(category.Tools.Count, 0);
 }
Пример #3
0
        public void BundleCategoriesIndexerTest()
        {
            var testCategory = new ToolCategory("Test", "0.0.0.0");
            var categoryToAdd = new ToolCategory("Test2", "0.0.0.0");
            ToolBundle bundle = new ToolBundle("TestBundle", "0.0.0.0");
            bundle.Categories.Add(categoryToAdd, testCategory);
            Assert.AreEqual(bundle.Categories.Count, 2);

            var categoryByTestIndex = bundle.Categories["Test"];
            Assert.AreEqual(categoryByTestIndex.FirstOrDefault(), testCategory);

            var isRemoved = bundle.Categories.Remove(testCategory);
            Assert.AreEqual(isRemoved, true);
            Assert.AreEqual(bundle.Categories.Count, 1);

            categoryByTestIndex = bundle.Categories["Test"];
            Assert.AreEqual(categoryByTestIndex.Count(), 0);
        }
Пример #4
0
        public override bool Parse(XElement xmlElement)
        {
            bool parseOK = false;
            if (base.Parse(xmlElement))
            {
                var categories = from element in xmlElement.Descendants() where element.Name == "Category" select element;

                foreach (var categoryElement in categories)
                {
                    var category = new ToolCategory();

                    if (category.Parse(categoryElement))
                    {
                        Categories.Add(category);
                    }
                }

                parseOK = true;
            }

            return parseOK;
        }
Пример #5
0
        public override bool Parse(XElement xmlElement)
        {
            bool parseOK = false;

            if (base.Parse(xmlElement))
            {
                var categories = from element in xmlElement.Descendants() where element.Name == "Category" select element;

                foreach (var categoryElement in categories)
                {
                    var category = new ToolCategory();

                    if (category.Parse(categoryElement))
                    {
                        Categories.Add(category);
                    }
                }

                parseOK = true;
            }

            return(parseOK);
        }
Пример #6
0
        public void BundleCategoriesRemoveTest()
        {
            var testCategory = new ToolCategory("Test", "0.0.0.1");
            var categoryToAdd = new ToolCategory("Test2", "0.0.0.1");
            ToolBundle bundle = new ToolBundle("TestBundle", "0.0.0.1");
            bundle.Categories.Add(categoryToAdd, testCategory);
            Assert.AreEqual(bundle.Categories.Count, 2);

            var isRemoved = bundle.Categories.Remove(testCategory);
            Assert.AreEqual(isRemoved, true);
            Assert.AreEqual(bundle.Categories.Count, 1);

            var isRemovedAgain = bundle.Categories.Remove(testCategory);
            Assert.AreEqual(isRemovedAgain, false);
            Assert.AreEqual(bundle.Categories.Count, 1);
        }
Пример #7
0
        public void BundleSerializationTest()
        {
            ToolBundle serializedBundle = new ToolBundle("SysInternals", "0.0.0.1")
            {
                Description = "SysInternals Bundle"
            };

            var debugging = new ToolCategory("Debugging", "0.0.0.1")
            {
                Description = "Debugging Tools from SysInternals.Com"
            };

            var monitoring = new ToolCategory("Monitoring", "0.0.0.1")
            {
                Description = "Monitoring Tools from SysInternals.Com"
            };

            Tool procDump = new Tool("ProcDump", "0.0.0.1", @"d:\sysinternals\procdump.exe -n 10 -cpu 90")
            {
                Description = "Automatic Dump capture",
                IsPortable = true
            };

            Tool procExp = new Tool("ProcExp", "0.0.0.1", @"d:\sysinternals\procexp.exe")
            {
                Description = "Process Explorer -- TaskMgr on steroids!",
                UpdateURL = "http://sysinternals.com",
                CanUpdate = true
            };

            procExp.Properties.Add("Company", "Microsoft");
            procExp.Properties.Add("Published", "2015");

            debugging.Tools.Add(procDump);
            monitoring.Tools.Add(procExp);

            serializedBundle.Categories.Add(debugging);
            serializedBundle.Categories.Add(monitoring);
            Assert.AreEqual(serializedBundle.Categories.Count, 2);

            var xml = serializedBundle.ToString();

            Assert.IsNotNull(xml);

            var deserializedBundle = ToolBundle.Parse(xml);

            Assert.AreEqual(serializedBundle.ID, deserializedBundle.ID);
            Assert.AreEqual(serializedBundle.Name, deserializedBundle.Name);
            Assert.AreEqual(serializedBundle.Version, deserializedBundle.Version);
            Assert.AreEqual(serializedBundle.Description, deserializedBundle.Description);

            foreach (var category in serializedBundle.Categories)
            {
                var deserializedCategory = deserializedBundle.Categories[category.Name].First();

                Assert.AreEqual(deserializedCategory.ID, category.ID);
                Assert.AreEqual(deserializedCategory.Name, category.Name);
                Assert.AreEqual(deserializedCategory.Version, category.Version);
                Assert.AreEqual(deserializedCategory.Description, category.Description);

                foreach (var tool in category.Tools)
                {
                    var deserializedTool = deserializedCategory.Tools[tool.Name].First();

                    Assert.AreEqual(deserializedTool.ID, tool.ID);
                    Assert.AreEqual(deserializedTool.Name, tool.Name);
                    Assert.AreEqual(deserializedTool.Version, tool.Version);
                    Assert.AreEqual(deserializedTool.Description, tool.Description);
                    Assert.AreEqual(deserializedTool.CanUpdate, tool.CanUpdate);
                    if (tool.CanUpdate)
                    {
                        Assert.AreEqual(deserializedTool.UpdateURL, tool.UpdateURL);
                    }
                    Assert.AreEqual(deserializedTool.CommandLine, tool.CommandLine);
                    Assert.AreEqual(deserializedTool.IsPortable, tool.IsPortable);

                    foreach (var prop in tool.Properties)
                    {
                        string deserializedValue = null;
                        Assert.IsTrue(deserializedTool.Properties.TryGetValue(prop.Key, out deserializedValue));
                        Assert.AreEqual(deserializedValue, prop.Value);
                    }
                }
            }
        }
Пример #8
0
 public void CategoryToolsAddTest()
 {
     ToolCategory category = new ToolCategory("SysInternals", "0.0.0.1");
     Assert.AreEqual(category.Tools.Count, 0);
     Tool procDump = new Tool("ProcDump", "0.0.0.1", @"d:\sysinternals\procdump.exe -n 10 -cpu 90");
     Tool procExp = new Tool("ProcExp", "0.0.0.1", @"d:\sysinternals\procexp.exe");
     category.Tools.Add(procDump);
     Assert.AreEqual(category.Tools.Count, 1);
     category.Tools.Add(procExp);
     Assert.AreEqual(category.Tools.Count, 2);
 }
Пример #9
0
        public void CategoryToolsRemoveTest()
        {
            Tool procDump = new Tool("ProcDump", "0.0.0.1", @"d:\sysinternals\procdump.exe -n 10 -cpu 90");
            Tool procExp = new Tool("ProcExp", "0.0.0.1", @"d:\sysinternals\procexp.exe");
            ToolCategory category = new ToolCategory("SysInternals", "0.0.0.1");
            category.Tools.Add(procDump, procExp);

            var isRemoved = category.Tools.Remove(procDump);
            Assert.AreEqual(isRemoved, true);
            Assert.AreEqual(category.Tools.Count, 1);

            isRemoved = category.Tools.Remove(procDump);
            Assert.AreEqual(isRemoved, false);
            Assert.AreEqual(category.Tools.Count, 1);
        }
Пример #10
0
        public void CategoryToolsIndexerTest()
        {
            Tool procDump = new Tool("ProcDump", "0.0.0.1", @"d:\sysinternals\procdump.exe -n 10 -cpu 90");
            Tool procExp = new Tool("ProcExp", "0.0.0.1", @"d:\sysinternals\procexp.exe");
            ToolCategory category = new ToolCategory("SysInternals", "0.0.0.1");
            category.Tools.Add(procDump, procExp);

            var toolByProcDumpIndex = category.Tools["ProcDump"];
            Assert.AreEqual(toolByProcDumpIndex.FirstOrDefault(), procDump);

            var isRemoved = category.Tools.Remove(procDump);
            Assert.AreEqual(isRemoved, true);
            Assert.AreEqual(category.Tools.Count, 1);

            toolByProcDumpIndex = category.Tools["ProcDump"];
            Assert.AreEqual(toolByProcDumpIndex.Count(), 0);
        }