public void ReadTest() { int expected = 1024; int bytesRead = _parser.Read(_stream); Assert.AreEqual(expected, bytesRead); }
public void DetectWithNoBoundary() { List <byte> content = new List <byte>(); byte[] buffer = new byte[100]; Random random = new Random(1234); random.NextBytes(buffer); content.AddRange((byte[])_boundary); content.AddRange(JPEG_HEADER_BYTES); content.AddRange(buffer); content.AddRange(JPEG_HEADER_BYTES); content.AddRange(buffer); MemoryStream memoryStream = new MemoryStream(content.ToArray()); MJPEGStreamParser parser = new MJPEGStreamParser(new Boundary(), JPEG_HEADER_BYTES); parser.Read(memoryStream); parser.DetectFrame(); Assert.IsTrue(parser.HasFrame); }
public void FixMalformedBoundaryTest() { string expected = "--" + _value; byte[] buffer = Encoding.ASCII.GetBytes(expected); MJPEGStreamParser parser = new MJPEGStreamParser(_boundary, new byte[0]); MemoryStream stream = new MemoryStream(buffer); parser.Read(stream); _boundary.FixMalformedBoundary(parser); Assert.AreEqual(expected, _boundary.Content); }
public void DetectWithNoFrameOrBoundaryTest() { byte[] buffer = new byte[1000]; Random random = new Random(1234); random.NextBytes(buffer); MemoryStream memoryStream = new MemoryStream(buffer); MJPEGStreamParser parser = new MJPEGStreamParser(new Boundary(), JPEG_HEADER_BYTES); parser.Read(memoryStream); parser.DetectFrame(); Assert.IsFalse(parser.HasFrame); }