GetContentForReading() public method

public GetContentForReading ( string sigName ) : Stream
sigName string
return Stream
Ejemplo n.º 1
0
		public void Generate_check()
		{
			using (var signatureRepository = new VolatileSignatureRepository("test"))
			using (var rested = new SigGenerator())
			{
				var result = rested.GenerateSignatures(_stream, "test", signatureRepository);
				Assert.Equal(2, result.Count);
				using (var content = signatureRepository.GetContentForReading(result[0].Name))
				{
					Assert.Equal("91b64180c75ef27213398979cc20bfb7", content.GetMD5Hash());
				}
				using (var content = signatureRepository.GetContentForReading(result[1].Name))
				{
					Assert.Equal("9fe9d408aed35769e25ece3a56f2d12f", content.GetMD5Hash());
				}
			}
		}
Ejemplo n.º 2
0
		public void Should_be_the_same_signatures()
		{
			const int size = 1024*1024*5;
			var randomStream = new RandomStream(size);
			var buffer = new byte[size];
			randomStream.Read(buffer, 0, size);
			var stream = new MemoryStream(buffer);

			var firstSigContentHashes = new List<string>();

			using (var signatureRepository = new VolatileSignatureRepository("test"))
			using (var rested = new SigGenerator())
			{
				var result = rested.GenerateSignatures(stream, "test", signatureRepository);

				foreach (var signatureInfo in result)
				{
					using (var content = signatureRepository.GetContentForReading(signatureInfo.Name))
					{
						firstSigContentHashes.Add(content.GetMD5Hash());
					}
				}
			}

			stream.Position = 0;

			var secondSigContentHashes = new List<string>();

			using (var signatureRepository = new VolatileSignatureRepository("test"))
			using (var rested = new SigGenerator())
			{
				var result = rested.GenerateSignatures(stream, "test", signatureRepository);

				foreach (var signatureInfo in result)
				{
					using (var content = signatureRepository.GetContentForReading(signatureInfo.Name))
					{
						secondSigContentHashes.Add(content.GetMD5Hash());
					}
				}
			}

			Assert.Equal(firstSigContentHashes.Count, secondSigContentHashes.Count);

			for (var i = 0; i < firstSigContentHashes.Count; i++)
			{
				Assert.Equal(firstSigContentHashes[i], secondSigContentHashes[i]);
			}
		}