public void GetMessage_ForAllMessageIds_ReturnsMessage(CompilerMessageId messageId)
        {
            // Arrange
            var messageKey      = CompilerMessages.FormatMessageId(messageId);
            var expectedMessage = this.resourceManager.GetString(messageKey);

            // Act
            var actualMessage = CompilerMessages.Get(messageId);

            // Assert
            Assert.True(!string.IsNullOrEmpty(expectedMessage), $"Compiler message missing for {messageKey}");
            Assert.Equal(expectedMessage, actualMessage);
        }
Ejemplo n.º 2
0
        public void When_CompilationHasMessages_OutputsMessages()
        {
            // Arrange
            var inputFile       = this.fileCreator.CreateTempFile();
            var outputDirectory = this.fileCreator.GetTempDirectory();

            this.SetupCompilationWithMessages(
                new CompilationMessage(CompilerMessageId.EnumMustHaveAName, CompilerMessageType.Error, 1, 1, 4, "Message 1"),
                new CompilationMessage(CompilerMessageId.EnumMemberMustHaveAName, CompilerMessageType.Error, 2, 4, 8, "Message 2"));
            this.SetupCreateThriftFile(inputFile);

            // Act
            Program.Main(inputFile, outputDirectory, this.console);

            // Assert
            var enumMustHaveName       = CompilerMessages.FormatMessageId(CompilerMessageId.EnumMustHaveAName);
            var enumMemberMustHaveName = CompilerMessages.FormatMessageId(CompilerMessageId.EnumMemberMustHaveAName);

            this.console.Out.Received().Write(
                $"{inputFile.Name}(1,1-4): Error {enumMustHaveName}: Message 1 [{inputFile.FullName}]{Environment.NewLine}");
            this.console.Out.Received().Write(
                $"{inputFile.Name}(2,4-8): Error {enumMemberMustHaveName}: Message 2 [{inputFile.FullName}]{Environment.NewLine}");
        }