Reformat code

This commit is contained in:
2023-06-01 04:17:16 +02:00
parent 23bfda2d75
commit ef92878cbd
53 changed files with 975 additions and 523 deletions

View File

@@ -16,10 +16,7 @@ public class FakeGlobalConfig : IGlobalConfig
private string _loginHandler = string.Empty;
public void FakeSetLoginHandler(string loginHandler)
{
_loginHandler = loginHandler;
}
public void FakeSetLoginHandler(string loginHandler) { _loginHandler = loginHandler; }
public string LoginHandler => _loginHandler;
@@ -27,18 +24,9 @@ public class FakeGlobalConfig : IGlobalConfig
private bool _authenticated;
public void FakeSetAuthenticated(bool authenticated)
{
_authenticated = authenticated;
}
public bool IsUserAuthenticated(IWebContext context)
{
return _authenticated;
}
public void FakeSetAuthenticated(bool authenticated) { _authenticated = authenticated; }
public void UserDeauthenticate(IWebContext context)
{
_authenticated = false;
}
public bool IsUserAuthenticated(IWebContext context) { return _authenticated; }
public void UserDeauthenticate(IWebContext context) { _authenticated = false; }
}

View File

@@ -5,34 +5,25 @@ namespace VAR.WebFormsCore.Tests.Fakes;
public class FakeWebContext : IWebContext
{
public FakeWebContext(string requestMethod = "GET")
{
RequestMethod = requestMethod;
}
public FakeWebContext(string requestMethod = "GET") { RequestMethod = requestMethod; }
public string RequestPath => string.Empty;
public string RequestMethod { get; }
public Dictionary<string, string?> RequestHeader { get; } = new();
public Dictionary<string, string> RequestCookies { get; } = new();
public Dictionary<string, string?> RequestQuery { get; } = new();
public Dictionary<string, string?> RequestForm { get; } = new();
public List<WritePackage> FakeWritePackages { get; } = new();
public void ResponseWrite(string text)
{
FakeWritePackages.Add(new WritePackage { Text = text, });
}
public void ResponseWrite(string text) { FakeWritePackages.Add(new WritePackage { Text = text, }); }
public void ResponseWriteBin(byte[] content)
{
FakeWritePackages.Add(new WritePackage { Bin = content, });
}
public void ResponseWriteBin(byte[] content) { FakeWritePackages.Add(new WritePackage { Bin = content, }); }
public void ResponseFlush()
{
@@ -50,30 +41,21 @@ public class FakeWebContext : IWebContext
throw new NotImplementedException();
}
public void DelResponseCookie(string cookieName)
{
throw new NotImplementedException();
}
public void DelResponseCookie(string cookieName) { throw new NotImplementedException(); }
private bool _responseHasStarted;
public void FakeSetResponseHasStarted(bool responseHasStarted)
{
_responseHasStarted = responseHasStarted;
}
public void FakeSetResponseHasStarted(bool responseHasStarted) { _responseHasStarted = responseHasStarted; }
public bool ResponseHasStarted => _responseHasStarted;
public int ResponseStatusCode { get; set; } = 200;
public string? ResponseContentType { get; set; }
public Dictionary<string, string> FakeResponseHeaders { get; } = new();
public void SetResponseHeader(string key, string value)
{
FakeResponseHeaders.Add(key, value);
}
public void SetResponseHeader(string key, string value) { FakeResponseHeaders.Add(key, value); }
public void PrepareCacheableResponse()
{
@@ -93,15 +75,9 @@ public struct WritePackage
public override string ToString()
{
if (Text != null)
{
return Text;
}
if (Text != null) { return Text; }
if (Bin == null)
{
return string.Empty;
}
if (Bin == null) { return string.Empty; }
string text = Encoding.UTF8.GetString(Bin ?? Array.Empty<byte>());
return text;
@@ -116,4 +92,4 @@ public static class WritePackageExtensions
string result = string.Join(separator, listStrings);
return result;
}
}
}