public void WhenCallingDisposeAndServicesAreNullShouldNotDisposeServices()
 {
     var helper = new TestUnityHelper();
     var container = helper.GetContainer();
     ReynaService service = new ReynaService(null, container);
     service.StoreService = null;
     service.ForwardService = null;
     service.NetworkStateService = null;
     service.Dispose();
     helper.mockStoreService.Verify(s => s.Dispose(), Times.Never);
     helper.mockForwardService.Verify(s => s.Dispose(), Times.Never);
     helper.mockNetworkStateService.Verify(s => s.Dispose(), Times.Never);
 }
        public void WhenConstructingWithAPasswordShouldSetPasswordOnSecureStore()
        {
            var helper = new TestUnityHelper();
            var container = helper.GetContainer();
            byte[] bytes = Encoding.ASCII.GetBytes("password");

            helper.mockSqlStore.SetupSet(s => s.Password = bytes).Verifiable();

            ReynaService service = new ReynaService(bytes, container);

            helper.mockSqlStore.VerifySet(s => s.Password=bytes, Times.Exactly(1));
        }
        public void WhenConstructingWithoutAPasswordShouldnotSetPasswordOnSecureStore()
        {
            var helper = new TestUnityHelper();
            var container = helper.GetContainer();

            helper.mockSqlStore.SetupSet(s => s.Password = It.IsAny<byte[]>()).Verifiable();

            ReynaService service = new ReynaService(null, container);

            helper.mockSqlStore.VerifySet(s => s.Password = It.IsAny<byte[]>(), Times.Never);
        }
 public void WhenConstructingWithAPasswordPasswordFieldShouldBeSet()
 {
     byte[] bytes = Encoding.ASCII.GetBytes("password");
     var helper = new TestUnityHelper();
     var container = helper.GetContainer();
     ReynaService service = new ReynaService(bytes, container);
     Assert.True(bytes.SequenceEqual(service.Password));
 }
 public void WhenConstructingShouldCallInitialiseOnStoreService()
 {
     var helper = new TestUnityHelper();
     var container = helper.GetContainer();
     ReynaService service = new ReynaService(null, container);
     helper.mockStoreService.Verify(s => s.Initialize(helper.mockVolatileStore.Object, helper.mockSqlStore.Object), Times.Exactly(1));
 }
 public void WhenConstructingShouldCallInitialiseOnForwardService()
 {
     var helper = new TestUnityHelper();
     var container = helper.GetContainer();
     ReynaService service = new ReynaService(null, container);
     helper.mockForwardService.Verify(s => s.Initialize(helper.mockSqlStore.Object, helper.mockHttpClient.Object, helper.mockNetworkStateService.Object, It.IsAny<int>(), It.IsAny<int>(), It.IsAny<bool>()), Times.Exactly(1));
 }
        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);
        }