Пример #1
0
        public void TestInterpolation()
        {
            var mockCore         = MockRepository.GenerateMock <ICentipedeCore>();
            var mockVariables    = MockRepository.GenerateMock <IDictionary <string, object> >();
            var mockPythonEngine = MockRepository.GenerateStub <IPythonEngine>();


            var oldPwd = ShellActionPwdAccessor.AccessedPwd;

            mockCore.Expect(c => c.PythonEngine).Return(mockPythonEngine);

            var bc = MockRepository.GenerateMock <IPythonByteCode>();

            mockPythonEngine.Expect(
                e => e.Compile(Arg <String> .Is.Equal("'..'"),
                               Arg <SourceCodeType> .Is.Anything))
            .Return(bc);
            mockPythonEngine.Expect(e => e.Evaluate(bc)).Return("..");


            var action = new SetCwd(mockVariables, mockCore)
            {
                DirectoryPath = @"{'..'}"
            };

            action.Run();

            mockPythonEngine.VerifyAllExpectations();

            ShellActionPwdAccessor.AccessedPwd = oldPwd;
        }
Пример #2
0
        public void TestInvalidPath()
        {
            var mockCore      = MockRepository.GenerateMock <ICentipedeCore>();
            var mockVariables = MockRepository.GenerateMock <IDictionary <string, object> >();


            var oldPwd = ShellActionPwdAccessor.AccessedPwd;

            var action = new SetCwd(mockVariables, mockCore)
            {
                DirectoryPath = "!£$%^*&()&"                 //no swearing in the source code!
            };

            try
            {
                action.Run();
                Assert.Fail("Did not throw!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ActionException));
            }

            ShellActionPwdAccessor.AccessedPwd = oldPwd;
        }
Пример #3
0
        public void TestRun()
        {
            var mockCore      = MockRepository.GenerateMock <ICentipedeCore>();
            var mockVariables = MockRepository.GenerateMock <IDictionary <string, object> >();


            var oldPwd = ShellActionPwdAccessor.AccessedPwd;

            var action = new SetCwd(mockVariables, mockCore)
            {
                DirectoryPath = ".."
            };

            action.Run();

            Assert.AreNotEqual(oldPwd, ShellActionPwdAccessor.AccessedPwd);
            ShellActionPwdAccessor.AccessedPwd = oldPwd;
        }