public void ArrayBufferConstructorWorks() {
			var buf = new ArrayBuffer(80);
			var arr = new Uint8ClampedArray(buf);
			Assert.IsTrue((object)arr is Uint8ClampedArray);
			Assert.IsTrue(arr.Buffer == buf, "buffer");
			Assert.AreEqual(arr.Length, 80, "length");
		}
		public void CopyConstructorWorks() {
			 var source = new Uint8ClampedArray(new byte[] { 3, 8, 4 });
			 var arr = new Uint8ClampedArray(source);
			 Assert.IsTrue(arr != source, "New object");
			 Assert.IsTrue((object)arr is Uint8ClampedArray, "is Uint8ClampedArray");
			 AssertContent(arr, new[] { 3, 8, 4 }, "content");
		}
		private void AssertContent(Uint8ClampedArray actual, int[] expected, string message) {
			if (actual.Length != expected.Length) {
				Assert.Fail(message + ": Expected length " + expected.Length + ", actual: " + actual.Length);
				return;
			}
			for (int i = 0; i < expected.Length; i++) {
				if (actual[i] != expected[i]) {
					Assert.Fail(message + ": Position " + i + ": expected " + expected[i] + ", actual: " + actual[i]);
					return;
				}
			}
			Assert.IsTrue(true, message);
		}
		public void TypePropertiesAreCorrect() {
			Assert.AreEqual(typeof(Uint8ClampedArray).FullName, "Uint8ClampedArray", "FullName");

			var interfaces = typeof(Uint8ClampedArray).GetInterfaces();
			Assert.AreEqual(interfaces.Length, 3, "Interface count should be 3");
			Assert.IsTrue(interfaces.Contains(typeof(IEnumerable<byte>)), "Interfaces should contain IEnumerable<byte>");
			Assert.IsTrue(interfaces.Contains(typeof(ICollection<byte>)), "Interfaces should contain ICollection<byte>");
			Assert.IsTrue(interfaces.Contains(typeof(IList<byte>)), "Interfaces should contain IList<byte>");

			object arr = new Uint8ClampedArray(0);
			Assert.IsTrue(arr is Uint8ClampedArray, "Is Uint8ClampedArray");
			Assert.IsTrue(arr is IEnumerable<byte>, "Is IEnumerable<byte>");
			Assert.IsTrue(arr is ICollection<byte>, "Is ICollection<byte>");
			Assert.IsTrue(arr is IList<byte>, "Is IList<byte>");
		}
		public void ForeachWorks() {
			var arr = new Uint8ClampedArray(new byte[] { 3, 6, 2, 9, 5 });
			var l = new List<int>();
			foreach (var i in arr) {
				l.Add(i);
			}
			Assert.AreEqual(l, new[] { 3, 6, 2, 9, 5 });
		}
		public void ContainsWorks() {
			var arr = new Uint8ClampedArray(new byte[] { 3, 6, 2, 9, 5 });
			Assert.IsTrue (arr.Contains(9), "9");
			Assert.IsFalse(arr.Contains(1), "1");
		}
		public void IndexOfWorks() {
			var arr = new Uint8ClampedArray(new byte[] { 3, 6, 2, 9, 5 });
			Assert.AreEqual(arr.IndexOf(9), 3, "9");
			Assert.AreEqual(arr.IndexOf(1), -1, "1");
		}
		public void ByteLengthPropertyWorks() {
			var arr = new Uint8ClampedArray(23);
			Assert.AreEqual(arr.ByteLength, 23, "Should be correct");
		}
		public void ByteOffsetPropertyWorks() {
			var buf = new ArrayBuffer(100);
			var arr = new Uint8ClampedArray(buf, 32);
			Assert.AreEqual(arr.ByteOffset, 32, "Should be correct");
		}
 public void Set(Uint8ClampedArray array)
 {
 }
		public void LengthConstructorWorks() {
			var arr = new Uint8ClampedArray(13);
			Assert.IsTrue((object)arr is Uint8ClampedArray, "is Uint8ClampedArray");
			Assert.AreEqual(arr.Length, 13, "Length");
		}
		public void SetNormalArrayWithOffsetWorks() {
			var arr = new Uint8ClampedArray(6);
			arr.Set(new byte[] { 3, 6, 7 }, 2);
			AssertContent(arr, new[] { 0, 0, 3, 6, 7, 0 }, "Content");
		}
		public void SetNormalArrayWorks() {
			var arr = new Uint8ClampedArray(4);
			arr.Set(new byte[] { 3, 6, 7 });
			AssertContent(arr, new[] { 3, 6, 7, 0 }, "Content");
		}
		public void IndexingWorks() {
			var arr = new Uint8ClampedArray(3);
			arr[1] = 42;
			AssertContent(arr, new[] { 0, 42, 0 }, "Content");
			Assert.AreEqual(arr[1], 42, "[1]");
		}
		public void LengthWorks() {
			var arr = new Uint8ClampedArray(13);
			Assert.AreEqual(arr.Length, 13, "Length");
		}
 public Uint8ClampedArray(Uint8ClampedArray array) : base(array)
 {
 }
 public void Set(Uint8ClampedArray array, long offset)
 {
 }
		public void GetEnumeratorWorks() {
			var arr = new Uint8ClampedArray(new byte[] { 3, 6, 2, 9, 5 });
			var l = new List<int>();
			var enm = arr.GetEnumerator();
			while (enm.MoveNext()) {
				l.Add(enm.Current);
			}
			Assert.AreEqual(l, new[] { 3, 6, 2, 9, 5 });
		}
		public Uint8ClampedArray(Uint8ClampedArray array) : base(array) {
		}
		public void Set(Uint8ClampedArray array, long offset) {
		}
		public void SubarrayWithBeginAndEndWorks() {
			var source = new Uint8ClampedArray(10);
			var arr = source.Subarray(3, 7);
			Assert.IsFalse(arr == source, "Should be a new array");
			Assert.IsTrue(arr.Buffer == source.Buffer, "Should be the same buffer");
			Assert.AreEqual(arr.ByteOffset, 3, "ByteOffset should be correct");
			Assert.AreEqual(arr.Length, 4, "Length should be correct");
		}
Exemple #22
0
 public ImageData(Uint8ClampedArray data, int sw, int sh)
 {
 }
		public void BufferPropertyWorks() {
			var buf = new ArrayBuffer(100);
			var arr = new Uint8ClampedArray(buf);
			Assert.IsTrue(arr.Buffer == buf, "Should be correct");
		}
		public void Set(Uint8ClampedArray array) {
		}