public unsafe void Dequeue_Item_After_Expanding_Success() { var expected = new TestStruct() { X = 3, Y = 1 }; ExpandableQueue <TestStruct> sut = stackalloc TestStruct[1]; sut.Enqueue(new TestStruct() { X = 1, Y = 1 }); sut.Expand(stackalloc TestStruct[1]); sut.Enqueue(expected); sut.Dequeue(); var testStruct = sut.Dequeue(); Assert.AreEqual(0, sut.Count); Assert.AreEqual(expected.X, testStruct.X); Assert.AreEqual(expected.Y, testStruct.Y); }
public unsafe void Dequeue_Item_Fail() { Assert.Throws <InvalidOperationException>(() => { ExpandableQueue <TestStruct> sut = stackalloc TestStruct[1]; sut.Dequeue(); }); }
public unsafe void Wrapping_Success() { ExpandableQueue <TestStruct> sut = stackalloc TestStruct[1]; for (var i = 0; i < 20; i++) { var expected = new TestStruct() { X = i, Y = i }; sut.Enqueue(expected); ref var actual = ref sut.Dequeue(); Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); }