public void Get_WhenElementExists_ShouldReturnValue() { var treeProvider = new TestAvlTreeProvider(); treeProvider.Insert("10", 10); treeProvider.Insert("2", 2); treeProvider.Insert("20", 20); treeProvider.Insert("1", 1); treeProvider.Insert("8", 8); treeProvider.Insert("7", 7); var result = treeProvider.Get("7"); Assert.Equal(7, result); }
public void Insert_WhenAllAreOnLeft_ShouldBalance_WithHeightAs1(int[] expectedOutput) { ReadOnlySpan <int> s = expectedOutput.AsSpan(); var treeProvider = new TestAvlTreeProvider(); treeProvider.Insert("10", 10); treeProvider.Insert("2", 2); treeProvider.Insert("1", 1); var spanIdx = 0; foreach (var node in treeProvider) { Assert.Equal(s[spanIdx++], node); } }
public void Insert_WhenThereIsLeftRightCase_ShouldHaveBalanceFactorAs1(int[] expectedOutput) { ReadOnlySpan <int> s = expectedOutput.AsSpan(); var treeProvider = new TestAvlTreeProvider(); treeProvider.Insert("10", 10); treeProvider.Insert("2", 2); treeProvider.Insert("20", 20); treeProvider.Insert("1", 1); treeProvider.Insert("8", 8); treeProvider.Insert("7", 7); var spanIdx = 0; foreach (var node in treeProvider) { Assert.Equal(s[spanIdx++], node); } }