forked from jbevain/cecil
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test to reproduce jbevain#859
- Loading branch information
1 parent
49b1c52
commit 1213f5d
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace Mono.Cecil.Tests { | ||
[TestFixture] | ||
public class ImageWriteTests : BaseTestFixture { | ||
|
||
[TestCase("EmbeddedPdbTarget.exe")] | ||
// [TestCase("ExternalPdbDeterministic.dll")] | ||
public void MultipleWriteOperationsShouldReturnSameOutput (string testee) | ||
{ | ||
TestModule (testee, module => { | ||
Assert.IsTrue (module.HasDebugHeader); | ||
const int numberOfStreams = 5; | ||
MemoryStream Write(int _) | ||
{ | ||
var stream = new MemoryStream (); | ||
module.Write (stream, new WriterParameters { WriteSymbols = true }); | ||
return stream; | ||
} | ||
var streams = Enumerable.Range (0, numberOfStreams) | ||
.Select (Write) | ||
.ToArray (); | ||
static bool AreStreamsEqual ((MemoryStream First, MemoryStream Second) pair) | ||
{ | ||
var buffer1 = pair.First.GetBuffer (); | ||
var buffer2 = pair.Second.GetBuffer (); | ||
return buffer1.SequenceEqual (buffer2); | ||
} | ||
var results = streams.Zip (streams.Skip (1)) | ||
.Select (AreStreamsEqual) | ||
.ToArray (); | ||
Assert.That (results, Is.EquivalentTo (results.Select (_ => true))); | ||
}); | ||
} | ||
} | ||
} |