public void TestBasicCacheRetrieval() { Cache.DiskWriteBackCache wbc = new Cache.DiskWriteBackCache(); AssetBase baseAsset = new AssetBase(); baseAsset.Data = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 }; baseAsset.Name = "Name"; baseAsset.Description = "Description"; baseAsset.FullID = UUID.Random(); baseAsset.Local = true; baseAsset.Temporary = true; baseAsset.Type = 5; baseAsset.Metadata.CreationDate = DateTime.Now; var stAsset = StratusAsset.FromAssetBase(baseAsset); wbc.StoreAsset(stAsset); CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; var cacheAsset = wbc.GetAsset(baseAsset.FullID.Guid); Assert.IsTrue(comp.Compare(cacheAsset, stAsset), comp.DifferencesString); CollectionAssert.AreEqual(cacheAsset.Data, stAsset.Data); }
public void TestWriteToCF() { if (!_runTests) { return; } //delete any leftover files in the writeback cache foreach (var file in Directory.EnumerateFiles("cache/cf_writeback")) { File.Delete(file); } Cache.DiskWriteBackCache wbc = new Cache.DiskWriteBackCache(); AssetBase baseAsset = new AssetBase(); baseAsset.Data = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 }; baseAsset.Name = "Name"; baseAsset.Description = "Description"; baseAsset.FullID = UUID.Random(); baseAsset.Local = true; baseAsset.Temporary = true; baseAsset.Type = 5; baseAsset.Metadata.CreationDate = DateTime.Now; var stAsset = StratusAsset.FromAssetBase(baseAsset); wbc.StoreAsset(stAsset); wbc.DoWriteCycle(); //the asset should still be in the WB cache Assert.IsNotNull(wbc.GetAsset(baseAsset.FullID.Guid)); //... but we should now be able to get the asset from CF AssetBase cfAsset = _client.RequestAssetSync(baseAsset.FullID); CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; Assert.IsTrue(comp.Compare(baseAsset, cfAsset), comp.DifferencesString); CollectionAssert.AreEqual(baseAsset.Data, cfAsset.Data); }
public void TestWriteToCF() { if (!_runTests) return; //delete any leftover files in the writeback cache foreach (var file in Directory.EnumerateFiles("cache/cf_writeback")) { File.Delete(file); } Cache.DiskWriteBackCache wbc = new Cache.DiskWriteBackCache(); AssetBase baseAsset = new AssetBase(); baseAsset.Data = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 }; baseAsset.Name = "Name"; baseAsset.Description = "Description"; baseAsset.FullID = UUID.Random(); baseAsset.Local = true; baseAsset.Temporary = true; baseAsset.Type = 5; baseAsset.Metadata.CreationDate = DateTime.Now; var stAsset = StratusAsset.FromAssetBase(baseAsset); wbc.StoreAsset(stAsset); wbc.DoWriteCycle(); //the asset should still be in the WB cache Assert.IsNotNull(wbc.GetAsset(baseAsset.FullID.Guid)); //... but we should now be able to get the asset from CF AssetBase cfAsset = _client.RequestAssetSync(baseAsset.FullID); CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; Assert.IsTrue(comp.Compare(baseAsset, cfAsset), comp.DifferencesString); CollectionAssert.AreEqual(baseAsset.Data, cfAsset.Data); }