Пример #1
0
        public void RunScript6()
        {
            // Arrange
            GingerPythonService service = new GingerPythonService();
            GingerAction        GA      = new GingerAction();

            String script6 =
                @"import sys
a = sys.argv[1]
b = sys.argv[2]
print('a=' + a)
print('b=' + b)
sum = int(a) + int(b)
print('sum=' + str(sum))";
            //Act
            List <Arg> args = new List <Arg>();

            args.Add(new Arg("Param 1", "4"));
            args.Add(new Arg("Param 2", "7"));
            service.RunScript(GA, script6, args);


            //Assert
            Assert.AreEqual("4", GA.Output["a"]);
            Assert.AreEqual("7", GA.Output["b"]);
            Assert.AreEqual("11", GA.Output["sum"]);
        }
Пример #2
0
        public void RunScript2()
        {
            // Arrange
            GingerPythonService service = new GingerPythonService();
            GingerAction        GA      = new GingerAction();

            String script2 =
                @"a = 'hello'
b = ' world' 
str = a + b
print('str=' + 'hello world')
";

            //Act
            service.RunScript(GA, script2, null);

            //Assert
            Assert.AreEqual("hello world", GA.Output["str"]);
        }
Пример #3
0
        public void RunScript4()
        {
            // Arrange
            GingerPythonService service = new GingerPythonService();
            GingerAction        GA      = new GingerAction();

            String script4 =
                @"a = 3
b = 4
c = min(a, b)
print('a=' + str(a))
print('b=' + str(b))
print('c=' + str(c))
";

            //Act
            service.RunScript(GA, script4, null);

            //Assert
            Assert.AreEqual("3", GA.Output["a"]);
            Assert.AreEqual("4", GA.Output["b"]);
            Assert.AreEqual("3", GA.Output["c"]);
        }
Пример #4
0
        public void RunScript1()
        {
            // Arrange
            GingerPythonService service = new GingerPythonService();
            GingerAction        GA      = new GingerAction();

            String script1 =
                @"a=2
b=3
print('a=' + str(a))
print('b=' + str(b))
sum=a+b
print('sum=' + str(sum))";

            //Act
            service.RunScript(GA, script1, null);


            //Assert
            Assert.AreEqual("2", GA.Output["a"]);
            Assert.AreEqual("3", GA.Output["b"]);
            Assert.AreEqual("5", GA.Output["sum"]);
        }