public unsafe void Pop_Item_After_Expanding_Success() { var expected = new TestStruct() { X = 3, Y = 1 }; ExpandableStack <TestStruct> sut = stackalloc TestStruct[1]; sut.Push(expected); sut.Expand(stackalloc TestStruct[1]); sut.Push(new TestStruct() { X = 1, Y = 1 }); sut.Pop(); var testStruct = sut.Pop(); Assert.AreEqual(0, sut.Count); Assert.AreEqual(expected.X, testStruct.X); Assert.AreEqual(expected.Y, testStruct.Y); }
public unsafe void Pop_Item_Fail() { Assert.Throws <InvalidOperationException>(() => { ExpandableStack <TestStruct> sut = stackalloc TestStruct[1]; sut.Pop(); }); }
public unsafe void Modify_Popped_Item_Success() { var expected = new TestStruct() { X = 3, Y = 1 }; ExpandableStack <TestStruct> sut = stackalloc TestStruct[1]; sut.Push(expected); ref var actual = ref sut.Peek();
public unsafe void Push_Item_Fail() { var expected = new TestStruct() { X = 3, Y = 1 }; ExpandableStack <TestStruct> sut = stackalloc TestStruct[1]; sut.Push(expected); Assert.AreEqual(1, sut.Count); Assert.False(sut.Push(expected)); Assert.AreEqual(1, sut.Count); }
public unsafe void Push_Item_Success() { var expected = new TestStruct() { X = 3, Y = 1 }; ExpandableStack <TestStruct> sut = stackalloc TestStruct[1]; Assert.AreEqual(1, sut.Capacity); Assert.AreEqual(0, sut.Count); Assert.True(sut.Push(expected)); Assert.AreEqual(1, sut.Count); }
public unsafe void Pop_Item_Success() { var expected = new TestStruct() { X = 3, Y = 1 }; ExpandableStack <TestStruct> sut = stackalloc TestStruct[1]; sut.Push(expected); var testStruct = sut.Pop(); Assert.AreEqual(0, sut.Count); Assert.AreEqual(3, testStruct.X); Assert.AreEqual(1, testStruct.Y); }