put StreamToString to extensions

This commit is contained in:
Alex Bezdieniezhnykh
2025-01-20 10:04:33 +02:00
parent 49de0351c1
commit bfb7b89f32
4 changed files with 18 additions and 12 deletions
+2 -9
View File
@@ -1,5 +1,6 @@
using System.Security.Cryptography;
using System.Text;
using Azaion.Common.Extensions;
using Azaion.Services;
using FluentAssertions;
using Newtonsoft.Json;
@@ -27,7 +28,7 @@ public class SecurityTest
await encryptedStream.DecryptTo(decryptedStream, key);
encryptedStream.Close();
var str = StreamToString(decryptedStream);
var str = decryptedStream.ConvertToString();
str.Should().Be(testString);
}
@@ -91,17 +92,9 @@ public class SecurityTest
return stream;
}
private static string StreamToString(Stream stream)
{
stream.Position = 0;
using var reader = new StreamReader(stream, Encoding.UTF8);
return reader.ReadToEnd();
}
private static Stream StringToStream(string src)
{
var byteArray = Encoding.UTF8.GetBytes(src);
return new MemoryStream(byteArray);
}
}