コード例 #1
0
        public void WriteOutput_ScanResultsMultipleErrors_TwoPatterns_TwoProperties_VerbosityIsVerbose_WritesBannerAndSummaryAndDetails()
        {
            SetOptions(verbosityLevel: VerbosityLevel.Verbose);
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,                     WriteSource.WriteLineOneParam),
                new WriteCall(ErrorCountGeneralStart,            WriteSource.WriteLineOneParam),
                new WriteCall(ErrorVerboseCountStart,            WriteSource.WriteLineTwoParams),
                new WriteCall(ErrorVerbosePropertiesHeaderStart, WriteSource.WriteLineStringOnly),
                new WriteCall(ErrorVerbosePropertyPairStart,     WriteSource.WriteLineTwoParams),
                new WriteCall(ErrorVerbosePropertyPairStart,     WriteSource.WriteLineTwoParams),
                new WriteCall(ErrorVerbosePatternsHeaderStart,   WriteSource.WriteLineStringOnly),
                new WriteCall(ErrorVerbosePatternIndex,          WriteSource.WriteLineOneParam),
                new WriteCall(ErrorVerbosePatternIndex,          WriteSource.WriteLineOneParam),
                new WriteCall(ErrorVerboseSeparatorStart,        WriteSource.WriteLineStringOnly),
                new WriteCall(ErrorVerboseCountStart,            WriteSource.WriteLineTwoParams),
                new WriteCall(ErrorVerbosePropertiesHeaderStart, WriteSource.WriteLineStringOnly),
                new WriteCall(ErrorVerbosePropertyPairStart,     WriteSource.WriteLineTwoParams),
                new WriteCall(ErrorVerbosePropertyPairStart,     WriteSource.WriteLineTwoParams),
                new WriteCall(ErrorVerbosePatternsHeaderStart,   WriteSource.WriteLineStringOnly),
                new WriteCall(ErrorVerbosePatternIndex,          WriteSource.WriteLineOneParam),
                new WriteCall(ErrorVerbosePatternIndex,          WriteSource.WriteLineOneParam),
                new WriteCall(ErrorVerboseSeparatorStart,        WriteSource.WriteLineStringOnly),
                new WriteCall(OutputFileStart,                   WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);
            ScanResults        scanResults        = BuildTestScanResults(errorCount: 2, a11yTestFile: TestA11yTestFile,
                                                                         patternCount: 2, propertyCount: 2);

            _testSubject.WriteOutput(_optionsMock.Object, scanResults, null);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #2
0
        public void WriteBanner_VerbosityIsDefault_NoProcessName_NoProcessId_NoScanId_WritesAppHeader()
        {
            SetOptions();
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteBanner(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #3
0
        //[Timeout(1000)]
        public void WriteOutput_ScanResultsNull_CaughtExceptionNull_VerbosityIsQuiet_WritesBannerAndError()
        {
            SetOptions(verbosityLevel: VerbosityLevel.Quiet);
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,    WriteSource.WriteLineOneParam),
                new WriteCall(UnableToComplete, WriteSource.WriteStringOnly),
                new WriteCall(NoFurtherData,    WriteSource.WriteLineStringOnly),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteOutput(_optionsMock.Object, null, null);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #4
0
        public void WriteOutput_ScanResultsNoErrors_VerbosityIsDefault_WritesBannerAndSummary()
        {
            SetOptions();
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,          WriteSource.WriteLineOneParam),
                new WriteCall(ErrorCountGeneralStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);
            ScanResults        scanResults        = BuildTestScanResults();

            _testSubject.WriteOutput(_optionsMock.Object, scanResults, null);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #5
0
        public void WriteBanner_ShowThirdPartyNotices_WritesAppHeaderAndThirdPartyNotice()
        {
            const string testFile = @"c:\somePath\someFile.html";

            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,         WriteSource.WriteLineOneParam),
                new WriteCall(ThirdPartyNoticeStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteThirdPartyNoticeOutput(testFile);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #6
0
        public void WriteBanner_CalledMultipleTimes_WritesOnlyOnce()
        {
            SetOptions();
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteBanner(_optionsMock.Object);
            _testSubject.WriteBanner(_optionsMock.Object);
            _testSubject.WriteBanner(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #7
0
        public void WriteBanner_VerbosityIsDefault_NoProcessName_ProcessId_NoScanId_WritesAppHeaderAndScanTarget()
        {
            SetOptions(processId: TestProcessId);
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,            WriteSource.WriteLineOneParam),
                new WriteCall(ScanTargetIntro,          WriteSource.WriteStringOnly),
                new WriteCall(ScanTargetProcessIdStart, WriteSource.WriteOneParam),
                new WriteCall(null,                     WriteSource.WriteLineEmpty),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteBanner(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #8
0
        public void WriteOutput_NonParameterExceptionIsThrown_VerbosityIsQuiet_WritesBannerAndError()
        {
            Exception caughtException = new MissingMethodException();

            SetOptions(verbosityLevel: VerbosityLevel.Quiet);
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,      WriteSource.WriteLineOneParam),
                new WriteCall(UnableToComplete,   WriteSource.WriteStringOnly),
                new WriteCall(ExceptionInfoStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteOutput(_optionsMock.Object, null, caughtException);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #9
0
        public void WriteOutput_ParameterExceptionIsThrown_VerbosityIsQuiet_WritesBannerAndError()
        {
            const string errorMessage = "A parameter was bad";

            SetOptions(verbosityLevel: VerbosityLevel.Quiet);
            Exception caughtException = new ParameterException(errorMessage);

            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart,    WriteSource.WriteLineOneParam),
                new WriteCall(UnableToComplete, WriteSource.WriteStringOnly),
                new WriteCall(errorMessage,     WriteSource.WriteLineStringOnly)
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.WriteOutput(_optionsMock.Object, null, caughtException);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
コード例 #10
0
        public void DelayWithCountdown_DelayIsNotZero_VerbosityIsNotQuiet_HasDelayWithOutput()
        {
            const int delayInSeconds = 3;

            _optionsMock.Setup(m => m.DelayInSeconds).Returns(delayInSeconds);
            _optionsMock.Setup(m => m.VerbosityLevel).Returns(VerbosityLevel.Default);
            _oneSecondDelayMock.Setup(m => m.Invoke());

            WriteCall[] expectedCalls =
            {
                PackFormattedCall(DisplayStrings.ScanDelayHeaderMoreThanOneSecond,                                      3),
                PackFormattedCall(DisplayStrings.ScanDelayCountdownMoreThanOneSecondLeft,                               3),
                PackFormattedCall(DisplayStrings.ScanDelayCountdownMoreThanOneSecondLeft,                               2),
                PackFormattedCall(DisplayStrings.ScanDelayCountdownOneSecondLeft,                                       1),
                new WriteCall(DisplayStrings.ScanDelayTriggeringScan,                     WriteSource.WriteLineStringOnly),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);

            _testSubject.DelayWithCountdown(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            _oneSecondDelayMock.Verify(m => m.Invoke(), Times.Exactly(delayInSeconds));
            VerifyWriterAndOptionsMocks();
        }