Esempio n. 1
0
        public void GetAllInstallationFolders_UserFileCreated()
        {
            const string pathToDefaultSettingFile = "myDefaultPath";
            const string pathToCustomSettingFile  = "myCustomPath";
            var          customDirectories        = "[\"dir1\",\"dir2\"]";

            #region Stubs and Mocks
            var globalSettingsStub = MockRepository.GenerateMock <GlobalSettings>();
            globalSettingsStub.DefaultInstallFolderConfigFile = pathToDefaultSettingFile;
            globalSettingsStub.CustomInstallFolderConfigFile  = pathToCustomSettingFile;

            var dalMock = MockRepository.GenerateMock <IFileSystemDal>();
            dalMock.Expect(x => x.FileExists(pathToCustomSettingFile)).Return(true);
            dalMock.Expect(x => x.ReadAllText(Arg <string> .Is.Equal(pathToDefaultSettingFile))).Repeat.Never();
            dalMock.Expect(x => x.ReadAllText(Arg <string> .Is.Equal(pathToCustomSettingFile))).Return(customDirectories);
            #endregion

            var repo = new InstallationDirectoriesRepository(globalSettingsStub, dalMock);
            var installationFolders = repo.GetAllInstallationFolders().ToList();

            #region Validate
            dalMock.VerifyAllExpectations();
            Assert.AreEqual(2, installationFolders.Count);
            Assert.IsNotNull(installationFolders.Where(x => x.Name == "dir1"));
            Assert.IsNotNull(installationFolders.Where(x => x.Name == "dir2"));
            #endregion
        }
        public Game GetGameFromSettings(GameSetting setting)
        {
            var allInstallDirs      = _installationDirRepository.GetAllInstallationFolders();
            var detectStatusAction  = new DetectGameStatus(setting, allInstallDirs);
            var gameDetectionResult = detectStatusAction.Execute();

            return(_gameFactory.GetGame(setting, gameDetectionResult));
        }
        public IEnumerable <Game> Execute()
        {
            //Load all game settings
            var gameSettings = _settingsRepository.GetAllGameSettings();

            //Load all repository to look at
            var installationRepositories = _installationDirectoryRepository.GetAllInstallationFolders().ToList();

            //Browse and detect installed games
            foreach (var gameSetting in gameSettings)
            {
                var gameDetection       = new DetectGameStatus(gameSetting, installationRepositories);
                var gameDetectionResult = gameDetection.Execute();

                yield return(_gameFact.GetGame(gameSetting, gameDetectionResult));
            }
        }
 public string[] GetAllInstallFolder()
 {
     return(_repository.GetAllInstallationFolders().Select(x => x.FullName).ToArray());
 }