private static async Task <bool> DefaultDatabaseSizeHasChangedAsync() { bool DatabaseSizeHasChanged = false; string ErrorMessage; StorageFile ResourceFile, InstalledFile; ulong NewDBSize, CurrentDBSize; try { ResourceFile = await Package.Current.InstalledLocation.GetFileAsync(@"DataLayer\" + App.DefaultDBName); NewDBSize = (await ResourceFile.GetBasicPropertiesAsync()).Size; InstalledFile = await ApplicationData.Current.LocalFolder.GetFileAsync(App.DefaultDBName); CurrentDBSize = (await InstalledFile.GetBasicPropertiesAsync()).Size; DatabaseSizeHasChanged = NewDBSize != CurrentDBSize; } catch (Exception e) { ErrorMessage = e.Message; //TODO: log message } return(DatabaseSizeHasChanged); }
public void TestInstallSingleFile() { var descriptor = new ApplicationDescriptor { Name = "TestInstallSingleFile", }; string fullPath = InternalWatchdog.Resolve(descriptor.Name, Environment.SpecialFolder.CommonApplicationData, "SharpRemote.dll"); var original = new FileInfo(_sharpRemoteLibraryLocation); if (File.Exists(fullPath)) { File.Delete(fullPath); } InstalledApplication app; using (var installer = new ApplicationInstaller(_watchdog, descriptor)) { installer.AddFile(_sharpRemoteLibraryLocation, Environment.SpecialFolder.CommonApplicationData); app = installer.Commit(); } app.Descriptor.Should().Be(descriptor); app.Files.Count.Should().Be(1); InstalledFile file = app.Files[0]; file.Id.Should().Be(1); file.Folder.Should().Be(Environment.SpecialFolder.CommonApplicationData); file.Filename.Should().Be("SharpRemote.dll"); file.FileLength.Should().Be(original.Length); var copy = new FileInfo(fullPath); copy.Exists.Should().BeTrue("Because the file should've been created during the installation"); copy.Length.Should().Be(file.FileLength); FilesAreEqual(original, copy).Should().BeTrue(); }
public void AddFileToRemove(InstalledFile file) { _filesToRemove.Add(file); }