Repository: dotnet/roslyn
File: src/Workspaces/MSBuild/Test/DefaultBinLogPathProviderTests.cs (C#)

Code before:
            Assert.Equal(LogDirectory, newLogDirectory);
            Assert.StartsWith(LogFileName, newLogFileName);
            Assert.Equal(LogExtension, newLogExtension);
        }
    }

    [Fact]
    public void DefaultBinLogPathProvider_UsesDefaultExtension()
    {
        var logPath = Path.Combine(LogDirectory, LogFileName);
        var provider = new DefaultBinLogPathProvider(logPath);

        var newLogPaths = Enumerable.Range(0, 10)
            .Select(_ => provider.GetNewLogPath())
            .ToImmutableHashSet();
        Assert.Equal(10, newLogPaths.Count);

        foreach (var newLogPath in newLogPaths)
        {
            var newLogDirectory = Path.GetDirectoryName(newLogPath);
            var newLogFileName = Path.GetFileNameWithoutExtension(newLogPath);
            var newLogExtension = Path.GetExtension(newLogPath);

            Assert.Equal(LogDirectory, newLogDirectory);
            Assert.StartsWith(LogFileName, newLogFileName);
            Assert.Equal(DefaultBinLogPathProvider.DefaultExtension, newLogExtension);
        }
    }

    [Fact]
    public void DefaultBinLogPathProvider_UsesDefaultFileName()
    {
        var provider = new DefaultBinLogPathProvider(LogDirectory + Path.DirectorySeparatorChar);

        var newLogPaths = Enumerable.Range(0, 10)
            .Select(_ => provider.GetNewLogPath())
            .ToImmutableHashSet();
        Assert.Equal(10, newLogPaths.Count);

        foreach (var newLogPath in newLogPaths)
        {
            var newLogDirectory = Path.GetDirectoryName(newLogPath);
            var newLogFileName = Path.GetFileNameWithoutExtension(newLogPath);
            var newLogExtension = Path.GetExtension(newLogPath);

            Assert.Equal(LogDirectory, newLogDirectory);
            Assert.StartsWith(DefaultBinLogPathProvider.DefaultFileName, newLogFileName);
            Assert.Equal(DefaultBinLogPathProvider.DefaultExtension, newLogExtension);
        }
    }
}

Review comment (suggestion):
I recommend duplicating the const into this file and using the one from here instead, so that just changing the const in the implementation isn't enough, there's a more conscious step to work through and accept a behavior break we may be creating by changing the constant value.

Code after:
        AssertUniquePaths(provider, LogDirectory, LogFileName, DefaultExtension);
    }

    [Fact]
    public void DefaultBinLogPathProvider_UsesDefaultFileName()
    {
        var provider = new BinLogPathProvider(LogDirectory + Path.DirectorySeparatorChar);
        AssertUniquePaths(provider, LogDirectory, DefaultFileName, DefaultExtension);
    }

    private static void AssertUniquePaths(BinLogPathProvider provider, string expectedDirectory, string expectedFilePrefix, string expectedExtension)
    {
        var newLogPaths = Enumerable.Range(0, 10)
            .Select(_ => provider.GetNewLogPath())
            .ToImmutableHashSet();
        Assert.Equal(10, newLogPaths.Count);

        foreach (var newLogPath in newLogPaths)
        {
            var newLogDirectory = Path.GetDirectoryName(newLogPath);
            var newLogFileName = Path.GetFileNameWithoutExtension(newLogPath);
            var newLogExtension = Path.GetExtension(newLogPath);

            Assert.Equal(expectedDirectory, newLogDirectory);
            Assert.StartsWith(expectedFilePrefix, newLogFileName);
            Assert.Equal(expectedExtension, newLogExtension);
        }
    }
}