public void LoadSaveGame_FileNotFound_ReturnsFileNotFoundErrorText( [Frozen] IMainModel model, [Frozen] IBackupService backupService, [Frozen] IRemoveWaggonsService removeWaggonsService, [Frozen] IMoveObjectsService moveObjectsService, [Frozen] IMoveTracksService moveTracksService, [Frozen] IMoveWaggonsService moveWaggonsService, string filePath ) { //Arrange var mockedFileSystem = new MockFileSystem(); model.FileName.Returns(filePath); var sut = new SavegameService(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, mockedFileSystem); //Act var result = sut.LoadSavegame(); result.Should().Be($"Error: File {filePath} not Found."); model.FileContent.Should().BeEmpty(); backupService.ReceivedCalls().Should().BeEmpty(); removeWaggonsService.ReceivedCalls().Should().BeEmpty(); }
public void LoadSaveGame_FileCanBeReadWithoutError_ReturnsEmptyString( [Frozen] IMainModel model, [Frozen] IBackupService backupService, [Frozen] IRemoveWaggonsService removeWaggonsService, [Frozen] IMoveObjectsService moveObjectsService, [Frozen] IMoveTracksService moveTracksService, [Frozen] IMoveWaggonsService moveWaggonsService, string fileContent, string filePath ) { //Arrange var mockedFileSystem = new MockFileSystem(); var mockedFileContent = new MockFileData(fileContent); mockedFileSystem.AddFile(filePath, mockedFileContent); model.FileName.Returns(filePath); var sut = new SavegameService(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, mockedFileSystem); //Act var result = sut.LoadSavegame(); result.Should().BeEmpty(); model.FileContent.Should().Be(fileContent); backupService.ReceivedCalls().Should().BeEmpty(); removeWaggonsService.ReceivedCalls().Should().BeEmpty(); }
public SavegameService( IMainModel model, IBackupService backupService, IRemoveWaggonsService removeWaggonsService, IMoveObjectsService moveObjectsService, IMoveTracksService moveTracksService, IMoveWaggonsService moveWaggonsService) : this(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, new FileSystem()) { }
public SavegameService( IMainModel model, IBackupService backupService, IRemoveWaggonsService removeWaggonsService, IMoveObjectsService moveObjectsService, IMoveTracksService moveTracksService, IMoveWaggonsService moveWaggonsService, IFileSystem fileSystem) { _model = model; _backupService = backupService; _removeWaggonsService = removeWaggonsService; _moveObjectsService = moveObjectsService; _moveTracksService = moveTracksService; _moveWaggonsService = moveWaggonsService; _fileSystem = fileSystem; }
private void InitializeServices() { _backupService = new BackupService(_model); _reformatService = new ReformatService(_model); _findWaggonsRegExService = new FindWaggonsRegExService(); _removeWaggonsService = new RemoveWaggonsService(_model, _reformatService, _findWaggonsRegExService); _findObjectsRegExService = new FindObjectsRegExService(); _findTracksRegExService = new FindTracksRegExService(); _parseAndAddFloatValue = new ParseAndAddFloatValue(); _moveCoWireObjectService = new MoveCoWireObjectService(_model, _parseAndAddFloatValue); _moveObjectsService = new MoveObjectsService(_model, _findObjectsRegExService, _moveCoWireObjectService, _parseAndAddFloatValue); _moveTracksService = new MoveTracksService(_model, _findTracksRegExService, _parseAndAddFloatValue); _moveWaggonsService = new MoveWaggonsService(_model, _findWaggonsRegExService, _parseAndAddFloatValue); _savegameService = new SavegameService(_model, _backupService, _removeWaggonsService, _moveObjectsService, _moveTracksService, _moveWaggonsService); }