public void SetterWorks() { var c = new FastCollection<int> { 1 }; Assert.Equal(1, c[0]); Assert.True(c.Contains(1)); Assert.False(c.Contains(2)); c[0] = 2; Assert.Equal(2, c[0]); Assert.False(c.Contains(1)); Assert.True(c.Contains(2)); c.Add(3); Assert.False(c.Contains(1)); Assert.True(c.Contains(2)); Assert.True(c.Contains(3)); Assert.False(c.Contains(4)); c[c.IndexOf(3)] = 4; Assert.False(c.Contains(1)); Assert.True(c.Contains(2)); Assert.False(c.Contains(3)); Assert.True(c.Contains(4)); c[c.IndexOf(4)] = 2; Assert.False(c.Contains(1)); Assert.True(c.Contains(2)); Assert.False(c.Contains(3)); Assert.False(c.Contains(4)); Assert.Equal(2, c.Count); }
public void IndexOfWorks() { var c = new FastCollection<int> { 1, 2, 3 }; Assert.Equal(1, c[c.IndexOf(1)]); Assert.Equal(2, c[c.IndexOf(2)]); Assert.Equal(3, c[c.IndexOf(3)]); Assert.Equal(-1, c.IndexOf(4)); c.Remove(1); Assert.Equal(2, c[c.IndexOf(2)]); Assert.Equal(3, c[c.IndexOf(3)]); Assert.Equal(-1, c.IndexOf(1)); c.Clear(); Assert.Equal(-1, c.IndexOf(1)); Assert.Equal(-1, c.IndexOf(2)); Assert.Equal(-1, c.IndexOf(3)); c.Add(3); Assert.Equal(-1, c.IndexOf(1)); Assert.Equal(-1, c.IndexOf(2)); Assert.Equal(0, c.IndexOf(3)); Assert.Equal(3, c[0]); }