diff --git a/VAR.WebFormsCore.Tests/Controls/HtmlBodyTests.cs b/VAR.WebFormsCore.Tests/Controls/HtmlBodyTests.cs
new file mode 100644
index 0000000..10ecdc0
--- /dev/null
+++ b/VAR.WebFormsCore.Tests/Controls/HtmlBodyTests.cs
@@ -0,0 +1,25 @@
+using VAR.WebFormsCore.Controls;
+using VAR.WebFormsCore.Pages;
+using VAR.WebFormsCore.Tests.Fakes;
+using Xunit;
+
+namespace VAR.WebFormsCore.Tests.Controls;
+
+public class HtmlBodyTests
+{
+ [Fact]
+ public void MustRenderCorrectly()
+ {
+ FakeWebContext fakeWebContext = new();
+ Page page = new();
+ HtmlBody htmlBody = new();
+ page.Controls.Add(htmlBody);
+
+ page.ProcessRequest(fakeWebContext);
+
+ Assert.Equal(200, fakeWebContext.ResponseStatusCode);
+ Assert.Equal("text/html", fakeWebContext.ResponseContentType);
+ string result = fakeWebContext.FakeWritePackages.ToString("");
+ Assert.Equal("
", result);
+ }
+}
\ No newline at end of file
diff --git a/VAR.WebFormsCore.Tests/Controls/HtmlGenericControlTests.cs b/VAR.WebFormsCore.Tests/Controls/HtmlGenericControlTests.cs
new file mode 100644
index 0000000..6d77bab
--- /dev/null
+++ b/VAR.WebFormsCore.Tests/Controls/HtmlGenericControlTests.cs
@@ -0,0 +1,25 @@
+using VAR.WebFormsCore.Controls;
+using VAR.WebFormsCore.Pages;
+using VAR.WebFormsCore.Tests.Fakes;
+using Xunit;
+
+namespace VAR.WebFormsCore.Tests.Controls;
+
+public class HtmlGenericControlTests
+{
+ [Fact]
+ public void MustRenderCorrectly()
+ {
+ FakeWebContext fakeWebContext = new();
+ Page page = new();
+ HtmlGenericControl htmlGenericControl = new("test");
+ page.Controls.Add(htmlGenericControl);
+
+ page.ProcessRequest(fakeWebContext);
+
+ Assert.Equal(200, fakeWebContext.ResponseStatusCode);
+ Assert.Equal("text/html", fakeWebContext.ResponseContentType);
+ string result = fakeWebContext.FakeWritePackages.ToString("");
+ Assert.Equal("", result);
+ }
+}
\ No newline at end of file
diff --git a/VAR.WebFormsCore.Tests/Controls/HtmlHeadTests.cs b/VAR.WebFormsCore.Tests/Controls/HtmlHeadTests.cs
new file mode 100644
index 0000000..a4e245a
--- /dev/null
+++ b/VAR.WebFormsCore.Tests/Controls/HtmlHeadTests.cs
@@ -0,0 +1,69 @@
+using VAR.WebFormsCore.Controls;
+using VAR.WebFormsCore.Pages;
+using VAR.WebFormsCore.Tests.Fakes;
+using Xunit;
+
+namespace VAR.WebFormsCore.Tests.Controls;
+
+public class HtmlHeadTests
+{
+ [Fact]
+ public void MustRenderCorrectly()
+ {
+ FakeWebContext fakeWebContext = new();
+ Page page = new();
+ HtmlHead htmlHead = new();
+ page.Controls.Add(htmlHead);
+
+ page.ProcessRequest(fakeWebContext);
+
+ Assert.Equal(200, fakeWebContext.ResponseStatusCode);
+ Assert.Equal("text/html", fakeWebContext.ResponseContentType);
+ string result = fakeWebContext.FakeWritePackages.ToString("");
+ Assert.Equal("", result);
+ }
+
+ [Fact]
+ public void MustRenderCorrectlyWithTitle()
+ {
+ FakeWebContext fakeWebContext = new();
+ Page page = new();
+ HtmlHead htmlHead = new();
+ htmlHead.Title = "Test";
+ page.Controls.Add(htmlHead);
+
+ page.ProcessRequest(fakeWebContext);
+
+ Assert.Equal(200, fakeWebContext.ResponseStatusCode);
+ Assert.Equal("text/html", fakeWebContext.ResponseContentType);
+ string result = fakeWebContext.FakeWritePackages.ToString("");
+ Assert.Equal("Test", result);
+ }
+
+ [Fact]
+ public void MustRenderCorrectlyWithMeta()
+ {
+ FakeWebContext fakeWebContext = new();
+ Page page = new();
+ HtmlHead htmlHead = new();
+ page.Controls.Add(htmlHead);
+ HtmlMeta htmlMeta = new()
+ {
+ Name = "TestMeta",
+ Content = "TestMetaContent",
+ HttpEquiv = "TestMetaHttpEquiv"
+ };
+ htmlHead.Controls.Add(htmlMeta);
+
+ page.ProcessRequest(fakeWebContext);
+
+ Assert.Equal(200, fakeWebContext.ResponseStatusCode);
+ Assert.Equal("text/html", fakeWebContext.ResponseContentType);
+ string result = fakeWebContext.FakeWritePackages.ToString("");
+ Assert.Equal(
+ expected: """
+
+ """,
+ actual: result);
+ }
+}
\ No newline at end of file
diff --git a/VAR.WebFormsCore/Controls/Button.cs b/VAR.WebFormsCore/Controls/Button.cs
index fb12e33..dfc09f2 100644
--- a/VAR.WebFormsCore/Controls/Button.cs
+++ b/VAR.WebFormsCore/Controls/Button.cs
@@ -7,14 +7,8 @@ public class Button : Control, IReceivePostbackEvent
{
public Button() { CssClass = "button"; }
- private string _text = string.Empty;
+ public string Text { get; set; } = string.Empty;
- public string Text
- {
- get => _text;
- set => _text = value;
- }
-
public string OnClientClick { get; set; } = string.Empty;
public string CommandArgument { get; set; } = string.Empty;
@@ -25,7 +19,7 @@ public class Button : Control, IReceivePostbackEvent
{
textWriter.Write(" _cssClassExtra;
- set => _cssClassExtra = value;
- }
+ public string CssClassExtra { get; set; } = string.Empty;
- public bool AllowEmpty
- {
- get => _allowEmpty;
- set => _allowEmpty = value;
- }
+ public bool AllowEmpty { get; set; } = true;
- public string PlaceHolder
- {
- get => _placeHolder;
- set => _placeHolder = value;
- }
+ public string PlaceHolder { get; set; } = string.Empty;
- public bool MarkedInvalid
- {
- get => _markedInvalid;
- set => _markedInvalid = value;
- }
+ public bool MarkedInvalid { get; set; }
- public Control? NextFocusOnEnter
- {
- get => _nextFocusOnEnter;
- set => _nextFocusOnEnter = value;
- }
+ public Control? NextFocusOnEnter { get; set; }
- public bool KeepSize
- {
- get => _keepSize;
- set => _keepSize = value;
- }
+ public bool KeepSize { get; set; }
public string Text
{
@@ -94,7 +59,7 @@ public class CTextBox : Control, INamingContainer, IValidableControl
if (TextMode == TextBoxMode.MultiLine)
{
- if (_keepSize)
+ if (KeepSize)
{
_hidSize = new HiddenField();
Controls.Add(_hidSize);
@@ -103,7 +68,7 @@ public class CTextBox : Control, INamingContainer, IValidableControl
string strCfgName = $"{ClientID}_cfg";
Dictionary cfg = new()
{
- {"txtContent", _txtContent.ClientID}, {"hidSize", _hidSize?.ClientID ?? string.Empty}, {"keepSize", _keepSize},
+ {"txtContent", _txtContent.ClientID}, {"hidSize", _hidSize?.ClientID ?? string.Empty}, {"keepSize", KeepSize},
};
StringBuilder sbCfg = new StringBuilder();
sbCfg.AppendFormat("