Tests: Add test for FrmEcho.

This commit is contained in:
2023-05-29 01:10:58 +02:00
parent 602ec194fa
commit 82b237f7fd
3 changed files with 102 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
using System.Text;
using VAR.WebFormsCore.Code;
namespace VAR.WebFormsCore.Tests.Fakes;
@@ -21,12 +22,6 @@ public class FakeWebContext : IWebContext
public Dictionary<string, string?> RequestForm { get; } = new();
public struct WritePackage
{
public string? Text { get; set; }
public byte[]? Bin { get; set; }
}
public List<WritePackage> FakeWritePackages { get; } = new();
public void ResponseWrite(string text)
@@ -79,4 +74,36 @@ public class FakeWebContext : IWebContext
{
throw new NotImplementedException();
}
}
}
public struct WritePackage
{
public string? Text { get; set; }
public byte[]? Bin { get; set; }
public override string ToString()
{
if (Text != null)
{
return Text;
}
if (Bin == null)
{
return string.Empty;
}
string text = Encoding.UTF8.GetString(Bin ?? Array.Empty<byte>());
return text;
}
}
public static class WritePackageExtensions
{
public static string ToString(this List<WritePackage> list, string separator)
{
IEnumerable<string> listStrings = list.Select(x => x.ToString());
string result = string.Join(separator, listStrings);
return result;
}
}