예제 #1
0
            public void ShouldReturnNullWhenElementIsNull()
            {
                var document        = new XmlDocument();
                var scriptVariables = new ScriptVariables(document);

                var result = scriptVariables.GetDoubleArray(null);

                Assert.IsNull(result);
            }
예제 #2
0
            public void ShouldReturnNullWhenElementHasNoVariableAttribute()
            {
                var document        = new XmlDocument();
                var scriptVariables = new ScriptVariables(document);

                var element = document.CreateElement("test");

                var result = scriptVariables.GetDoubleArray(element);

                Assert.IsNull(result);
            }
예제 #3
0
            public void ShouldReturnNullWhenVariableValueIsInvalid()
            {
                var document = new XmlDocument();

                document.LoadXml("<test foo=\"{$foo}\"/>");

                var scriptVariables = new ScriptVariables(document);

                var element = document.CreateElement("test");

                element.SetAttribute("variable", "bar");

                var result = scriptVariables.GetDoubleArray(element);

                Assert.IsNull(result);
            }
예제 #4
0
            public void ShouldThrowExceptionWhenVariableNameIsInvalid()
            {
                var document = new XmlDocument();

                document.LoadXml("<test foo=\"{$foo}\"/>");

                var scriptVariables = new ScriptVariables(document);

                var element = document.CreateElement("test");

                element.SetAttribute("variable", "{$bar}");

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    scriptVariables.GetDoubleArray(element);
                }, "Invalid variable name: bar");
            }
예제 #5
0
            public void ShouldThrowExceptionWhenVariableTypeIsIncorrect()
            {
                var document = new XmlDocument();

                document.LoadXml("<test foo=\"{$foo}\"/>");

                var scriptVariables = new ScriptVariables(document);

                scriptVariables.Set("foo", new string[] { });

                var element = document.CreateElement("test");

                element.SetAttribute("variable", "{$foo}");

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    scriptVariables.GetDoubleArray(element);
                }, "The value of variable 'foo' is not a double[].");
            }
예제 #6
0
            public void ShouldReturnValue()
            {
                var document = new XmlDocument();

                document.LoadXml("<test foo=\"{$foo}\"/>");

                var scriptVariables = new ScriptVariables(document);

                scriptVariables.Set("foo", new double[] { 42 });

                var element = document.CreateElement("test");

                element.SetAttribute("variable", "{$foo}");

                var result = scriptVariables.GetDoubleArray(element);

                Assert.IsNotNull(result);
                Assert.AreEqual(42.0, result[0]);
            }