Example #1
0
        public void TestContains()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string           name        = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);

            m_store.Blobs.Add(blobSrc);
            String tempPath = Path.GetTempPath();

            using (StreamWriter log = new System.IO.StreamWriter(Path.Combine(tempPath, "linq.log")))
            {
                log.AutoFlush = true;

                using (ConfigDatabase db = m_store.CreateReadContext())
                {
                    db.Log = log;
                    Assert.True(m_store.Blobs.Contains(db, name));
                }

                //
                // Add an additional 3 blobs. Then, when we list by prefix, we'll get 4
                //
                for (int i = 0; i < 3; ++i)
                {
                    NamedBlob blob = new NamedBlob(name + "_" + i.ToString(), settingsSrc);
                    m_store.Blobs.Add(blob);
                }

                using (ConfigDatabase db = m_store.CreateReadContext())
                {
                    Assert.True(m_store.Blobs.ListNamesStartWith(db, name).Count() == 4);
                }
            }
        }
Example #2
0
        public void TestUpdate()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string           name        = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);

            Assert.DoesNotThrow(() => m_store.Blobs.Add(blobSrc));

            for (int i = 0; i < 10; ++i)
            {
                NamedBlob blobGet = null;
                Assert.DoesNotThrow(() => blobGet = m_store.Blobs.Get(name));

                TestUserSettings settingsDest = null;

                Assert.DoesNotThrow(() => settingsDest = blobGet.GetObject <TestUserSettings>());

                string newFirstName = settingsDest.FirstName + "," + i.ToString();
                settingsDest.FirstName = newFirstName;

                Assert.DoesNotThrow(() => m_store.Blobs.Update(new NamedBlob(name, settingsDest)));

                Assert.DoesNotThrow(() => blobGet = m_store.Blobs.Get(name));

                Assert.DoesNotThrow(() => settingsDest = blobGet.GetObject <TestUserSettings>());
                Assert.True(string.Equals(settingsDest.FirstName, newFirstName));
            }
        }
Example #3
0
        public void TestUpdate()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string name = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);            
            Assert.DoesNotThrow(() => m_store.Blobs.Add(blobSrc));
            
            for (int i = 0; i < 10; ++i)
            {
                NamedBlob blobGet = null;
                Assert.DoesNotThrow(() => blobGet = m_store.Blobs.Get(name));
                
                TestUserSettings settingsDest = null;
                
                Assert.DoesNotThrow(() => settingsDest = blobGet.GetObject<TestUserSettings>());

                string newFirstName = settingsDest.FirstName + "," + i.ToString();
                settingsDest.FirstName = newFirstName;
                
                Assert.DoesNotThrow(() => m_store.Blobs.Update(new NamedBlob(name, settingsDest)));

                Assert.DoesNotThrow(() => blobGet = m_store.Blobs.Get(name));

                Assert.DoesNotThrow(() => settingsDest = blobGet.GetObject<TestUserSettings>());
                Assert.True(string.Equals(settingsDest.FirstName, newFirstName));
            }
        }
Example #4
0
        public void TestAdd()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string           name        = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);

            Assert.DoesNotThrow(() => m_store.Blobs.Add(blobSrc));
            Assert.Throws <SqlException>(() => m_store.Blobs.Add(blobSrc));
        }
Example #5
0
        public void TestAdd()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string name = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);
            
            Assert.DoesNotThrow(() => m_store.Blobs.Add(blobSrc));
            Assert.Throws<SqlException>(() => m_store.Blobs.Add(blobSrc));
        }
Example #6
0
 public void UpdateBlob(NamedBlob blob)
 {
     try
     {
         this.Store.Blobs.Update(blob);
     }
     catch (Exception ex)
     {
         throw CreateFault("UpdateBlob", ex);
     }
 }
Example #7
0
 public void AddBlob(NamedBlob blob)
 {
     try
     {
         this.Store.Blobs.Add(blob);
     }
     catch (Exception ex)
     {
         throw CreateFault("AddBlob", ex);
     }
 }
Example #8
0
        public void TestRoundtrip()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string           name        = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);

            Assert.DoesNotThrow(() => m_store.Blobs.Add(blobSrc));

            NamedBlob blobGet = null;

            Assert.DoesNotThrow(() => blobGet = m_store.Blobs.Get(name));

            TestUserSettings settingsDest = null;

            Assert.DoesNotThrow(() => settingsDest = blobGet.GetObject <TestUserSettings>());
            Assert.True(settingsSrc.Compare(settingsDest));
        }
Example #9
0
        public void TestSerialization()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string           name        = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc  = null;
            NamedBlob blobDest = null;

            Assert.DoesNotThrow(() => blobSrc = new NamedBlob(name, settingsSrc));
            Assert.True(!blobSrc.Data.IsNullOrEmpty());

            Assert.DoesNotThrow(() => blobDest = new NamedBlob(name, blobSrc.Data));

            TestUserSettings settingsDest = null;

            Assert.DoesNotThrow(() => settingsDest = blobDest.GetObject <TestUserSettings>());

            Assert.True(settingsSrc.Compare(settingsDest));
        }
Example #10
0
        public void Get(string[] args)
        {
            string name           = args.GetRequiredValue(0);
            string outputFilePath = args.GetOptionalValue(1, null);

            NamedBlob blob = this.Client.GetBlob(name);

            if (blob == null)
            {
                WriteLine("No matches");
                return;
            }

            if (outputFilePath != null)
            {
                File.WriteAllBytes(outputFilePath, blob.Data);
            }
            else
            {
                WriteLine("{0} bytes", blob.Data.Length);
            }
        }
Example #11
0
        public void Update(string[] args)
        {
            NamedBlob blob = CreateBlob(args);

            this.Client.UpdateBlob(blob);
        }
Example #12
0
 public void UpdateBlob(NamedBlob blob)
 {
     try
     {
         this.Store.Blobs.Update(blob);
     }
     catch (Exception ex)
     {
         throw CreateFault("UpdateBlob", ex);
     }
 }
Example #13
0
        public void Add(string[] args)
        {
            NamedBlob blob = CreateBlob(args);

            this.Client.AddBlob(blob);
        }
Example #14
0
        public void TestContains()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string name = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);
            m_store.Blobs.Add(blobSrc);
            String tempPath = Path.GetTempPath();
            using(StreamWriter log = new System.IO.StreamWriter(Path.Combine(tempPath, "linq.log")))
            {
                log.AutoFlush = true;
                                
                using(ConfigDatabase db = m_store.CreateReadContext())
                {
                    db.Log = log;
                    Assert.True(m_store.Blobs.Contains(db, name));            
                }
                
                //
                // Add an additional 3 blobs. Then, when we list by prefix, we'll get 4
                //                
                for (int i = 0; i < 3; ++i)
                {
                    NamedBlob blob = new NamedBlob(name + "_" + i.ToString(), settingsSrc);
                    m_store.Blobs.Add(blob);
                }

                using (ConfigDatabase db = m_store.CreateReadContext())
                {
                    Assert.True(m_store.Blobs.ListNamesStartWith(db, name).Count() == 4);
                }
            }
        }
Example #15
0
        public void TestRoundtrip()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string name = Guid.NewGuid().ToString("D");

            NamedBlob blobSrc = new NamedBlob(name, settingsSrc);
            Assert.DoesNotThrow(() => m_store.Blobs.Add(blobSrc));
            
            NamedBlob blobGet = null;
            Assert.DoesNotThrow(() => blobGet = m_store.Blobs.Get(name));
            
            TestUserSettings settingsDest = null;
            Assert.DoesNotThrow(() => settingsDest = blobGet.GetObject<TestUserSettings>());
            Assert.True(settingsSrc.Compare(settingsDest));
        }
Example #16
0
        public void TestSerialization()
        {
            TestUserSettings settingsSrc = TestUserSettings.Create();
            string name = Guid.NewGuid().ToString("D");
            
            NamedBlob blobSrc = null;
            NamedBlob blobDest = null;
            
            Assert.DoesNotThrow(() => blobSrc = new NamedBlob(name, settingsSrc));
            Assert.True(!blobSrc.Data.IsNullOrEmpty());

            Assert.DoesNotThrow(() => blobDest = new NamedBlob(name, blobSrc.Data));
            
            TestUserSettings settingsDest = null;
            Assert.DoesNotThrow(() => settingsDest = blobDest.GetObject<TestUserSettings>());
            
            Assert.True(settingsSrc.Compare(settingsDest));
        }
Example #17
0
 public void AddBlob(NamedBlob blob)
 {
     try
     {
         this.Store.Blobs.Add(blob);
     }
     catch (Exception ex)
     {
         throw CreateFault("AddBlob", ex);
     }
 }