public void ProjectBindingOperation_GenerateNewProjectRuleSetPath_DesiredFileNameExists_AppendsNumberToFileName()
        {
            // General setup
            const string             ruleSetRootPath = @"X:\";
            const string             fileName        = "NameTaken";
            CSharpVBBindingOperation testSubject     = this.CreateTestSubject();

            // Test case 1: desired name exists
            // Arrange
            fileSystem.AddFile($"X:\\NameTaken.ruleset", new MockFileData(""));

            // Act
            string actual = testSubject.GenerateNewProjectRuleSetPath
                            (
                ruleSetRootPath,
                fileName
                            );

            // Assert
            actual.Should().Be($"X:\\{fileName}-1.ruleset", "Expected to append running number to desired file name, skipping the default one since exists");

            // Test case 2: desired name + 1 + 2 exists
            // Arrange
            fileSystem.AddFile(@"X:\NameTaken-1.ruleset", new MockFileData(""));
            fileSystem.AddFile(@"X:\NameTaken-2.ruleset", new MockFileData(""));

            // Act
            actual = testSubject.GenerateNewProjectRuleSetPath
                     (
                ruleSetRootPath,
                fileName
                     );

            // Assert
            actual.Should().Be(@"X:\NameTaken-3.ruleset", "Expected to append running number to desired file name");

            // Test case 3: has a pending write (not exists yet)
            ((ISourceControlledFileSystem)this.sccFileSystem).QueueFileWrite(@"X:\NameTaken-3.ruleset", () => true);

            // Act
            actual = testSubject.GenerateNewProjectRuleSetPath
                     (
                ruleSetRootPath,
                fileName
                     );

            // Assert
            actual.Should().Be(@"X:\NameTaken-4.ruleset", "Expected to append running number to desired file name, skipping 3 since pending write");
        }
        public void ProjectBindingOperation_GenerateNewProjectRuleSetPath_NoAvailableFileNames_AppendsGuid()
        {
            // Arrange
            const string             fileName        = "fileTaken";
            const string             ruleSetRootPath = @"X:\";
            CSharpVBBindingOperation testSubject     = this.CreateTestSubject();

            string[] existingFiles = Enumerable.Range(0, 10).Select(i => $@"X:\{fileName}-{i}.ruleset").ToArray();

            fileSystem.AddFile($@"X:\{fileName}.ruleset", new MockFileData(""));

            foreach (var existingFile in existingFiles)
            {
                fileSystem.AddFile(existingFile, new MockFileData(""));
            }

            // Act
            string actual = testSubject.GenerateNewProjectRuleSetPath
                            (
                ruleSetRootPath,
                fileName
                            );

            // Assert
            string actualFileName = Path.GetFileNameWithoutExtension(actual);

            actualFileName.Should().HaveLength(fileName.Length + 32 + 1, "Expected to append GUID to desired file name, actual: " + actualFileName);
        }
        public void ProjectBindingOperation_GenerateNewProjectRuleSetPath_FileNameHasDot_AppendsExtension()
        {
            // Arrange
            const string             ruleSetRootPath = @"X:\";
            const string             fileName        = "My.File.With.Dots";
            CSharpVBBindingOperation testSubject     = this.CreateTestSubject();
            string expected = $"X:\\My.File.With.Dots.ruleset";

            // Act
            string actual = testSubject.GenerateNewProjectRuleSetPath
                            (
                ruleSetRootPath,
                fileName
                            );

            // Assert
            actual.Should().Be(expected);
        }