Пример #1
0
        public void WriteCommandNoParamsTest()
        {
            // test basic command for WriteCommand
            var command = new WriteCommand("no_params.in");

            command.AddCommands("TestSystem", "TestCmd", new string[] {}, new string[] { });
            command.Save();

            var cmnDocPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
            var filePath   = Path.Combine(cmnDocPath, "BpOmniaBridge", "temp_files", "no_params.in");

            Assert.AreEqual(true, File.Exists(filePath));

            // test if maine root is OmniaXB
            // test system and command elements
            var root   = XDocument.Load(filePath).Element("OmniaXB");
            var system = XDocument.Load(filePath).Element("OmniaXB").Element("TestSystem");
            var cmd    = XDocument.Load(filePath).Element("OmniaXB").Element("TestSystem").Element("TestCmd");

            Assert.AreEqual("OmniaXB", root.Name);
            Assert.AreEqual("TestSystem", system.Name);
            Assert.AreEqual("TestCmd", cmd.Name);

            File.Delete(filePath);
        }
Пример #2
0
        public void WriteCommandWithParamsTest()
        {
            // test WriteCommand with parameters with Guid as well
            var  command = new WriteCommand("with_params.in");
            Guid my_guid = new Guid("11A4801F-7977-4D3E-8D1E-6CA0BE52E604");

            command.AddCommands("TestSystem", "TestCmd", new string[] { "Param0", "Param1", "Param2" }, new string[] { "Value0", "Value1", my_guid.ToString() }, true, 2);
            command.Save();

            var cmnDocPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
            var filePath   = Path.Combine(cmnDocPath, "BpOmniaBridge", "temp_files", "with_params.in");

            Assert.AreEqual(true, File.Exists(filePath));

            var elements   = XDocument.Load(filePath).Element("OmniaXB").Element("TestSystem").Element("TestCmd").Elements();
            int num_params = 0;

            // test each parameter has the correct name and value
            // Important to test the GUID otherwise you get NACK from OMNIA
            foreach (XElement element in elements)
            {
                if (num_params == 2)
                {
                    Assert.AreEqual("Param" + num_params, element.Name);
                    Assert.AreEqual(new Guid(element.Value), my_guid);
                }
                else
                {
                    Assert.AreEqual("Param" + num_params, element.Name);
                    Assert.AreEqual("Value" + num_params, element.Value);
                }

                num_params += 1;
            }

            Assert.AreEqual(3, num_params);

            File.Delete(filePath);
        }