Пример #1
0
        public void AddNewFolder_PathDontExists_CustomFileAlreadyCreated()
        {
            const string pathToDefaultSettingFile = "myDefaultPath";
            const string pathToCustomSettingFile  = "myCustomPath";
            var          customDirectories        = "[\"dir1\", \"dir2\"]";
            const string newPathToAdd             = "dir3";

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

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

            var repo = new InstallationDirectoriesRepository(globalSettingsStub, dalMock);
            repo.AddNewInstallFolder(newPathToAdd);

            #region Validate
            dalMock.VerifyAllExpectations();
            #endregion
        }
 public void AddInstallationFolder(string path)
 {
     _repository.AddNewInstallFolder(path);
 }