public void FIFO_with_one_and_only_one_Value_Type() { FIFOBuffer <int> f = new FIFOBuffer <int>(1); AssertEmpty(f); f.Push(5); CheckOneValueType(f, 5, 50); f.Pop(); f.Push(0); CheckOneValueType(f, 0, 5); f.Push(1); CheckOneValueType(f, 1, 0); f.Push(2); CheckOneValueType(f, 2, 0); int iType = f.IndexOf(2); int iBoxed = f.IndexOf((object)2); iType.Should().Be(iBoxed); }
public void FIFOOneValueType() { FIFOBuffer <int> f = new FIFOBuffer <int>(1); AssertEmpty(f); f.Push(5); CheckOneValueType(f, 5, 50); f.Pop(); f.Push(0); CheckOneValueType(f, 0, 5); f.Push(1); CheckOneValueType(f, 1, 0); f.Push(2); CheckOneValueType(f, 2, 0); int iType = f.IndexOf(2); int iBoxed = f.IndexOf((object)2); Assert.That(iType == iBoxed); }
public void FIFO_supports_Null_entries() { var c0 = CultureInfo.InvariantCulture; var c1 = this; var f = new FIFOBuffer <object>(2); AssertEmpty(f); // When calling with null, it is the IndexOf( T ) that is called // since T is a reference type. int iNull = f.IndexOf(null); iNull.Should().BeLessThan(0); f.Push(c0); f.Contains(null).Should().BeFalse(); f.IndexOf(null).Should().BeLessThan(0); f.PeekLast().Should().BeSameAs(c0); AssertContains(f, c0); f.Push(null); f.Count.Should().Be(2); f.IndexOf(null).Should().Be(1); f.IndexOf(c0).Should().Be(0); f.PeekLast().Should().BeNull(); AssertContains(f, c0, null); f.Push(c1); f.IndexOf(null).Should().Be(0); f.IndexOf(c1).Should().Be(1); f.Contains(c0).Should().BeFalse(); f.IndexOf(c0).Should().BeLessThan(0); f.PeekLast().Should().BeSameAs(c1); AssertContains(f, null, c1); f.Push(null); AssertContains(f, c1, null); f.Push(null); AssertContains(f, null, null); f.PopLast().Should().BeNull(); f.PopLast().Should().BeNull(); f.Invoking(sut => sut.PopLast()).Should().Throw <InvalidOperationException>(); }
public void FIFO_supports_Null_entries() { var c0 = CultureInfo.InvariantCulture; var c1 = this; var f = new FIFOBuffer <object>(2); AssertEmpty(f); // When calling with null, it is the IndexOf( T ) that is called // since T is a reference type. int iNull = f.IndexOf(null); Assert.That(iNull, Is.LessThan(0)); f.Push(c0); Assert.That(f.Contains(null), Is.False); Assert.That(f.IndexOf(null), Is.LessThan(0)); Assert.That(f.PeekLast(), Is.SameAs(c0)); AssertContains(f, c0); f.Push(null); Assert.That(f.Count, Is.EqualTo(2)); Assert.That(f.IndexOf(null), Is.EqualTo(1)); Assert.That(f.IndexOf(c0), Is.EqualTo(0)); Assert.That(f.PeekLast(), Is.Null); AssertContains(f, c0, null); f.Push(c1); Assert.That(f.IndexOf(null), Is.EqualTo(0)); Assert.That(f.IndexOf(c1), Is.EqualTo(1)); Assert.That(f.Contains(c0), Is.False); Assert.That(f.IndexOf(c0), Is.LessThan(0)); Assert.That(f.PeekLast(), Is.SameAs(c1)); AssertContains(f, null, c1); f.Push(null); AssertContains(f, c1, null); f.Push(null); AssertContains(f, null, null); Assert.That(f.PopLast(), Is.Null); Assert.That(f.PopLast(), Is.Null); Assert.Throws <InvalidOperationException>(() => f.PopLast()); }
public void FIFOSupportNull() { CultureInfo c0 = CultureInfo.InvariantCulture; CultureInfo c1 = CultureInfo.GetCultureInfo("fr"); FIFOBuffer <CultureInfo> f = new FIFOBuffer <CultureInfo>(2); AssertEmpty(f); // When calling with null, it is the IndexOf( T ) that is called // since T is a reference type. int iNull = f.IndexOf(null); Assert.That(iNull, Is.LessThan(0)); f.Push(c0); Assert.That(f.Contains(null), Is.False); Assert.That(f.IndexOf(null), Is.LessThan(0)); AssertContains(f, c0); f.Push(null); Assert.That(f.Count, Is.EqualTo(2)); Assert.That(f.IndexOf(null), Is.EqualTo(1)); Assert.That(f.IndexOf(c0), Is.EqualTo(0)); AssertContains(f, c0, null); f.Push(c1); Assert.That(f.IndexOf(null), Is.EqualTo(0)); Assert.That(f.IndexOf(c1), Is.EqualTo(1)); Assert.That(f.Contains(c0), Is.False); Assert.That(f.IndexOf(c0), Is.LessThan(0)); AssertContains(f, null, c1); f.Push(null); AssertContains(f, c1, null); f.Push(null); AssertContains(f, null, null); }