using Amazon.Lambda.Annotations.SourceGenerator; using Amazon.Lambda.Annotations.SourceGenerator.FileIO; using Moq; using Xunit; namespace Amazon.Lambda.Annotations.SourceGenerators.Tests.WriterTests { /// /// Tests for /// public class ProjectFileHandlerTests { /// /// Asserts that the project is not opted out of description modification when the element is not present /// [Fact] public void IsNotOptedOut() { var csprojContent = @" net6.0 true Lambda true "; var mockFileManager = new Mock(); mockFileManager.Setup(m => m.ReadAllText(It.IsAny())).Returns(csprojContent); Assert.False(ProjectFileHandler.IsTelemetrySuppressed("test.csproj", mockFileManager.Object)); } /// /// Asserts that the project is opted out of description modification when the element is present and true /// [Fact] public void IsOptedOut() { var csprojContent = @" net6.0 true Lambda true true "; var mockFileManager = new Mock(); mockFileManager.Setup(m => m.ReadAllText(It.IsAny())).Returns(csprojContent); Assert.True(ProjectFileHandler.IsTelemetrySuppressed("test.csproj", mockFileManager.Object)); } /// /// Asserts that the project is not opted out of description modification when the element is present but has no inner text /// [Fact] public void IsNotOptedOut_PresentButEmpty() { var csprojContent = @" net6.0 true Lambda true "; var mockFileManager = new Mock(); mockFileManager.Setup(m => m.ReadAllText(It.IsAny())).Returns(csprojContent); Assert.False(ProjectFileHandler.IsTelemetrySuppressed(csprojContent, mockFileManager.Object)); } /// /// Asserts that the project is not opted out of description modification when the element is present but is set to false /// [Fact] public void IsNotOptedOut_PresentButFalse() { var csprojContent = @" net6.0 true Lambda false true "; var mockFileManager = new Mock(); mockFileManager.Setup(m => m.ReadAllText(It.IsAny())).Returns(csprojContent); Assert.False(ProjectFileHandler.IsTelemetrySuppressed(csprojContent, mockFileManager.Object)); } } }