public void CanBeReset() { var firstSnapshot = new Snapshot { Name = "first" }; firstSnapshot.Add(new MetricData(10, DateTime.Now.AddMinutes(-2), new List<string> { "value" })); firstSnapshot.Add(new MetricData(11, DateTime.Now.AddMinutes(-1.5), new List<string> { "value" })); firstSnapshot.Add(new MetricData(15, DateTime.Now.AddMinutes(-1), new List<string> { "value" })); var secondSnapshot = new Snapshot { Name = "second" }; secondSnapshot.Add(new MetricData(10, DateTime.Now.AddMinutes(-2), new List<string> { "value2" })); secondSnapshot.Add(new MetricData(5, DateTime.Now.AddMinutes(-1.5), new List<string> { "value2" })); secondSnapshot.Add(new MetricData(6, DateTime.Now.AddMinutes(-1), new List<string> { "value2" })); var name = "testPlotter"; var config = new PlotterElement("id", name, ".", 0, 15, 1, ""); var sink = new MultiPlotter(config); sink.ResetWith(new [] { firstSnapshot, secondSnapshot }); var plotFile = Path.Combine(".", Path.ChangeExtension(name, "png")); Assert.IsTrue(File.Exists(plotFile)); File.Delete(plotFile); }
public void CanBeConfiguredwithConfiguration() { var name = "testPlotter"; var config = new PlotterElement("id", name, ".", 0, 1, 1, ""); var plotter = new MultiPlotter(config); Assert.IsInstanceOf<IMultipleSnapshotConsumer>(plotter); Assert.AreEqual(name, plotter.Name); }
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(); }