public void Get_ForNotExistingKey_ThrowsException(ProbingType type) { //arrange var oaht = new OpenAddressingHashTable <string, int>(5, type); //arrange + act Action act = () => { oaht.Get("null"); }; //assert act.Should().Throw <System.Collections.Generic.KeyNotFoundException>(); }
public void Get_ForNull_ThrowsException(ProbingType type) { //arrange var oaht = new OpenAddressingHashTable <string, int>(5, type); //arrange + act Action act = () => { oaht.Get(null); }; //assert act.Should().Throw <ArgumentException>(); }
public void Add_ForGoodValues_InsertsIt(ProbingType type) { //arrange const string key = "1"; const int value = 1; var oaht = new OpenAddressingHashTable <string, int>(5, type); //act oaht.Add(key, value); //assert oaht[key].Should().Be(value); }
public void Get_ForExistingKey_ReturnsTheValue(ProbingType type) { //arrange const string key = "1"; const int value = 1; var oaht = new OpenAddressingHashTable <string, int>(5, type); oaht.Add(key, value); //act var result = oaht.Get(key); //assert result.Should().Be(value); }
public OpenAddressingHashTable(int capacity, ProbingType type = ProbingType.Linear) : base(capacity) { _elements = 0; Keys = new NullableArray<TKey>(capacity); Values = new DynamicArray<TValue>(capacity); switch(type) { case ProbingType.Linear: _probe = (x) => x * 17; break; case ProbingType.Quadratic: _probe = (x) => (x * x + x) >> 1; break; } }