Esempio n. 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);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);
            ScanResults        scanResults        = BuildTestScanResults(errorCount: 2, a11yTestFile: TestA11yTestFile,
                                                                         patternCount: 2, propertyCount: 2);

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

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 2
0
        public void WriteBanner_VerbosityIsDefault_NoProcessName_NoProcessId_NoScanId_WritesAppHeader()
        {
            SetOptions();
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);

            generator.WriteBanner(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 3
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);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);
            ScanResults        scanResults        = BuildTestScanResults();

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

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 4
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);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);

            generator.WriteThirdPartyNoticeOutput(testFile);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 5
0
        public void WriteBanner_CalledMultipleTimes_WritesOnlyOnce()
        {
            SetOptions();
            WriteCall[] expectedCalls =
            {
                new WriteCall(AppTitleStart, WriteSource.WriteLineOneParam),
            };
            TextWriterVerifier textWriterVerifier = new TextWriterVerifier(_writerMock, expectedCalls);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);

            generator.WriteBanner(_optionsMock.Object);
            generator.WriteBanner(_optionsMock.Object);
            generator.WriteBanner(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 6
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);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);

            generator.WriteBanner(_optionsMock.Object);

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 7
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);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);

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

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }
Esempio n. 8
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);
            IOutputGenerator   generator          = new OutputGenerator(_writerMock.Object);

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

            textWriterVerifier.VerifyAll();
            VerifyAllMocks();
        }