public void WhenAddSubscription_ThenReturnsId() { var subscription = new WebhookSubscription { Event = "aneventname", CreatedById = "auserid" }; var result = store.Add(subscription); Assert.That(result.IsEntityId(), Is.True); cacheClient.Verify(cc => cc.Add(CacheClientSubscriptionStore.FormatCacheKey("auserid", "aneventname"), It.Is <WebhookSubscription>(sub => sub.Id.IsEntityId()))); }
public void Initialize() { cacheClient = new Mock <ICacheClient>(); cacheClient.As <ICacheClientExtended>().Setup(cc => cc.GetKeysByPattern(It.IsAny <string>())) .Returns(new List <string> { "akey" }); cacheClient.Setup(cc => cc.Add(It.IsAny <string>(), It.IsAny <WebhookSubscription>())); store = new CacheClientSubscriptionStore { CacheClient = cacheClient.Object }; }
public void WhenAddHistory_ThenAddsHistory() { var datum = DateTime.UtcNow.ToNearestSecond(); cacheClient.Setup(cc => cc.Get <object>("akey")) .Returns(new WebhookSubscription { Id = "asubscriptionid", Event = "aneventname", CreatedById = "auserid" }); var result = new SubscriptionDeliveryResult { Id = "aresultid", AttemptedDateUtc = datum }; store.Add("asubscriptionid", result); cacheClient.Verify(cc => cc.Add(CacheClientSubscriptionStore.FormatHistoryCacheKey("auserid", "aneventname", "aresultid"), It.Is <SubscriptionDeliveryResult>(sub => (sub.Id == "aresultid") && (sub.AttemptedDateUtc == datum)))); }
public void WhenFind_ThenReturnsSubscriptions() { var subscription = new WebhookSubscription(); cacheClient.Setup(cc => cc.Get <object>("akey")) .Returns(subscription); var result = store.Find("auserid"); Assert.That(result[0], Is.EqualTo(subscription)); cacheClient.As <ICacheClientExtended>().Verify(cc => cc.GetKeysByPattern(CacheClientSubscriptionStore.FormatCacheKey("auserid", null) + "*")); cacheClient.Verify(cc => cc.Get <object>("akey")); }
public void WhenFormatCacheKeyAndUserId_ThenReturnsUserkey() { var result = CacheClientSubscriptionStore.FormatCacheKey("auserid", "aneventname"); Assert.That(result, Is.EqualTo(CacheClientSubscriptionStore.FormatCacheKey("auserid", "aneventname"))); }
public void WhenFormatCacheKeyAndNullUserId_ThenReturnsAnonymousUserkey() { var result = CacheClientSubscriptionStore.FormatCacheKey(null, "aneventname"); Assert.That(result, Is.EqualTo(CacheClientSubscriptionStore.FormatCacheKey(CacheClientSubscriptionStore.CacheKeyForAnonymousUser, "aneventname"))); }