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); } } }
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)); } }
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)); } }
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)); }
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)); }
public void UpdateBlob(NamedBlob blob) { try { this.Store.Blobs.Update(blob); } catch (Exception ex) { throw CreateFault("UpdateBlob", ex); } }
public void AddBlob(NamedBlob blob) { try { this.Store.Blobs.Add(blob); } catch (Exception ex) { throw CreateFault("AddBlob", ex); } }
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)); }
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)); }
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); } }
public void Update(string[] args) { NamedBlob blob = CreateBlob(args); this.Client.UpdateBlob(blob); }
public void Add(string[] args) { NamedBlob blob = CreateBlob(args); this.Client.AddBlob(blob); }
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); } } }
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)); }
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)); }