public void FileSystemDataStoreIsASnapshotConsumerAndProvider() { var store = new FileSystemDataStore(".", "testStore", "id"); Assert.IsInstanceOf<ISnapshotConsumer>(store); Assert.IsInstanceOf<ISnapshotProvider>(store); }
public void JustWarnsandReturnsEmptySnapshotIfFileDoesNotExistOnSnapshot() { var root = "Store"; var store = new FileSystemDataStore(root, "testData", "id"); var snapshot = store.Snapshot(); Assert.AreEqual(0, snapshot.Count()); }
public void FileSystemDataStore_AnswersContainsQueries() { var testData = new Snapshot { new MetricData(2.5d, DateTime.Now, new List<string>()) }; var store = new FileSystemDataStore(".", "testData", "id"); store.ResetWith(testData); Assert.IsTrue(store.Contains("testData")); Assert.IsFalse(store.Contains("realData")); File.Delete("testData.am"); }
public void FileSystemDataStore_CanPersistSimpleData() { var testData = new Snapshot { new MetricData(2.5d, DateTime.Now, new List<string>()) }; var store = new FileSystemDataStore(".", "testStore", "id"); store.Update(testData); var ret = store.Snapshot(); Assert.AreEqual(testData.First().Data, ret.First().Data); File.Delete("testData.am"); }
private void Run(string snapshotFile) { var item = Path.GetFileName(snapshotFile).Replace(".am.gz", ""); var store = new FileSystemDataStore(".", item, "Snapshot Store Id"); var snapshot = store.Snapshot(); Console.WriteLine("Timestamp\tValue"); foreach(var metricData in snapshot) { Console.WriteLine(metricData.Timestamp + "\t" + metricData.Data); } }
public void FileSystemDataStore_HandlesRootDirectory() { var root = "Store"; var store = new FileSystemDataStore(root, "testData", "id"); Assert.IsTrue(Directory.Exists(root)); var filePath = Path.Combine(root, "testData.am"); var testData = new Snapshot { new MetricData(2.5d, DateTime.Now, new List<string>()) }; store.ResetWith(testData); Assert.IsTrue(File.Exists(filePath)); File.Delete(filePath); Directory.Delete(root); }
public void ChainBuilderCanBuildAMainAndAPlottingChain() { var snapshot = new Snapshot { new MetricData(0.5, DateTime.Parse("12 Aug 2008"), new List<string> { "value" }), new MetricData(0.8, DateTime.Parse("13 Aug 2008"), new List<string> { "value" }), new MetricData(0.9, DateTime.Parse("14 Aug 2008"), new List<string> { "value" }) }; var configs = new List<ChainElement> { new ChainElement("chain1", "storageChain", "testSourceId", "testBufferId,testStoreId", ""), new ChainElement("chain2", "plottingChain", "testBufferId", "", "testPlotterId"), }; var source = MockRepository.GenerateMock<ISnapshotProvider>(); source.Expect(s => s.Snapshot()).Return(snapshot).Repeat.Any(); source.Expect(s => s.Name).Return("testSource").Repeat.Any(); source.Expect(s => s.Id).Return("testSourceId").Repeat.Any(); var bufferConfig = new SinkElement("testBufferId", "testBuffer", 10, 0, 1); var buffer = new CircularDataSink(bufferConfig); var store = new FileSystemDataStore(".", "testStore", "testStoreId"); var config = new PlotterElement("testPlotterId", "testPlotter", ".", 0, 1, 1, ""); var plotter = new MultiPlotter(config); var sources = new HashSet<ISnapshotProvider> { source, buffer }; var sinks = new HashSet<ISnapshotConsumer> { buffer, store }; var multiSinks = new HashSet<IMultipleSnapshotConsumer> { plotter }; var chains = ChainBuilder.Build(sources, sinks, multiSinks, configs); Assert.AreEqual(configs.Count, chains.Count()); foreach(var chain in chains) { chain.Update(); } var chartName = Path.Combine(@".", plotter.Name + ".png"); var storeName = store.Name + ".am"; Assert.IsTrue(File.Exists(chartName)); Assert.IsTrue(File.Exists(storeName)); File.Delete(chartName); File.Delete(storeName); source.VerifyAllExpectations(); }