public void ShouldUpdateLocalModelForStronglyTypedModelOrDynamic()
        {
            _mockService.Setup(x => x.GetSubscriptionByKey(It.IsAny <string>())).Returns(SUSBCRIBER_JSON);
            _client = new SubscriptionClient(_mockService.Object);
            var result = _client.GetSubscriptionByKey <TestClass>("Tuttle");

            result.PlanName = "Steeeeeeeve";
            _client.UpdateLocalSubscription(result);
            result = _client.GetSubscriptionByKey <TestClass>("Tuttle");
            Assert.AreEqual("Steeeeeeeve", result.PlanName);

            var dynamicResult = _client.GetSubscriptionByKey("Tuttle");

            dynamicResult.PlanName = "Tuttle";
            _client.UpdateLocalSubscription(dynamicResult);
            result = _client.GetSubscriptionByKey <TestClass>("Tuttle");
            Assert.AreEqual("Tuttle", result.PlanName);
        }
        public void ShouldRemoveSubscribersOnUpdateAll()
        {
            _mockService.Setup(x => x.GetSubscriptions()).Returns(SUSBCRIBERS_JSON);
            _client = new SubscriptionClient(_mockService.Object);
            _client.SubscriptionUpdated(new SubscriberModel {
                ApplicationId = "1234", Key = "5678"
            });
            _client.WebhookUpdate(new SubscriberWebhookModel {
                Action = "updateall"
            });
            System.Threading.Thread.Sleep(2000);
            var result = _client.GetSubscriptionByKey("5678");

            Assert.IsNull(result);
        }
        public void ShouldReturnNullForFeaturesThatAreNull()
        {
            _mockService.Setup(x => x.GetSubscriptionByKey(It.IsAny <string>())).Returns(SUSBCRIBER_JSON_NULL);
            _client = new SubscriptionClient(_mockService.Object);
            var result = _client.GetSubscriptionByKey("TuttleNull");

            Assert.IsNull(result.RoutingEnabled);
            Assert.IsNull(result.DailyRate);
            Assert.IsNull(result.EnterpriseChatLimit);
            Assert.IsNull(result.PlanName);
            Assert.IsNull(result.NewVersionDate);
            Assert.AreEqual(1, result.SubscriptionTypeId);
            Assert.AreEqual("TuttleNull", result.Name);
            Assert.AreEqual(false, result.IsExpired);
        }
        public void ShouldCreatePropertiesBasedUponFeaturesForStronglyTypedModel()
        {
            _mockService.Setup(x => x.GetSubscriptionByKey(It.IsAny <string>())).Returns(SUSBCRIBER_JSON);
            _client = new SubscriptionClient(_mockService.Object);
            var result = _client.GetSubscriptionByKey <TestClass>("Tuttle");

            Assert.AreEqual(true, result.RoutingEnabled);
            Assert.AreEqual(44.44m, result.DailyRate);
            Assert.AreEqual(222, result.EnterpriseChatLimit);
            Assert.AreEqual("the name", result.PlanName);
            Assert.AreEqual(2015, result.NewVersionDate.Year);
            Assert.AreEqual(9, result.NewVersionDate.Month);
            Assert.AreEqual(4, result.NewVersionDate.Day);
            Assert.AreEqual(1, result.SubscriptionTypeId);
            Assert.AreEqual("Tuttle", result.Name);
            Assert.AreEqual(false, result.IsExpired);
        }