Created
January 9, 2020 08:55
-
-
Save bymyslf/cdaef4e98c06223a3bf9775e5e6bda95 to your computer and use it in GitHub Desktop.
Compare streams
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
public static class StreamAssert | |
{ | |
public static bool AreEquivalent<T>(T left, T right) | |
where T : Stream | |
{ | |
int file1byte; | |
int file2byte; | |
if (left == right) | |
{ | |
return true; | |
} | |
if (left.Length != right.Length) | |
{ | |
return false; | |
} | |
do | |
{ | |
file1byte = left.ReadByte(); | |
file2byte = right.ReadByte(); | |
} | |
while ((file1byte == file2byte) && (file1byte != -1)); | |
return ((file1byte - file2byte) == 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment