Exemple #1
0
        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);
        }
Exemple #2
0
        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 StartStopDisposeShouldWork()
 {
     var reynaService = new ReynaService(false, this.Logger.Object);
     Assert.Null(reynaService.NetworkStateService);
     reynaService.Start();
     System.Threading.Thread.Sleep(1000);
     reynaService.Stop();
     reynaService.Stop();
     reynaService.Stop();
     reynaService.Dispose();
     reynaService.Dispose();
     reynaService.Dispose();
 }
        public void StartStopDisposeShouldWork()
        {
            var reynaService = new ReynaService(null, null, false, this.Logger.Object);

            Assert.Null(reynaService.NetworkStateService);
            reynaService.Start();
            System.Threading.Thread.Sleep(1000);
            reynaService.Stop();
            reynaService.Stop();
            reynaService.Stop();
            reynaService.Dispose();
            reynaService.Dispose();
            reynaService.Dispose();
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            var store = new ReynaService();

            store.Start();
            Time from = new Time(10, 00);
            Time to = new Time(12, 59);
            ReynaService.SetCellularDataBlackout(new TimeRange(from, to));

            store.Put(GetMessage());
            store.Put(GetMessage());
            store.Put(GetMessage());

            Thread.Sleep(100);

            store.Put(GetMessage());
            store.Put(GetMessage());
            store.Put(GetMessage());

            store.Stop();
        }
Exemple #6
0
        public static void Main(string[] args)
        {
            var store = new ReynaService(null, null, false, new ReynaNullLogger());

            store.Start();
            Time from = new Time(10, 00);
            Time to   = new Time(12, 59);

            ReynaService.SetCellularDataBlackout(new TimeRange(from, to));

            store.Put(GetMessage());
            store.Put(GetMessage());
            store.Put(GetMessage());

            Thread.Sleep(100);

            store.Put(GetMessage());
            store.Put(GetMessage());
            store.Put(GetMessage());

            store.Stop();
        }
        public void WhenCallingStartAndPasswordIsSetAndDbIsNotEncryptedShouldEncryptDbUsingPassword()
        {
            var helper = new TestUnityHelper();
            var container = helper.GetContainer();
            byte[] bytes = Encoding.ASCII.GetBytes("password");
            ReynaService service = new ReynaService(bytes, container);
            helper.mockEncryptionChecker.Setup(m => m.DbEncrypted()).Returns(false);

            service.Start();

            helper.mockEncryptionChecker.Verify(m => m.EncryptDb(bytes), Times.Exactly(1));
        }
        public void WhenCallingStartAndPasswordIsNotSetAndShouldNotEncryptDb()
        {
            var helper = new TestUnityHelper();
            var container = helper.GetContainer();
            ReynaService service = new ReynaService(null, container);

            service.Start();

            helper.mockEncryptionChecker.Verify(m => m.DbEncrypted(), Times.Never);
        }