public void CopyFilesWhenIndicated(bool shouldInitialize) { var initializationDeterminer = new MockLevelInitializationDeterminer(shouldInitialize); var copyDir = new MockCopyDir(); var levelId = "level"; var levelToInitialize = new Level(id: levelId, folderFilepath: "."); var levelsProvider = new FakeLevelsProvider(new[] { levelToInitialize }); var mockFileSystem = new MockFileSystem(); mockFileSystem.AddDirectory(levelToInitialize.GetMasterFolder()); //will throw error if no master folder var masterFolderLevelInitializer = new MasterFolderLevelInitializer(initializationDeterminer, copyDir, levelsProvider, mockFileSystem.Path); var someUser = "******"; masterFolderLevelInitializer.InitializeIfNecessary(levelId, someUser); Assert.Equal(shouldInitialize, copyDir.DidCopy); Assert.Equal(shouldInitialize, initializationDeterminer.IsMarkedAsInitialized); }
public void ThrowExceptionIfMasterFolderDoesNotExist(FakeLevelsProvider fakeLevelsProvider, string levelId, string user, string expectedSourceDir, string expectedDestDir) { var determinerIndicatingInitialization = new MockLevelInitializationDeterminer(true); var copyDir = new MockCopyDir(); var path = new MockPath(new MockFileSystem()); var masterFolderLevelInitializer = new MasterFolderLevelInitializer(determinerIndicatingInitialization, copyDir, fakeLevelsProvider, path); var exception = Assert.Throws <DirectoryNotFoundException>(() => masterFolderLevelInitializer.InitializeIfNecessary(levelId, user)); Assert.Equal($"Master folder for level {levelId} not found.", exception.Message); }
public void CopyCorrectFilesToCorrectLocation(FakeLevelsProvider fakeLevelsProvider, string levelId, string user, string expectedSourceDir, string expectedDestDir) { var determinerIndicatingInitialization = new MockLevelInitializationDeterminer(true); var copyDir = new MockCopyDir(); var mockFileSystem = new MockFileSystem(); foreach (var level in fakeLevelsProvider.GetLevels()) { mockFileSystem.AddDirectory(level.GetMasterFolder()); //put master folder in every level folder to prevent error } var masterFolderLevelInitializer = new MasterFolderLevelInitializer(determinerIndicatingInitialization, copyDir, fakeLevelsProvider, mockFileSystem.Path); masterFolderLevelInitializer.InitializeIfNecessary(levelId, user); Assert.Equal(expectedSourceDir, copyDir.SuppliedSourceDir); Assert.Equal(expectedDestDir, copyDir.SuppliedDestDir); }