private static void ValidateCounterExists(string path) { if (knownCounterPaths.ContainsKey(path)) { return; } if (File.Exists(path)) { try { knownCounterPaths.Add(path, Whipser.Info(path)); return; } catch (CorruptWhisperFileException) { File.Delete(path); // corrupt? } } var retention = new List <ArchiveInfo>() { new ArchiveInfo(10, 180), // 10 seconds * 180 points = 30 min = 2.9 kb new ArchiveInfo(60, 60), // 60 seconds (1min) * 60 points = 1 hr = 3.9 kb }; Whipser.Create(path, retention); knownCounterPaths.Add(path, Whipser.Info(path)); }
public void create() { var retention = new List <ArchiveInfo>() { new ArchiveInfo(1, 60), new ArchiveInfo(60, 60) }; // check if invalid configuration fails successfully Assert.Throws <InvalidConfigurationException>(() => Whipser.Create(db, new List <ArchiveInfo>())); // create a new db with a valid configuration Whipser.Create(db, retention); // attempt to create another db in the same file, this should fail Assert.Throws <InvalidConfigurationException>(() => Whipser.Create(db, retention)); var info = Whipser.Info(db); Assert.AreEqual(retention.Max(x => x.Retention), info.MaxRetention); Assert.AreEqual(AggregationType.Average, info.AggregationType); Assert.AreEqual(0.5f, info.xFilesFactor); Assert.AreEqual(retention.Count, info.ArchiveList.Count); Assert.AreEqual(retention[0].SecondsPerPoint, info.ArchiveList[0].SecondsPerPoint); Assert.AreEqual(retention[0].Points, info.ArchiveList[0].Points); Assert.AreEqual(retention[1].SecondsPerPoint, info.ArchiveList[1].SecondsPerPoint); Assert.AreEqual(retention[1].Points, info.ArchiveList[1].Points); RemoveDb(); }