public void Fallback_CalculatesAndDeDupesOnContentCorrectly()
        {
            // Arrange
            var testSubject = new BuildVNextCoverageSearchFallback(new TestLogger());
            var dir         = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString(), "TestResults");
            var subDir      = Path.Combine(dir, "subDir", "subDir2");

            Directory.CreateDirectory(subDir);

            var fileOne          = "fileNameOne.coverage";
            var fileTwo          = "fileNameTwo.coverage";
            var fileThree        = "fileNameThree.coverage";
            var fileOneDuplicate = "fileNameOneDuplicate.coverage";
            var expected1        = TestUtils.CreateTextFile(dir, fileOne, fileOne);
            var expected2        = TestUtils.CreateTextFile(dir, fileTwo, fileTwo);
            var expected3        = TestUtils.CreateTextFile(dir, fileThree, fileThree);

            TestUtils.CreateTextFile(dir, fileOneDuplicate, fileOne); // Same content as fileOne, should not be expected
            TestUtils.CreateTextFile(subDir, fileOne, fileOne);       // Same content and filename, but in other dir, as fileOne, should not be expected

            using (var envVars = new EnvironmentVariableScope())
            {
                envVars.SetVariable(BuildVNextCoverageSearchFallback.AGENT_TEMP_DIRECTORY, dir);

                // Act
                var actual = testSubject.FindCoverageFiles();

                // Assert
                actual.Should().BeEquivalentTo(expected1, expected2, expected3);
            }
        }
        public void Fallback_FilesLocatedCorrectly()
        {
            // Arrange
            var testSubject = new BuildVNextCoverageSearchFallback(new TestLogger());
            var dir         = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString(), "TestResults");
            var subDir      = Path.Combine(dir, "subDir", "subDir2");

            Directory.CreateDirectory(subDir);

            TestUtils.CreateTextFile(dir, "foo.coverageXXX", "1");
            TestUtils.CreateTextFile(dir, "abc.trx", "2");
            var expected1 = TestUtils.CreateTextFile(dir, "foo.coverage", "3");
            var expected2 = TestUtils.CreateTextFile(dir, "DUPLICATE.coverage", "4");

            TestUtils.CreateTextFile(dir, "BAR.coverage.XXX", "");
            TestUtils.CreateTextFile(dir, "Duplicate.coverage", "4");              // appears in both places - only one should be returned
            var expected3 = TestUtils.CreateTextFile(subDir, "BAR.COVERAGE", "5"); // should be found

            using (var envVars = new EnvironmentVariableScope())
            {
                envVars.SetVariable(BuildVNextCoverageSearchFallback.AGENT_TEMP_DIRECTORY, dir);

                // Act
                var actual = testSubject.FindCoverageFiles();

                // Assert
                actual.Should().BeEquivalentTo(expected1, expected2, expected3);
            }
        }