Ejemplo n.º 1
0
        public void ExceptionShouldBeThrownWhenNullWriter()
        {
            var mockFormatter = new Mock <ICSVFormatter>();
            var options       = new Options {
                OutputFileName = "output.csv"
            };
            var sut            = new CSVFlawWriter(mockFormatter.Object);
            var detailedReport = new detailedreport();

            Should.Throw <ArgumentNullException>(() => sut.Write(null, detailedReport, options));
        }
Ejemplo n.º 2
0
        public void ShouldReturnFilenameFromXML()
        {
            var mockFormatter  = new Mock <ICSVFormatter>();
            var options        = new Options( );
            var sut            = new CSVFlawWriter(mockFormatter.Object);
            var detailedReport = new detailedreport {
                app_name = "app name"
            };

            sut.GetOutputFilename(detailedReport, options).ShouldBe("app name.csv");
        }
Ejemplo n.º 3
0
        public void ShouldReturnFilenameIfSupplied()
        {
            var mockFormatter = new Mock <ICSVFormatter>();
            var options       = new Options {
                OutputFileName = "input.csv"
            };
            var sut            = new CSVFlawWriter(mockFormatter.Object);
            var detailedReport = new detailedreport();

            sut.GetOutputFilename(detailedReport, options).ShouldBe("input.csv");
        }
Ejemplo n.º 4
0
        public void ExceptionShouldBeThrownWhenNullOptions()
        {
            var mockFormatter  = new Mock <ICSVFormatter>();
            var detailedReport = new detailedreport();
            var sut            = new CSVFlawWriter(mockFormatter.Object);

            using (var resultStream = new MemoryStream())
                using (var resultWriter = new StreamWriter(resultStream))
                {
                    Should.Throw <ArgumentNullException>(() => sut.Write(resultWriter, detailedReport, null));
                }
        }
Ejemplo n.º 5
0
        public void ExceptionShouldBeThrownWhenNullReport()
        {
            var mockFormatter = new Mock <ICSVFormatter>();
            var options       = new Options {
                OutputFileName = "output.csv"
            };
            var sut = new CSVFlawWriter(mockFormatter.Object);

            using (var resultStream = new MemoryStream())
                using (var resultWriter = new StreamWriter(resultStream))
                {
                    Should.Throw <ArgumentNullException>(() => sut.Write(resultWriter, null, options));
                    resultWriter.Flush();
                }
        }
Ejemplo n.º 6
0
        public void ShouldLoadStaticResults()
        {
            var detailedReport = detailedreport.LoadFromFile("./xml/LoadValidStaticFileTest.xml");
            var options        = new Options
            {
                IncludeFixedFlaws = false
            };
            var mockFormatter = new Mock <ICSVFormatter>();

            using (var resultStream = new MemoryStream())
                using (var resultWriter = new StreamWriter(resultStream))
                {
                    var sut = new CSVFlawWriter(mockFormatter.Object);
                    sut.Write(resultWriter, detailedReport, options);
                    resultWriter.Flush();
                }

            // 1 for header, 5 for static results
            mockFormatter.Verify(x => x.FormatLine(It.IsAny <List <string> >()), Times.Exactly(6));
        }