diff --git a/VAR.WebFormsCore.Tests/Code/ScriptsBundlerTests.cs b/VAR.WebFormsCore.Tests/Code/ScriptsBundlerTests.cs new file mode 100644 index 0000000..f14805b --- /dev/null +++ b/VAR.WebFormsCore.Tests/Code/ScriptsBundlerTests.cs @@ -0,0 +1,21 @@ +using Xunit; +using VAR.WebFormsCore.Code; +using VAR.WebFormsCore.Tests.Fakes; + +namespace VAR.WebFormsCore.Tests.Code; + +public class ScriptsBundlerTests +{ + [Fact] + public void ProcessRequest__Base__IntrinsicScripts() + { + FakeWebContext fakeWebContext = new(); + ScriptsBundler scriptsBundler = new(); + + scriptsBundler.ProcessRequest(fakeWebContext); + + Assert.Single(fakeWebContext.FakeWritePackages); + + // TODO: Verify contents of intrinsic scripts + } +} \ No newline at end of file diff --git a/VAR.WebFormsCore.Tests/Code/StylesBundlerTests.cs b/VAR.WebFormsCore.Tests/Code/StylesBundlerTests.cs new file mode 100644 index 0000000..c11683b --- /dev/null +++ b/VAR.WebFormsCore.Tests/Code/StylesBundlerTests.cs @@ -0,0 +1,21 @@ +using Xunit; +using VAR.WebFormsCore.Code; +using VAR.WebFormsCore.Tests.Fakes; + +namespace VAR.WebFormsCore.Tests.Code; + +public class StylesBundlerTests +{ + [Fact] + public void ProcessRequest__Base__IntrinsicStyles() + { + FakeWebContext fakeWebContext = new(); + StylesBundler stylesBundler = new(); + + stylesBundler.ProcessRequest(fakeWebContext); + + Assert.Single(fakeWebContext.FakeWritePackages); + + // TODO: Verify contents of intrinsic styles + } +} \ No newline at end of file diff --git a/VAR.WebFormsCore.Tests/Fakes/FakeWebContext.cs b/VAR.WebFormsCore.Tests/Fakes/FakeWebContext.cs new file mode 100644 index 0000000..019da5d --- /dev/null +++ b/VAR.WebFormsCore.Tests/Fakes/FakeWebContext.cs @@ -0,0 +1,77 @@ +using VAR.WebFormsCore.Code; + +namespace VAR.WebFormsCore.Tests.Fakes; + +public class FakeWebContext : IWebContext +{ + public string RequestPath => string.Empty; + + public string RequestMethod => string.Empty; + + public Dictionary RequestHeader { get; } = new(); + + public Dictionary RequestCookies { get; } = new(); + + public Dictionary RequestQuery { get; } = new(); + + public Dictionary RequestForm { get; } = new(); + + public struct WritePackage + { + public string? Text { get; set; } + public byte[]? Bin { get; set; } + } + + public List FakeWritePackages { get; } = new(); + + public void ResponseWrite(string text) + { + FakeWritePackages.Add(new WritePackage { Text = text, }); + } + + public void ResponseWriteBin(byte[] content) + { + FakeWritePackages.Add(new WritePackage { Bin = content, }); + } + + public void ResponseFlush() + { + // NOTE: Nothing to do + } + + public void ResponseRedirect(string url) + { + throw new NotImplementedException(); + } + + public void AddResponseCookie(string cookieName, string value, DateTime? expiration = null) + { + throw new NotImplementedException(); + } + + public void DelResponseCookie(string cookieName) + { + throw new NotImplementedException(); + } + + public bool ResponseHasStarted => false; + + public int ResponseStatusCode { get; set; } + + public string? ResponseContentType { get; set; } + + public void SetResponseHeader(string key, string value) + { + throw new NotImplementedException(); + } + + public void PrepareCacheableResponse() + { + // TODO: Mark as Cacheable response + } + + public void PrepareUncacheableResponse() + { + throw new NotImplementedException(); + } +} \ No newline at end of file