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);

        }