public void It_Allocates_Exact_Size_For_Empty_Nodes() { var node = new Node <int>(5); var bytes = new byte[100]; var strategy = new PredictiveBTreeNodeAllocationStrategy <int>(node); var calculated = strategy.CalculateSize(bytes.Length); Assert.AreEqual(bytes.Length, calculated); }
public void It_Allocates_2000_Percent_For_A_10_Percent_Filled_Non_ValueType_Leaf_Node() { var node = new Node <string>(5); var bytes = new byte[100]; node.EntryList.Add(new Entry <string>()); var strategy = new PredictiveBTreeNodeAllocationStrategy <string>(node); var calculated = strategy.CalculateSize(bytes.Length); var diff = Math.Abs(bytes.Length * 20 - calculated); Assert.IsTrue(diff <= bytes.Length * 2); // max 10% off }