コード例 #1
0
 public List<Organisation.Organisation> CreateTestOrgs(int numberoforgs)
 {
     // orgkey, name, id
     var orgs = new List<Organisation.Organisation>();
     for (int i = 0; i < numberoforgs; i++)
     {
         var org = new Organisation.Organisation();
         var orgKey = i.ToString();
         org.Id = "org" + orgKey;
         org.ApiKey = "orgapikey" + orgKey;
         org.OrgKey = "orgKey" + orgKey;// so orgKey is orgKey number
         org.Name = "org" + orgKey;
         org.Url = "orgurl" + orgKey; 
         orgs.Add(org);
     }
     return orgs;
 }
コード例 #2
0
        public void NewOrgStore()
        {
            //ARRANGE
            var id = GetMockDatabase();

            var os = new EmbeddableDocumentStore { RunInMemory = true };
            os.Initialize();
            const string key = "test";

            //ACT
            id.AddOrgStore(key, os);

            var newlyAddedStore = id.GetOrgStore(key);

            Assert.IsNotNull(newlyAddedStore);
            Assert.AreEqual(newlyAddedStore.Identifier, os.Identifier);
            var newOrg = new Organisation.Organisation
                                 {
                                     OrgKey = "neworg",
                                     ApiKey = "blah",
                                     Id = "blah",
                                     IsLive = true,
                                     Url = "cloudyday"
                                 };
            using (var session = id.MasterStore.OpenSession())
            {
                
                session.Store(newOrg);
                session.SaveChanges();
            }
            var testOrgStore = new EmbeddableDocumentStore {RunInMemory = true};
            var orgStore = id.GetOrgStore(newOrg.OrgKey, testOrgStore);
            Assert.IsNotNull(orgStore);
            
            Assert.AreEqual( id.GetAllOrgStores().Count,2);

            var newOrg2 = new Organisation.Organisation
            {
                OrgKey = "neworg2",
                ApiKey = "blah2",
                Id = "blah2",
                IsLive = true,
                Url = "cloudyday2"
            };
            using (var session = id.MasterStore.OpenSession())
            {

                session.Store(newOrg2);
                session.SaveChanges();
            }
            var testOrgStore2 = new EmbeddableDocumentStore { RunInMemory = true };
            Thread.Sleep(1000);
            Assert.AreEqual(id.GetAllOrgStores(testOrgStore2).Count,3);

            var dontexist = id.GetOrgStore("sasasa",testOrgStore);
            Assert.IsNull(dontexist);
            try
            {
                id.GetOrgStore(string.Empty);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                
            }
            catch (Exception)
            {
                Assert.Fail();
            }
            try
            {
                id.GetOrgStore(null);
            }
            catch (ArgumentException)
            {
                
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }