public InstalledUpdate ApplyPreparedUpdate(IPreparedUpdate preparedUpdate) { AssertCanUpdate(preparedUpdate.Version); var oldVersionDir = _oldVersionDir; var basePrepDir = Path.Combine(_fileSystem.AppDirectory, ".updates"); var prepDir = Path.Combine(basePrepDir, preparedUpdate.Version.ToString()); if (_fileSystem.DirectoryExists(oldVersionDir)) { _fileSystem.DeleteDirectory(oldVersionDir, true); } foreach (var filePath in preparedUpdate.Files) { var fileName = Get(filePath, relativeTo: prepDir); var appFilePath = Path.Combine(_fileSystem.AppDirectory, fileName); if (_fileSystem.FileExists(appFilePath)) { _fileSystem.MoveFile(appFilePath, Path.Combine(oldVersionDir, fileName)); } _fileSystem.MoveFile(filePath, appFilePath); } _fileSystem.DeleteDirectory(basePrepDir, true); return(new InstalledUpdate(CurrentVersion, preparedUpdate.Version)); }
public InstalledUpdate ApplyPreparedUpdate(IPreparedUpdate preparedUpdate) { AssertCanUpdate(preparedUpdate.Version); var oldVersionDir = _oldVersionDir; var basePrepDir = Path.Combine(_fileSystem.AppDirectory, ".updates"); var prepDir = Path.Combine(basePrepDir, preparedUpdate.Version.ToString()); if (_fileSystem.DirectoryExists(oldVersionDir)) _fileSystem.DeleteDirectory(oldVersionDir, true); foreach (var filePath in preparedUpdate.Files) { var fileName = Get(filePath, relativeTo: prepDir); var appFilePath = Path.Combine(_fileSystem.AppDirectory, fileName); if (_fileSystem.FileExists(appFilePath)) { _fileSystem.MoveFile(appFilePath, Path.Combine(oldVersionDir, fileName)); } _fileSystem.MoveFile(filePath, appFilePath); } _fileSystem.DeleteDirectory(basePrepDir, true); return new InstalledUpdate(CurrentVersion, preparedUpdate.Version); }
void AndGivenAPreparedUpdateForANewerVersion() { _preparedUpdate = Substitute.For <IPreparedUpdate>(); _newVersion = new SemanticVersion(new Version(1, 1)); _preparedUpdate.Version.Returns(_newVersion); FileSystem.CreateDirectory(@"c:\app\.updates\1.1"); FileSystem.AddFile(Path.Combine(PrepDir, _appFile), MockFileContent(_appFile, _newVersion)); _preparedUpdate.Files.Returns(new[] { Path.Combine(PrepDir, _appFile) }); }
void AndGivenAPreparedUpdateForANewerVersion() { _preparedUpdate = Substitute.For<IPreparedUpdate>(); _newVersion = new Version(1, 1); _preparedUpdate.Version.Returns(_newVersion); FileSystem.CreateDirectory(@"c:\app\.updates\1.1"); FileSystem.AddFile(Path.Combine(PrepDir, _appFile), MockFileContent(_appFile, _newVersion)); _preparedUpdate.Files.Returns(new[] { Path.Combine(PrepDir, _appFile) }); }
void AndGivenAPreparedUpdateForANewerVersion() { _preparedUpdate = Substitute.For <IPreparedUpdate>(); _newVersion = new Version(1, 1); _preparedUpdate.Version.Returns(_newVersion); _newAppFiles = new[] { "app.exe", "app.exe.config", "nuget.dll", "app.core.dll", "content\\logo.png" }; FileSystem.CreateDirectory(@"c:\app\.updates\1.1"); foreach (var file in _newAppFiles) { FileSystem.AddFile(Path.Combine(PrepDir, file), MockFileContent(file, _newVersion)); } _preparedUpdate.Files.Returns(_newAppFiles.Select(file => Path.Combine(PrepDir, file))); }
void AndGivenAPreparedUpdateForANewerVersion() { _preparedUpdate = Substitute.For<IPreparedUpdate>(); _newVersion = new Version(1, 1); _preparedUpdate.Version.Returns(_newVersion); _newAppFiles = new[] { "app.exe", "app.exe.config", "nuget.dll", "app.core.dll", "content\\logo.png" }; FileSystem.CreateDirectory(@"c:\app\.updates\1.1"); foreach (var file in _newAppFiles) { FileSystem.AddFile(Path.Combine(PrepDir, file), MockFileContent(file, _newVersion)); } _preparedUpdate.Files.Returns(_newAppFiles.Select(file => Path.Combine(PrepDir, file))); }
void WhenTheUpdateIsPrepared() { _preparedUpdate = _appUpdater.PrepareUpdate(_package); }
void AndGivenAPreparedUpdateForAnOlderVersion() { _preparedUpdate = Substitute.For <IPreparedUpdate>(); _preparedUpdate.Version.Returns(new Version(1, 0)); }
void AndGivenAPreparedUpdateForAnOlderVersion() { _preparedUpdate = Substitute.For<IPreparedUpdate>(); _preparedUpdate.Version.Returns(new Version(1, 0)); }
void AndGivenAPreparedUpdateForTheInstalledVersion() { _preparedUpdate = Substitute.For <IPreparedUpdate>(); _preparedUpdate.Version.Returns(_installedVersion); }
void AndGivenAPreparedUpdateForTheInstalledVersion() { _preparedUpdate = Substitute.For<IPreparedUpdate>(); _preparedUpdate.Version.Returns(_installedVersion); }