public void Vector2CopyToTest() { Vector2 v1 = new Vector2(2.0f, 3.0f); Single[] a = new Single[3]; Single[] b = new Single[2]; Assert.Throws <NullReferenceException>(() => v1.CopyTo(null, 0)); Assert.Throws <ArgumentOutOfRangeException>(() => v1.CopyTo(a, -1)); Assert.Throws <ArgumentOutOfRangeException>(() => v1.CopyTo(a, a.Length)); if (!PlatformDetection.IsNetNative) { AssertExtensions.Throws <ArgumentException>(null, () => v1.CopyTo(a, 2)); } else { // The .Net Native code generation optimizer does aggressive optimizations to range checks // which result in an ArgumentOutOfRangeException exception being thrown at runtime. Assert.ThrowsAny <ArgumentException>(() => v1.CopyTo(a, 2)); } v1.CopyTo(a, 1); v1.CopyTo(b); Assert.Equal(0.0, a[0]); Assert.Equal(2.0, a[1]); Assert.Equal(3.0, a[2]); Assert.Equal(2.0, b[0]); Assert.Equal(3.0, b[1]); }