Esempio n. 1
0
        public LoginViewModel()
        {
            cache = DependencyService.Get <SubscriptionsCache>();

            string emptyValidationMessage = Translations.Validations_NullOrEmptyMessage;
            var    emptyRule = new IsNotNullOrEmptyRule
            {
                ValidationMessage = emptyValidationMessage,
            };

            password = new ValidatableObject <string>();
            password.Validations.Add(emptyRule);

            clientId = new ValidatableObject <string>();
            clientId.Validations.Add(emptyRule);

            tenantId = new ValidatableObject <string>();
            tenantId.Validations.Add(emptyRule);

#if DEBUG
            /*
             * Avoid having to enter credentials every time app is deployed
             * during development
             */

            ClientId.Value = AppSettings.ClientId;
            TenantId.Value = AppSettings.TenantId;


            ClientId.IsValid = TenantId.IsValid = Password.IsValid = true;
#else
            ClientId.IsValid = TenantId.IsValid = Password.IsValid = false;
#endif
        }
        public IConfigurable[] Find <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy) where T : IConfigurable, new()
        {
            SubscriptionsCache cacheForRead = this.GetCacheForRead();

            return(new IConfigurable[]
            {
                cacheForRead
            });
        }
Esempio n. 3
0
        public void Add_WithSubscriber_ReturnsSubscriptionWithSameTopicType()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            var subscription = cache.Add <Topic>(subscriber);

            // Assert
            Assert.That(subscription.TopicType, Is.EqualTo(typeof(Topic)));
        }
Esempio n. 4
0
        public void Add_WithSubscriber_ReturnsSubscription()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            var subscription = cache.Add <Topic>(subscriber);

            // Assert
            Assert.That(subscription, Is.Not.Null);
        }
Esempio n. 5
0
        public void Add_WithNullSubscriber_ThrowsArgumentNullException()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            TestDelegate add = () => cache.Add <Topic>(null);

            // Assert
            Assert.That(add, Throws.ArgumentNullException);
        }
Esempio n. 6
0
        public void Remove_WithNoSubscriptionAdded_DoesNothing()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            TestDelegate remove = () => cache.Remove <Topic>(subscriber);

            // Assert
            Assert.That(remove, Throws.Nothing);
        }
Esempio n. 7
0
        public void Add_WhenSubscriptionDisposeCalled_CallsSubscriberUnsubscribe()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            cache.Add <Topic>(subscriber).Dispose();

            // Assert
            mockSubscriber.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }
        private SubscriptionsCache GetCacheForRead()
        {
            SubscriptionsCache subscriptionsCache = new SubscriptionsCache();

            subscriptionsCache.SetIdentity(this.userPrincipal.ObjectId);
            if (this.cacheAction == SubscriptionCacheAction.None || this.cacheAction == SubscriptionCacheAction.Validate)
            {
                this.TestUserCache(subscriptionsCache);
            }
            return(subscriptionsCache);
        }
Esempio n. 9
0
        public void Add_CalledTwiceWithDifferentSubscribers_ReturnsDifferentSubscriptionInstance()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            var sub1 = cache.Add <Topic>(subscriber);
            var sub2 = cache.Add <Topic>(subscriber2);

            // Assert
            Assert.That(sub1, Is.Not.SameAs(sub2));
        }
Esempio n. 10
0
        public void Remove_WithSubscriptionAdded_CallsSubscriberUnsubscribe()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            cache.Add <Topic>(subscriber);

            // Act
            cache.Remove <Topic>(subscriber);

            // Assert
            mockSubscriber.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }
Esempio n. 11
0
        public void Remove_WithTwoSubscriptionsAdded_CallsCorrectUnsubscribe_2()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            cache.Add <Topic>(subscriber);
            cache.Add <Topic>(subscriber2);

            // Act
            cache.Remove <Topic>(subscriber2);

            // Assert
            mockSubscriber2.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }
Esempio n. 12
0
        public void Remove_WhenCalledForSameSubscriberTwice_UnsubscribesOnce()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            cache.Add <Topic>(subscriber);

            // Act
            cache.Remove <Topic>(subscriber);
            cache.Remove <Topic>(subscriber);

            // Assert
            mockSubscriber.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }
Esempio n. 13
0
        public Builder(string name)
        {
            this.name          = name;
            TopicRouter        = new TopicRouter();
            MonitorCache       = new MonitorCache();
            RequestRouter      = new RequestRouter();
            PackageFactory     = new PackageFactory();
            TopicDispatcher    = new TopicDispatcher();
            RequestDispatcher  = new RequestDispatcher();
            SubscriptionsCache = new SubscriptionsCache();
            SerializerCache    = new SerializerCache();

            SenderCache     = new SenderCache(RequestRouter, MonitorCache);
            ReceiverCache   = new ReceiverCache(MonitorCache);
            PublisherCache  = new PublisherCache(MonitorCache);
            SubscriberCache = new SubscriberCache(TopicRouter, MonitorCache, SubscriptionsCache);
        }
        public ResourceGroupViewModel()
        {
            useExistingResourceGroup = true;
            newResourceGroupName     = new ValidatableObject <string>();
            newResourceGroupName.Validations.Add(
                new IsNotNullOrEmptyRule()
            {
                ValidationMessage = Translations.Validations_ResourceGroup_RequiredName,
            });
            newResourceGroupName.Validations.Add(
                new EvalValidationRule <string>(
                    CheckResourceGroupName,
                    Translations.Validations_ResourceGroup_InvalidName));
            newResourceGroupName.Validations.Add(
                new EvalValidationRule <string>(
                    CheckResourceGroupUnique,
                    Translations.Validations_ResourceGroup_DuplicatedName));

            subscriptionCache = DependencyService.Get <SubscriptionsCache>();
        }
Esempio n. 15
0
        private void TestUserCache(SubscriptionsCache subscriptionsCache)
        {
            string serverFqdn         = this.userPrincipal.MailboxInfo.Location.ServerFqdn;
            string primarySmtpAddress = this.userPrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
            string failureReason;
            uint   num;
            List <SubscriptionCacheObject> subscriptionCacheObjects;
            ObjectState objectState;

            if (!SubscriptionCacheClient.TryTestUserCache(serverFqdn, primarySmtpAddress, this.cacheAction, out failureReason, out num, out subscriptionCacheObjects, out objectState))
            {
                subscriptionsCache.FailureReason = failureReason;
                return;
            }
            uint num2 = num;

            if (num2 != 0U)
            {
                switch (num2)
                {
                case 268435456U:
                    subscriptionsCache.FailureReason = Strings.CacheRpcServerFailed(serverFqdn, failureReason);
                    break;

                case 268435457U:
                    subscriptionsCache.FailureReason = Strings.CacheRpcServerStopped(serverFqdn);
                    break;

                case 268435458U:
                    subscriptionsCache.FailureReason = Strings.CacheRpcInvalidServerVersionIssue(serverFqdn);
                    break;

                default:
                    throw new InvalidObjectOperationException(Strings.InvalidCacheActionResult(num));
                }
            }
            subscriptionsCache.SubscriptionCacheObjects = subscriptionCacheObjects;
            subscriptionsCache.propertyBag.SetField(SimpleProviderObjectSchema.ObjectState, objectState);
            subscriptionsCache.propertyBag.ResetChangeTracking(SimpleProviderObjectSchema.ObjectState);
        }
Esempio n. 16
0
 public SubscriptionViewModel()
 {
     cache = DependencyService.Get <SubscriptionsCache>();
 }
Esempio n. 17
0
 public CacheIdParameter(SubscriptionsCache cache)
 {
     this.Initialize(cache.Identity);
 }
Esempio n. 18
0
        public void Delete(IConfigurable instance)
        {
            SubscriptionsCache subscriptionsCache = (SubscriptionsCache)instance;

            this.TestUserCache(subscriptionsCache);
        }