public void PylintConverter_Convert_WhenInputIsValid_Passes()
        {
            byte[]       data   = Encoding.UTF8.GetBytes(InputJson);
            MemoryStream stream = new MemoryStream(data);

            var mockWriter = new Mock <IResultLogWriter>();

            mockWriter.Setup(writer => writer.Initialize(It.IsAny <string>(), It.IsAny <string>()));
            mockWriter.Setup(writer => writer.WriteTool(It.IsAny <Tool>()));
            mockWriter.Setup(writer => writer.WriteFiles(It.IsAny <IDictionary <string, FileData> >()));
            mockWriter.Setup(writer => writer.OpenResults());
            mockWriter.Setup(writer => writer.CloseResults());
            mockWriter.Setup(writer => writer.WriteResults(It.IsAny <List <Result> >()));

            var converter = new PylintConverter();

            converter.Convert(stream, mockWriter.Object, Microsoft.CodeAnalysis.Sarif.Writers.LoggingOptions.None);

            mockWriter.Verify(writer => writer.Initialize(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            mockWriter.Verify(writer => writer.WriteTool(It.IsAny <Tool>()), Times.Once);
            mockWriter.Verify(writer => writer.WriteFiles(It.IsAny <IDictionary <string, FileData> >()), Times.Once);
            mockWriter.Verify(writer => writer.OpenResults(), Times.Once);
            mockWriter.Verify(writer => writer.CloseResults(), Times.Once);
            mockWriter.Verify(writer => writer.WriteResults(It.IsAny <List <Result> >()), Times.Once);
        }
Example #2
0
        public void PylintConverter_CreateResult_WhenInputIsNull_ThrowsArgumentNullException()
        {
            var converter = new PylintConverter();

            Action action = () => converter.CreateResult(null);

            action.Should().Throw <ArgumentNullException>();
        }
Example #3
0
        public void PylintConverter_Convert_WhenOutputIsNull_ThrowsArgumentNullException()
        {
            var converter = new PylintConverter();

            Action action = () => converter.Convert(new MemoryStream(), null, OptionallyEmittedData.None);

            action.Should().Throw <ArgumentNullException>();
        }
        public void PylintConverter_Convert_WhenOutputIsNull_ThrowsArgumentNullException()
        {
            var converter = new PylintConverter();

            Action action = () => converter.Convert(new MemoryStream(), null, Microsoft.CodeAnalysis.Sarif.Writers.LoggingOptions.None);

            action.ShouldThrow <ArgumentNullException>();
        }
Example #5
0
        public void PylintConverter_Convert_WhenInputIsNull_ThrowsArgumentNullException()
        {
            var converter     = new PylintConverter();
            var mockLogWriter = new Mock <IResultLogWriter>();

            Action action = () => converter.Convert(null, mockLogWriter.Object, OptionallyEmittedData.None);

            action.Should().Throw <ArgumentNullException>();
        }
        public void PylintConverter_Convert_WhenInputIsNull_ThrowsArgumentNullException()
        {
            var converter     = new PylintConverter();
            var mockLogWriter = new Mock <IResultLogWriter>();

            Action action = () => converter.Convert(null, mockLogWriter.Object, Microsoft.CodeAnalysis.Sarif.Writers.LoggingOptions.None);

            action.ShouldThrow <ArgumentNullException>();
        }
Example #7
0
        public void PylintConverter_CreateResult_CreatesExpectedResult()
        {
            var            converter = new PylintConverter();
            PylintLogEntry PylintLog = CreateTestLogEntry();

            Result actualResult   = converter.CreateResult(PylintLog);
            Result expectedResult = CreateResult();

            Result.ValueComparer.Equals(actualResult, expectedResult).Should().BeTrue();
        }
Example #8
0
        public void PylintConverter_Convert_WhenInputIsValid_Passes()
        {
            byte[]       data   = Encoding.UTF8.GetBytes(InputJson);
            MemoryStream stream = new MemoryStream(data);

            var mockWriter = new Mock <IResultLogWriter>();

            mockWriter.Setup(writer => writer.Initialize(It.IsAny <Run>()));
            mockWriter.Setup(writer => writer.WriteArtifacts(It.IsAny <IList <Artifact> >()));
            mockWriter.Setup(writer => writer.OpenResults());
            mockWriter.Setup(writer => writer.CloseResults());
            mockWriter.Setup(writer => writer.WriteResults(It.IsAny <List <Result> >()));

            var converter = new PylintConverter();

            converter.Convert(stream, mockWriter.Object, OptionallyEmittedData.None);

            mockWriter.Verify(writer => writer.Initialize(It.IsAny <Run>()), Times.Once);
            mockWriter.Verify(writer => writer.WriteArtifacts(It.IsAny <IList <Artifact> >()), Times.Never);
            mockWriter.Verify(writer => writer.OpenResults(), Times.Once);
            mockWriter.Verify(writer => writer.CloseResults(), Times.Once);
            mockWriter.Verify(writer => writer.WriteResults(It.IsAny <List <Result> >()), Times.Once);
        }