public void TestCircularBufferMatchesBytePattern() { byte[] testBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04 }; Assert.IsTrue(GifFormatChecker.CircularBufferMatchesBytePattern(testBytes, 0, testBytes)); for (int i = 1; i < testBytes.Length; i++) { Assert.IsFalse(GifFormatChecker.CircularBufferMatchesBytePattern(testBytes, i, testBytes)); } byte[] testInnerBytes = new byte[] { 0x01, 0x02 }; Assert.IsTrue(GifFormatChecker.CircularBufferMatchesBytePattern(testBytes, 1, testInnerBytes)); for (int i = 2; i < testBytes.Length; i++) { Assert.IsFalse(GifFormatChecker.CircularBufferMatchesBytePattern( testBytes, i, testInnerBytes)); } byte[] testCircularBytes = new byte[] { (byte)0x04, (byte)0x00 }; Assert.IsTrue(GifFormatChecker.CircularBufferMatchesBytePattern( testBytes, 4, testCircularBytes)); for (int i = 0; i < 4; i++) { Assert.IsFalse(GifFormatChecker.CircularBufferMatchesBytePattern( testBytes, i, testCircularBytes)); } }
private async Task SingleAnimatedGifTest( IList <string> resourceNames, bool expectedAnimated) { foreach (string name in resourceNames) { Stream resourceStream = await GetResourceStream(name); try { Assert.AreEqual( expectedAnimated, GifFormatChecker.IsAnimated(resourceStream), "failed with resource: " + name); } finally { resourceStream.Dispose(); } } }