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 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 bool Compare(TestUserSettings other) { return( string.Equals(this.FirstName, other.FirstName) && string.Equals(this.LastName, other.LastName) && string.Equals(this.Address, other.Address) ); }
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 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 bool Compare(TestUserSettings other) { return ( string.Equals(this.FirstName, other.FirstName) && string.Equals(this.LastName, other.LastName) && string.Equals(this.Address, other.Address) ); }