public void TestNewSubscription() { var repo = new BrightstarAccountsRepository(_connectionString); var accountId = repo.CreateAccount("userTokenC", "*****@*****.**"); var subscription = repo.CreateSubscription(accountId, SubscriptionDetails.TrialDetails); Assert.IsNotNull(subscription); Assert.IsNotNull(subscription.Id); Assert.IsTrue(subscription.IsTrial); Assert.AreEqual(SubscriptionDetails.TrialDetails.StoreLimit, subscription.StoreLimit); Assert.AreEqual(SubscriptionDetails.TrialDetails.StoreSizeLimit, subscription.StoreSizeLimit); Assert.AreEqual(SubscriptionDetails.TrialDetails.TotalSizeLimit, subscription.TotalSizeLimit); var accountDetails = repo.GetAccountDetailsForUser("userTokenC"); Assert.AreEqual(1, accountDetails.Subscriptions.Count()); var s = accountDetails.Subscriptions.First(); Assert.AreEqual(subscription.Id, s.Id); }
public void TestOneTrialPerAccount() { var repo = new BrightstarAccountsRepository(_connectionString); var accountId = repo.CreateAccount("userTokenD", "*****@*****.**"); var subscription = repo.CreateSubscription(accountId, SubscriptionDetails.TrialDetails); try { var sub2 = repo.CreateSubscription(accountId, SubscriptionDetails.TrialDetails); Assert.Fail("Expected creation of second trial subscription for account to fail."); } catch(AccountsRepositoryException are) { Assert.AreEqual(AccountsRepositoryException.AccountHasTrialSubscription, are.ErrorCode); } }
public void TestStoreCountLimit() { var repo = new BrightstarAccountsRepository(_connectionString); var accountId = repo.CreateAccount("userTokenF", "*****@*****.**"); var subscription = repo.CreateSubscription(accountId, SubscriptionDetails.TrialDetails); repo.CreateStore("userTokenF", subscription.Id, "Test"); try { repo.CreateStore("userTokenF", subscription.Id, "Test"); Assert.Fail("Expected exception when creating a second store with StoreCountLimit=1"); } catch(AccountsRepositoryException are) { Assert.AreEqual(AccountsRepositoryException.StoreCountLimitReached, are.ErrorCode); } }
public void TestCreateStore() { var repo = new BrightstarAccountsRepository(_connectionString); var accountId = repo.CreateAccount("userTokenE", "*****@*****.**"); var subscription = repo.CreateSubscription(accountId, SubscriptionDetails.TrialDetails); var store = repo.CreateStore("userTokenE", subscription.Id, "Test"); Assert.IsNotNull(store); var updatedAccount = repo.GetAccountDetailsForUser("userTokenE"); Assert.AreEqual(1, updatedAccount.Subscriptions.Count(), "Unexpected subscriptions count"); var updatedSubscription = updatedAccount.Subscriptions.First(); Assert.AreEqual(1, updatedSubscription.CurrentStoreCount, "Unexpected CurrentStoreCount"); // After creation there should be an access key for the owner on this store var storeAccessKeys = repo.GetUserAccessKey("userTokenE", store.Id); Assert.IsNotNull(storeAccessKeys); Assert.AreEqual(store.Id, storeAccessKeys.StoreId); Assert.AreEqual(accountId, storeAccessKeys.AccountId); Assert.AreEqual(StoreAccessLevel.Read|StoreAccessLevel.Write|StoreAccessLevel.Admin|StoreAccessLevel.Export, storeAccessKeys.Access); }