コード例 #1
0
        public GameSetting GetGameSetting(string gameName, string publisherName, string developerName, string platformFolder, string gameRootFolder, List <DisableIntroductionAction> disablingIntroductionActions, IllustrationPlatformEnum platformType, string illustrationUrl)
        {
            //Determine if illustration is valid
            var action  = new ValidateIllustrationAction(platformType, illustrationUrl);
            var isValid = action.Execute();

            //Determine illustration Code
            var illustration     = IllustrationPlatformEnum.Unknown;
            var illustrationCode = string.Empty;

            if (isValid)
            {
                var extractIllustrationCodeAction = new ExtractIllustrationCodeAction(platformType, illustrationUrl);
                illustrationCode = extractIllustrationCodeAction.Execute();
                illustration     = platformType;
            }

            //Determine rootValidationRule
            var generateRootValidationRulesAction = new GenerateRootValidationRulesAction(_fileSystemDal);
            var validationRules = generateRootValidationRulesAction.Execute(Path.Combine(platformFolder, gameRootFolder)).ToList();

            //Create new game settings
            var generateNewGameSetting = new GenerateNewGameSettingAction(_gameSettingsRepository);

            return(generateNewGameSetting.Execute(gameName, publisherName, developerName, platformFolder,
                                                  gameRootFolder, disablingIntroductionActions, validationRules, illustration, illustrationCode));
        }
        public void GameRootFolderDontExists()
        {
            //Test data
            const string dirFolder = "customDirFolder";

            //Set mocks
            var fileSystemDalMock = MockRepository.GenerateMock <IFileSystemDal>();

            fileSystemDalMock.Expect(x => x.DirectoryExists(Arg <string> .Is.Equal(dirFolder))).Return(false);

            //Run Tests
            var action = new GenerateRootValidationRulesAction(fileSystemDalMock);

            action.Execute(dirFolder).ToList();
        }
        public void GetAllExesRules()
        {
            //Test data
            const string rootDirFolder = "customDirFolder";
            var          dirList       = new List <DirectoryInfo>();

            //Set stubs
            var dir1 = MockRepository.GenerateStub <DirectoryInfo>();

            dir1.Stub(x => x.Name).Return("subfolder1");
            dir1.Stub(x => x.FullName).Return("fullPathSubfolder1");
            dirList.Add(dir1);

            var exe1 = MockRepository.GenerateStub <FileInfo>();

            exe1.Stub(x => x.Name).Return("exe1.exe");
            exe1.Stub(x => x.FullName).Return(@"customDirFolder\exe1.exe");

            var exe2 = MockRepository.GenerateStub <FileInfo>();

            exe2.Stub(x => x.Name).Return("exe2.exe");
            exe2.Stub(x => x.FullName).Return(@"customDirFolder\subfolder1\exe2.exe");

            //Set mocks
            var fileSystemDalMock = MockRepository.GenerateMock <IFileSystemDal>();

            fileSystemDalMock.Expect(x => x.DirectoryExists(Arg <string> .Is.Anything)).Return(true);
            fileSystemDalMock.Expect(x => x.DirectoryGetChildren(Arg <string> .Is.Equal(rootDirFolder))).Return(dirList);
            fileSystemDalMock.Expect(x => x.DirectoryGetChildren(Arg <string> .Is.Anything)).Return(new DirectoryInfo[0]);
            fileSystemDalMock.Expect(x => x.GetFiles(Arg <string> .Is.Equal(rootDirFolder))).Return(new [] { exe1 });
            fileSystemDalMock.Expect(x => x.GetFiles(Arg <string> .Is.Equal(dir1.FullName))).Return(new[] { exe2 });

            //Run Tests
            var action = new GenerateRootValidationRulesAction(fileSystemDalMock);
            var result = action.Execute(rootDirFolder).ToList();

            //Validate
            fileSystemDalMock.VerifyAllExpectations();
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(RootValidationTypeEnum.FolderValidation, result[0].Type);
            Assert.AreEqual(dir1.Name, result[0].WitnessName);
            Assert.AreEqual(RootValidationTypeEnum.FileValidation, result[1].Type);
            Assert.AreEqual(exe1.Name, result[1].WitnessName);
            Assert.AreEqual(RootValidationTypeEnum.FileValidation, result[2].Type);
            Assert.AreEqual(dir1.Name + "\\" + exe2.Name, result[2].WitnessName);
        }