Exemplo n.º 1
0
        public void BuildArgs_ShouldConstructWithFileToTest()
        {
            string pathToFile = "c:\\test.dll";
            var    subject    = new NUnitRunner().FileToTest(pathToFile);

            subject.BuildArgs();
            Assert.That(subject._argumentBuilder.Build(), Is.EqualTo(pathToFile + " /nologo /nodots /xmlconsole"));
        }
Exemplo n.º 2
0
        public void PathToConsoleRunner_ShouldPopulateInternalFieldAndReturnSelf()
        {
            var         subject     = new NUnitRunner();
            string      file        = "c:\\temp\\nunit-console.exe";
            NUnitRunner nUnitRunner = subject.PathToNunitConsoleRunner(file);

            Assert.That(nUnitRunner, Is.SameAs(subject));
            Assert.That(nUnitRunner._pathToConsoleRunner, Is.EqualTo(file));
        }
Exemplo n.º 3
0
        public void XmlOutputTo_ShouldPopulatePropertiesAndReturnSelf()
        {
            var         subject     = new NUnitRunner();
            string      file        = "c:\\temp\\out.xml";
            NUnitRunner nUnitRunner = subject.XmlOutputTo(file);

            Assert.That(nUnitRunner, Is.SameAs(subject));
            Assert.That(nUnitRunner._argumentBuilder.FindByName("xml"), Is.EqualTo(file));
        }
Exemplo n.º 4
0
        public void WorkingDirectory_ShouldPopulateInternalFieldAndReturnSelf()
        {
            var         subject     = new NUnitRunner();
            string      workingdir  = "workingDir";
            NUnitRunner nUnitRunner = subject.WorkingDirectory(workingdir);

            Assert.That(nUnitRunner, Is.SameAs(subject));
            Assert.That(nUnitRunner._workingDirectory, Is.EqualTo(workingdir));
        }
Exemplo n.º 5
0
        public void FileToTest_ShouldPopulateInternalFieldAndReturnSelf()
        {
            var         subject     = new NUnitRunner();
            string      file        = "file.dll";
            NUnitRunner nUnitRunner = subject.FileToTest(file);

            Assert.That(nUnitRunner, Is.SameAs(subject));
            Assert.That(nUnitRunner._fileToTest, Is.EqualTo(file));
        }
Exemplo n.º 6
0
        public void AddParameter_ShouldAddToInteralDictionary()
        {
            var         subject     = new NUnitRunner();
            string      param       = "singleParam";
            string      value       = "val";
            NUnitRunner nUnitRunner = subject.AddParameter(param, value);

            Assert.That(nUnitRunner, Is.SameAs(subject));
            Assert.That(nUnitRunner._argumentBuilder.FindByName(param), Is.EqualTo(value));
        }
Exemplo n.º 7
0
        public void AddSingleParameter_ShouldAddToInteralDictionary()
        {
            var         subject     = new NUnitRunner();
            string      singleparam = "singleParam";
            NUnitRunner nUnitRunner = subject.AddParameter(singleparam);

            subject.BuildArgs();
            Assert.That(nUnitRunner, Is.SameAs(subject));
            Assert.That(nUnitRunner._argumentBuilder.FindByName(singleparam), Is.EqualTo(null));
        }
Exemplo n.º 8
0
        public void Execute_ShouldThrowExceptionIfPathToExeNotSetAndCanNotBeFound()
        {
            var mockExecutable = MockRepository.GenerateStub <IExecutable>();
            var mockFileFinder = MockRepository.GenerateStub <IFileSystemHelper>();

            var subject = new NUnitRunner(mockExecutable, mockFileFinder);

            mockFileFinder.Stub(x => x.Find("nunit-console.exe")).Return(null);
            subject.Execute();
        }
Exemplo n.º 9
0
        public void BuildArgs_ShouldConstructWithFileToTestAndNameValueParameter()
        {
            string pathToFile = "c:\\test.dll";
            string name       = "label";
            string value      = "value";
            var    subject    = new NUnitRunner().FileToTest(pathToFile).AddParameter(name, value);

            subject.BuildArgs();
            Assert.That(subject._argumentBuilder.Build(), Is.EqualTo(pathToFile + " /" + name + ":" + value + " /nologo /nodots /xmlconsole"));
        }
Exemplo n.º 10
0
        public void Execute_ShouldSetOnErrorStateToFalse()
        {
            string pathToExe      = "c:\\test.exe";
            var    mockExecutable = MockRepository.GenerateStub <IExecutable>();
            var    mockFileFinder = MockRepository.GenerateStub <IFileSystemHelper>();
            var    subject        = new NUnitRunner(mockExecutable, mockFileFinder);

            mockExecutable.Stub(x => x.ExecutablePath(pathToExe)).Return(mockExecutable);
            mockExecutable.Stub(x => x.UseArgumentBuilder(null)).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.SucceedOnNonZeroErrorCodes()).IgnoreArguments().Return(mockExecutable);

            mockExecutable.Stub(x => x.FailOnError).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.ContinueOnError).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.WithMessageProcessor(Arg <IMessageProcessor> .Is.Anything)).Return(mockExecutable);

            subject.PathToNunitConsoleRunner(pathToExe).ContinueOnError.Execute();

            Assert.That(subject.OnError, Is.EqualTo(OnError.Continue));
        }
Exemplo n.º 11
0
        public void Execute_ShouldSetWorkingDirectoryOnMockIfManuallySpecifiedInCode()
        {
            string workingDirectory = "c:\\temp";
            string pathToExe        = "c:\\test.exe";
            var    mockExecutable   = MockRepository.GenerateStub <IExecutable>();
            var    mockFileFinder   = MockRepository.GenerateStub <IFileSystemHelper>();
            var    subject          = new NUnitRunner(mockExecutable, mockFileFinder);

            mockExecutable.Stub(x => x.ExecutablePath(pathToExe)).Return(mockExecutable);
            mockExecutable.Stub(x => x.UseArgumentBuilder(null)).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.SucceedOnNonZeroErrorCodes()).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.InWorkingDirectory(workingDirectory)).Return(mockExecutable);
            mockExecutable.Stub(x => x.FailOnError).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.ContinueOnError).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.WithMessageProcessor(Arg <IMessageProcessor> .Is.Anything)).Return(mockExecutable);

            subject.PathToNunitConsoleRunner(pathToExe).WorkingDirectory(workingDirectory).Execute();

            mockExecutable.AssertWasCalled(x => x.InWorkingDirectory(workingDirectory));
        }
Exemplo n.º 12
0
        public void Execute_ShouldTryToFindPathToNunitIfNotSet()
        {
            string workingDirectory = "c:\\temp";
            string pathToExe        = "c:\\test.exe";
            var    mockExecutable   = MockRepository.GenerateStub <IExecutable>();
            var    mockFileFinder   = MockRepository.GenerateStub <IFileSystemHelper>();

            var subject = new NUnitRunner(mockExecutable, mockFileFinder);

            mockFileFinder.Stub(x => x.Find("nunit-console.exe")).Return("c:\\temp\nunit-console.exe");
            mockExecutable.Stub(x => x.ExecutablePath(pathToExe)).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.UseArgumentBuilder(null)).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.SucceedOnNonZeroErrorCodes()).IgnoreArguments().Return(mockExecutable);

            mockExecutable.Stub(x => x.FailOnError).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.ContinueOnError).IgnoreArguments().Return(mockExecutable);
            mockExecutable.Stub(x => x.WithMessageProcessor(Arg <IMessageProcessor> .Is.Anything)).Return(mockExecutable);
            subject.Execute();

            mockFileFinder.AssertWasCalled(x => x.Find("nunit-console.exe"));
        }