Ejemplo n.º 1
0
        public void ShouldKeepSizeTheSame()
        {
            long size = 2 * 1024 * 1024; // 2 mega
            var password = new byte[] { 0x33, 0xFF, 0xAB };

            ReynaService.ResetStorageSizeLimit();
            var sqliteRepository = new SQLiteRepository(password);
            sqliteRepository.Create();

            var reynaService = new ReynaService(password, null, new ReynaNullLogger());
            reynaService.Start();

            var assemblyFile = new FileInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
            var path = Path.Combine(assemblyFile.DirectoryName, "reyna.db");

            putMessageFromFile(reynaService, assemblyFile.DirectoryName, 100);
            
            FileInfo fileInfo = new FileInfo(path);
            Assert.AreEqual(5649408, fileInfo.Length);

            ReynaService.SetStorageSizeLimit(password, size);
            reynaService.Stop();
            fileInfo = new FileInfo(path);
            Assert.AreEqual(1754112, fileInfo.Length);
            File.Delete(path);
        }
Ejemplo n.º 2
0
        public void ShouldEncryptDbIfPasswordIsPassedAndDbIsNotEncrypted()
        {
            var sqliteRepository = new SQLiteRepository(new byte[] { 0x33, 0xFF, 0xAB });
            sqliteRepository.Create();

            var reynaService = new ReynaService(new byte[] { 0x33, 0xFF, 0xAB }, null, 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);
        }