public void TestMultipleGeneration() { var result = KeyValueGenerator.Generate(100, new int[] { 1000, 100000 }); Assert.AreEqual(200, result.Count); Assert.AreEqual(1000, KeyValueGenerator.GenerateValue(1000, result[0].Value).Length); Assert.AreEqual("TestKey 000", result[0].Key); Assert.AreEqual(new string('*', 999) + "0", KeyValueGenerator.GenerateValue(1000, result[0].Value)); Assert.AreEqual(1000, KeyValueGenerator.GenerateValue(1000, result[1].Value).Length); Assert.AreEqual("TestKey 001", result[1].Key); Assert.AreEqual(new string('*', 999) + "1", KeyValueGenerator.GenerateValue(1000, result[1].Value)); Assert.AreEqual(1000, KeyValueGenerator.GenerateValue(1000, result[99].Value).Length); Assert.AreEqual("TestKey 099", result[99].Key); Assert.AreEqual(new string('*', 998) + "99", KeyValueGenerator.GenerateValue(1000, result[99].Value)); Assert.AreEqual(100000, KeyValueGenerator.GenerateValue(100000, result[100].Value).Length); Assert.AreEqual("TestKey 100", result[100].Key); Assert.AreEqual(new string('*', 99997) + "100", KeyValueGenerator.GenerateValue(100000, result[100].Value)); Assert.AreEqual(100000, KeyValueGenerator.GenerateValue(100000, result[101].Value).Length); Assert.AreEqual("TestKey 101", result[101].Key); Assert.AreEqual(new string('*', 99997) + "101", KeyValueGenerator.GenerateValue(100000, result[101].Value)); Assert.AreEqual(100000, KeyValueGenerator.GenerateValue(100000, result[199].Value).Length); Assert.AreEqual("TestKey 199", result[199].Key); Assert.AreEqual(new string('*', 99997) + "199", KeyValueGenerator.GenerateValue(100000, result[199].Value)); }
private void PrepareCache() { _pairs = KeyValueGenerator.Generate(_count, _length); foreach (var item in _pairs) { Provider.SetItem(item.Key, KeyValueGenerator.GenerateValue(item.Length, item.Value)); } }
public void TestGeneration() { var result = KeyValueGenerator.Generate(100, 1000); Assert.AreEqual(100, result.Count); Assert.AreEqual(1000, KeyValueGenerator.GenerateValue(1000, result[0].Value).Length); Assert.AreEqual("TestKey 000", result[0].Key); Assert.AreEqual(new string('*', 999) + "0", KeyValueGenerator.GenerateValue(1000, result[0].Value)); Assert.AreEqual(1000, KeyValueGenerator.GenerateValue(1000, result[1].Value).Length); Assert.AreEqual("TestKey 001", result[1].Key); Assert.AreEqual(new string('*', 999) + "1", KeyValueGenerator.GenerateValue(1000, result[1].Value)); Assert.AreEqual(1000, KeyValueGenerator.GenerateValue(1000, result[99].Value).Length); Assert.AreEqual("TestKey 099", result[99].Key); Assert.AreEqual(new string('*', 998) + "99", KeyValueGenerator.GenerateValue(1000, result[99].Value)); }
private static Dictionary <int, string> PrepareTestData(TestPlan testPlan, ICacheProvider provider) { var keys = new Dictionary <int, string>(); int maxIntervalEnd = testPlan.Intervals.Max(p => p.End); foreach (var interval in testPlan.Intervals) { for (int i = interval.Start; i < interval.End; i++) { var key = KeyValueGenerator.GenerateKey(maxIntervalEnd, i); keys.Add(i, key); var value = KeyValueGenerator.GenerateValue(interval.Length, i); provider.SetItem(key, value); } } return(keys); }