public void ShouldKeepSizeTheSameWhenAddingNewMessage() { long size = 2 * 1024 * 1024; // 2 mega var password = new byte[] { 0x33, 0xFF, 0xAB }; ReynaService.ResetStorageSizeLimit(); var sqliteRepository = new SQLiteRepository(new ReynaNullLogger(), password); sqliteRepository.Create(); var reynaService = new ReynaService(password, null, false, new ReynaNullLogger()); reynaService.Start(); var assemblyFile = new FileInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); var path = Path.Combine(assemblyFile.DirectoryName, "reyna.db"); ReynaService.SetStorageSizeLimit(new ReynaNullLogger(), password, size); putMessageFromFile(reynaService, assemblyFile.DirectoryName, 100); reynaService.Stop(); var fileInfo = new FileInfo(path); Assert.AreEqual(1812480, fileInfo.Length); File.Delete(path); }
public void ShouldEncryptDbIfPasswordIsPassedAndDbIsNotEncrypted() { var sqliteRepository = new SQLiteRepository(new ReynaNullLogger(), new byte[] { 0x33, 0xFF, 0xAB }); sqliteRepository.Create(); var reynaService = new ReynaService(new byte[] { 0x33, 0xFF, 0xAB }, null, false, new ReynaNullLogger()); reynaService.Start(); var assemblyFile = new FileInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); var path = Path.Combine(assemblyFile.DirectoryName, "reyna.db"); var bytes = new byte[16]; using (var file = File.OpenRead(path)) { file.Read(bytes, 0, bytes.Length); } var stringResult = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length); Assert.AreNotEqual("SQLite format 3\0", stringResult); reynaService.Stop(); File.Delete(path); }
public void IfDatabaseIsEncryptedButConnectionMissingPasswordShouldThrowException() { var sqliteRepository = new SQLiteRepository(new ReynaNullLogger(), new byte[] { 0xFF, 0xEE, 0xDD, 0x10, 0x20, 0x30 }); sqliteRepository.Create(); var assemblyFile = new FileInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); var path = Path.Combine(assemblyFile.DirectoryName, "reyna.db"); this.ExecuteScalar("SELECT count(1) FROM sqlite_master WHERE type='table' AND name not like 'sqlite?_%' escape '?'", path); File.Delete(path); }