public static void ValidateReferenceType <T>(this Memory <T> memory, params T[] expected) { T[] bufferArray = memory.ToArray(); Assert.Equal(memory.Length, expected.Length); for (int i = 0; i < expected.Length; i++) { T actual = bufferArray[i]; Assert.Same(expected[i], actual); } }