예제 #1
0
파일: Program.cs 프로젝트: asipe/shamz
        private static void Main()
        {
            var exe = ShamzFactory.CreateShamzExe("sample.exe");

            exe
            .Setup(invocation => invocation
                   .WhenCommandLine("abc")
                   .ThenReturn(1000))
            .Setup(invocation => invocation
                   .WhenCommandLine("def")
                   .ThenReturn(0))
            .Initialize();

            using (var process = Process.Start("sample.exe", "abc")) {
                process.WaitForExit();
                Console.WriteLine("'sample.exe abc': ExitCode = {0}", process.ExitCode);
            }

            using (var process = Process.Start("sample.exe", "def")) {
                process.WaitForExit();
                Console.WriteLine("'sample.exe def': ExitCode = {0}", process.ExitCode);
            }

            exe.CleanUp();
        }
예제 #2
0
파일: UsageTest.cs 프로젝트: asipe/shamz
        public void TestExactMatchUsage()
        {
            var shamz = ShamzFactory.CreateShamzExe(mWorkingExePath);

            shamz
            .Setup(invocation => invocation
                   .WhenCommandLine(MatchMode.Exact, "a1", "b1", "c1")
                   .ThenReturn(10))
            .Setup(invocation => invocation
                   .WhenCommandLine(MatchMode.Exact, "a2", "b2", "c2")
                   .ThenReturn(20))
            .Initialize();

            new WorkQueueBatch(BuildWorkQueue())
            .Add(() => Measure(0, 750, () => ExecuteProcess("a1 b1 c1", 10)),
                 () => Measure(0, 750, () => ExecuteProcess("a2 b2 c2", 20)),
                 () => Measure(0, 750, () => ExecuteProcess("a22 b22 c22", 0)),
                 () => Measure(0, 750, () => ExecuteProcess("a22a b22b c22c", 0)),
                 () => Measure(0, 750, () => ExecuteProcess("", 0)),
                 () => Measure(0, 750, () => ExecuteProcess("a1b1c1", 0)))
            .Wait(100000);

            shamz.CleanUp();
            VerifyShamzExecutableRemoved();
        }
예제 #3
0
파일: UsageTest.cs 프로젝트: asipe/shamz
        public void TestDelayUsage()
        {
            var shamz = ShamzFactory.CreateShamzExe(mWorkingExePath);

            shamz
            .Setup(invocation => invocation
                   .WhenCommandLine("arg1", "arg2", "arg3")
                   .Delay(1000)
                   .ThenReturn(1000))
            .Setup(invocation => invocation
                   .WhenCommandLine("arg4", "arg5", "arg6")
                   .ThenReturn(2000))
            .Setup(invocation => invocation
                   .WhenCommandLine("arg7", "arg8", "arg9")
                   .Delay(1500)
                   .ThenReturn(3000))
            .Initialize();
            new WorkQueueBatch(BuildWorkQueue())
            .Add(() => Measure(1000, 2500, () => ExecuteProcess("arg1 arg2 arg3", 1000)),
                 () => Measure(0, 2000, () => ExecuteProcess("arg4 arg5 arg6", 2000)),
                 () => Measure(1500, 3000, () => ExecuteProcess("arg7 arg8 arg9", 3000)))
            .Wait(100000);
            shamz.CleanUp();
            VerifyShamzExecutableRemoved();
        }
예제 #4
0
파일: UsageTest.cs 프로젝트: asipe/shamz
        public void TestRegexUsage()
        {
            var shamz = ShamzFactory.CreateShamzExe(mWorkingExePath);

            shamz
            .Setup(invocation => invocation
                   .WhenCommandLine("^a[0-9]$", "b[0-9]", "c1")
                   .ThenReturn(1000))
            .Setup(invocation => invocation
                   .WhenCommandLine(".+", ".+", ".+")
                   .ThenReturn(2000))
            .Initialize();
            new WorkQueueBatch(BuildWorkQueue())
            .Add(() => Measure(0, 500, () => ExecuteProcess("a1 b1 c1", 1000)),
                 () => Measure(0, 500, () => ExecuteProcess("a2 b2 c2", 2000)),
                 () => Measure(0, 500, () => ExecuteProcess("a2", 0)))
            .Wait(100000);
            shamz.CleanUp();
            VerifyShamzExecutableRemoved();
        }
예제 #5
0
파일: UsageTest.cs 프로젝트: asipe/shamz
        public void TestDefaultExitCodeUsage()
        {
            var shamz = ShamzFactory.CreateShamzExe(mWorkingExePath);

            shamz
            .Setup(invocation => invocation
                   .WhenCommandLine("a1", "b1", "c1")
                   .ThenReturn(2))
            .Setup(invocation => invocation
                   .WhenCommandLine("a2", "b2", "c2")
                   .ThenReturn(1))
            .WithDefaultExitCode(100)
            .Initialize();
            new WorkQueueBatch(BuildWorkQueue())
            .Add(() => Measure(0, 500, () => ExecuteProcess("a1 b1 c1", 2)),
                 () => Measure(0, 500, () => ExecuteProcess("a2 b2 c2", 1)),
                 () => Measure(0, 500, () => ExecuteProcess("", 100)),
                 () => Measure(0, 500, () => ExecuteProcess("a1b1c1", 100)),
                 () => Measure(0, 500, () => ExecuteProcess(null, 100)))
            .Wait(100000);
            shamz.CleanUp();
            VerifyShamzExecutableRemoved();
        }