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 TestNewAccount()
        {
            var repo = new BrightstarAccountsRepository(_connectionString);
            var accountId = repo.CreateAccount("userTokenA", "*****@*****.**");

            AssertTriple("http://demand.brightstardb.com/accounts/usertoken/userTokenA",
                         "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
                         "http://demand.brightstardb.com/schemas/accounts/UserToken");
            AssertTriple("http://demand.brightstardb.com/accounts/account/" + accountId,
                         "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
                         "http://demand.brightstardb.com/schemas/accounts/Account");
            AssertTriple("http://demand.brightstardb.com/accounts/account/" + accountId,
                "http://demand.brightstardb.com/schemas/accounts/userToken",
                "http://demand.brightstardb.com/accounts/usertoken/userTokenA");

            var accountDetails = repo.GetAccountDetailsForUser("userTokenA");
            Assert.IsNotNull(accountDetails);
            Assert.AreEqual(accountId, accountDetails.AccountId);
            Assert.AreEqual(0, accountDetails.Subscriptions.Count());
        }
        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);

        }