コード例 #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 RunScript7()
        {
            // Arrange
            GingerPythonService service = new GingerPythonService();
            GingerAction        GA      = new GingerAction();


            //Act
            List <Arg> args = new List <Arg>();

            args.Add(new Arg("Param 1", "5"));
            args.Add(new Arg("Param 2", "6"));

            service.RunScriptFile(GA, TestResources.GetTestResourcesFile("sum-file.py"), args);


            //Assert
            Assert.AreEqual("5", GA.Output["a"]);
            Assert.AreEqual("6", GA.Output["b"]);
            Assert.AreEqual("11", GA.Output["sum"]);
        }
コード例 #4
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"]);
        }
コード例 #5
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"]);
        }