Ejemplo n.º 1
0
        public void SingleFileToRenameWtComplexNavigation()
        {
            //Set constants
            const string installPath  = @"C:\Temp";
            const string fileToRename = @"\videos\*\data\second\*\Nvidia.bk2";

            //Set dependancies
            var settings = new GameSetting()
            {
                DisablingIntroductionActions = new List <DisableIntroductionAction>()
                {
                    new DisableIntroductionAction()
                    {
                        Type        = DisableActionTypeEnum.FileRename,
                        InitialName = fileToRename,
                    }
                }
            };

            var gameDetectionResult = new GameDetectionResult("wat")
            {
                InstallationPath  = new DirectoryInfo(installPath),
                Detected          = true,
                IntroductionState = IntroductionStateEnum.Disabled
            };

            //Set Mocks
            var pathPatternTranslatorMock = MockRepository.GenerateMock <IPathPatternTranslator>();

            pathPatternTranslatorMock.Expect(x => x.GetPathFromPattern($"{installPath}{fileToRename}")).Return(new[]
            {
                @"C:\Temp\videos\sub1\data\second\third1\Nvidia.bk2",
                @"C:\Temp\videos\sub1\data\second\third2\Nvidia.bk2",
                @"C:\Temp\videos\sub2\data\second\third3\Nvidia.bk2",
                @"C:\Temp\videos\sub2\data\second\third4\Nvidia.bk2"
            });

            var fileAndFolderRenamerMock = MockRepository.GenerateMock <IFileAndFolderRenamer>();

            fileAndFolderRenamerMock.Expect(x => x.RenameFile(Arg <string> .Is.Equal($@"C:\Temp\videos\sub1\data\second\third1\Nvidia.bk2{GlobalNamesStruct.RenameSuffix}"), Arg <string> .Is.Equal(@"C:\Temp\videos\sub1\data\second\third1\Nvidia.bk2"), Arg <bool> .Is.Equal(false)));
            fileAndFolderRenamerMock.Expect(x => x.RenameFile(Arg <string> .Is.Equal($@"C:\Temp\videos\sub1\data\second\third2\Nvidia.bk2{GlobalNamesStruct.RenameSuffix}"), Arg <string> .Is.Equal(@"C:\Temp\videos\sub1\data\second\third2\Nvidia.bk2"), Arg <bool> .Is.Equal(false)));
            fileAndFolderRenamerMock.Expect(x => x.RenameFile(Arg <string> .Is.Equal($@"C:\Temp\videos\sub2\data\second\third3\Nvidia.bk2{GlobalNamesStruct.RenameSuffix}"), Arg <string> .Is.Equal(@"C:\Temp\videos\sub2\data\second\third3\Nvidia.bk2"), Arg <bool> .Is.Equal(false)));
            fileAndFolderRenamerMock.Expect(x => x.RenameFile(Arg <string> .Is.Equal($@"C:\Temp\videos\sub2\data\second\third4\Nvidia.bk2{GlobalNamesStruct.RenameSuffix}"), Arg <string> .Is.Equal(@"C:\Temp\videos\sub2\data\second\third4\Nvidia.bk2"), Arg <bool> .Is.Equal(false)));

            //Run test
            var businessRule = new ApplyReenableIntroAction(settings, gameDetectionResult, fileAndFolderRenamerMock, pathPatternTranslatorMock);

            businessRule.Execute();

            //Validate
            pathPatternTranslatorMock.VerifyAllExpectations();
            fileAndFolderRenamerMock.VerifyAllExpectations();
        }
Ejemplo n.º 2
0
        public void ReenableIntro(Game targetedGame)
        {
            var reenableIntro = new ApplyReenableIntroAction(targetedGame.Settings, targetedGame.DetectionResult, _fileAndFolderRenamer, _pathPatternTranslator);

            reenableIntro.Execute();
        }