private static void RenderDynamicOverlayAndVerify(IMappingService mapSvc, RuntimeMap map, string fileName, string format) { using (var stream = mapSvc.RenderDynamicOverlay(map, map.Selection, format)) { using (var ms = new MemoryStream()) using (var ms2 = new MemoryStream()) using (var fs = new FileStream(fileName, FileMode.OpenOrCreate)) { Utility.CopyStream(stream, ms); Utility.CopyStream(ms, ms2); Utility.CopyStream(ms, fs); //See if System.Drawing.Image accepts this try { using (var img = System.Drawing.Image.FromStream(ms)) { } } catch (Exception ex) { Assert.Fail(ex.Message); } } } }