public void TestClear_NonEmptyCollection() { var key1 = @"TestKey1"; var key2 = @"TestKey2"; var key3 = @"TestKey3"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction1 = JackpotLog.Randomize(new Random()); var transaction2 = JackpotLog.Randomize(new Random()); var transaction3 = JackpotLog.Randomize(new Random()); collection.Add(key1, transaction1); collection.Add(key2, transaction2); collection.Add(key3, transaction3); collection.Clear(); Assert.IsFalse(collection.TryGetValue(key1, out var result1)); Assert.IsNull(result1); Assert.IsFalse(collection.TryGetValue(key2, out var result2)); Assert.IsNull(result2); Assert.IsFalse(collection.TryGetValue(key3, out var result3)); Assert.IsNull(result3); }
public void TestRemoveKey_KeyExists() { var key = @"TestKey"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction = JackpotLog.Randomize(new Random()); collection.Add(key, transaction); Assert.IsTrue(collection.Remove(key)); }
public void TestIndexer_SingleKeyValue() { var key = @"TestKey"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction = JackpotLog.Randomize(new Random()); collection[key] = transaction; var result = collection[key]; Assert.AreEqual(transaction, result); }
public void TestAdd_DuplicateKeyValue() { var key = @"TestKey"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction = JackpotLog.Randomize(new Random()); collection.Add(key, transaction); Assert.Throws <ArgumentException>(() => collection.Add(key, transaction)); }
public void TestAdd_SingleKeyValue() { var key = @"TestKey"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction = JackpotLog.Randomize(new Random()); collection.Add(key, transaction); Assert.IsTrue(collection.TryGetValue(key, out var result)); Assert.AreEqual(transaction, result); }
public void TestIndexer_MultipleKeyValues() { var key1 = @"TestKey1"; var key2 = @"TestKey2"; var key3 = @"TestKey3"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction1 = JackpotLog.Randomize(new Random()); var transaction2 = JackpotLog.Randomize(new Random()); var transaction3 = JackpotLog.Randomize(new Random()); collection[key1] = transaction1; collection[key2] = transaction2; collection[key3] = transaction3; Assert.AreEqual(transaction1, collection[key1]); Assert.AreEqual(transaction2, collection[key2]); Assert.AreEqual(transaction3, collection[key3]); }
public void TestContainsKey_MultipleKeysExist() { var key1 = @"TestKey1"; var key2 = @"TestKey2"; var key3 = @"TestKey3"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction1 = JackpotLog.Randomize(new Random()); var transaction2 = JackpotLog.Randomize(new Random()); var transaction3 = JackpotLog.Randomize(new Random()); collection.Add(key1, transaction1); collection.Add(key2, transaction2); collection.Add(key3, transaction3); Assert.IsTrue(collection.ContainsKey(key1)); Assert.IsTrue(collection.ContainsKey(key2)); Assert.IsTrue(collection.ContainsKey(key3)); }
public void TestValues() { var key1 = @"TestKey1"; var key2 = @"TestKey2"; var key3 = @"TestKey3"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction1 = JackpotLog.Randomize(new Random()); var transaction2 = JackpotLog.Randomize(new Random()); var transaction3 = JackpotLog.Randomize(new Random()); collection[key1] = transaction1; collection[key2] = transaction2; collection[key3] = transaction3; Assert.AreEqual(3, collection.Values.Count()); Assert.IsTrue(collection.Values.Contains(transaction1)); Assert.IsTrue(collection.Values.Contains(transaction2)); Assert.IsTrue(collection.Values.Contains(transaction3)); }
public void TestAdd_MultipleKeyValues() { var key1 = @"TestKey1"; var key2 = @"TestKey2"; var key3 = @"TestKey3"; var collection = new KeyValueCollection <string, JackpotLog>(@"TestCollection", _database); var transaction1 = JackpotLog.Randomize(new Random()); var transaction2 = JackpotLog.Randomize(new Random()); var transaction3 = JackpotLog.Randomize(new Random()); collection.Add(key1, transaction1); collection.Add(key2, transaction2); collection.Add(key3, transaction3); Assert.IsTrue(collection.TryGetValue(key1, out var result1)); Assert.IsTrue(collection.TryGetValue(key2, out var result2)); Assert.IsTrue(collection.TryGetValue(key3, out var result3)); Assert.AreEqual(transaction1, result1); Assert.AreEqual(transaction2, result2); Assert.AreEqual(transaction3, result3); }