();
}
+ [Fact]
+ public void RenderTwoSectionOutletsWithSameSectionId_TrowsException()
+ {
+ _appElement.FindElement(By.Id("section-outlet-same-id")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains("There is already a subscriber to the content with the given section ID 'System.Object'", logs[0].Message);
+ }
+
+ [Fact]
+ public void RenderTwoSectionOutletsWithSameSectionName_TrowsException()
+ {
+ _appElement.FindElement(By.Id("section-outlet-same-name")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains("There is already a subscriber to the content with the given section ID 'test1'", logs[0].Message);
+ }
+
+ [Fact]
+ public void RenderTwoSectionOutletsWithEqualSectionNameToSectionId_TrowsException()
+ {
+ _appElement.FindElement(By.Id("section-outlet-equal-name-id")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains("There is already a subscriber to the content with the given section ID 'test2'", logs[0].Message);
+ }
+
+ [Fact]
+ public void RenderSectionOutletWithSectionNameAndSectionId_TrowsException()
+ {
+ _appElement.FindElement(By.Id("section-outlet-with-name-id")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains($"{nameof(SectionOutlet)} requires that '{nameof(SectionOutlet.SectionName)}' and '{nameof(SectionOutlet.SectionId)}' cannot both have non-null values.", logs[0].Message);
+ }
+
+ [Fact]
+ public void RenderSectionOutletWithoutSectionNameAndSectionId_TrowsException()
+ {
+ _appElement.FindElement(By.Id("section-outlet-without-name-id")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains($"{nameof(SectionOutlet)} requires a non-null value either for '{nameof(SectionOutlet.SectionName)}' or '{nameof(SectionOutlet.SectionId)}'.", logs[0].Message);
+ }
+
+ [Fact]
+ public void RenderSectionContentWithSectionNameAndSectionId_ThrowsException()
+ {
+ _appElement.FindElement(By.Id("section-content-with-name-id")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains($"{nameof(SectionContent)} requires that '{nameof(SectionContent.SectionName)}' and '{nameof(SectionContent.SectionId)}' cannot both have non-null values.", logs[0].Message);
+ }
+
+ [Fact]
+ public void RenderSectionContentWithoutSectionNameAndSectionId_ThrowsException()
+ {
+ _appElement.FindElement(By.Id("section-content-without-name-id")).Click();
+
+ var logs = Browser.GetBrowserLogs(LogLevel.Severe);
+
+ Assert.True(logs.Count > 0);
+
+ Assert.Contains($"{nameof(SectionContent)} requires a non-null value either for '{nameof(SectionContent.SectionName)}' or '{nameof(SectionContent.SectionId)}'.", logs[0].Message);
+ }
+
[Fact]
public void NoExistingSectionContents_SectionOutletsRenderNothing()
{
@@ -38,7 +123,7 @@ public void NoExistingSectionContents_SectionOutletsRenderNothing()
}
[Fact]
- public void RenderOneSectionContent_MatchingSectionOutletRendersContentSuccessfully()
+ public void RenderSectionContentWithSectionId_MatchingSectionOutletRendersContentSuccessfully()
{
_appElement.FindElement(By.Id("counter-render-section-content")).Click();
@@ -51,7 +136,15 @@ public void RenderOneSectionContent_MatchingSectionOutletRendersContentSuccessfu
}
[Fact]
- public void RenderTwoSectionContentsWithSameId_LastRenderedOverridesSectionOutletContent()
+ public void RenderSectionContentWithSectionName_MatchingSectionOutletRendersContentSuccessfully()
+ {
+ _appElement.FindElement(By.Id("section-content-with-name")).Click();
+
+ Browser.Exists(By.Id("test6"));
+ }
+
+ [Fact]
+ public void RenderTwoSectionContentsWithSameSectionId_LastRenderedOverridesSectionOutletContent()
{
_appElement.FindElement(By.Id("counter-render-section-content")).Click();
@@ -90,14 +183,14 @@ public void BothSectionContentsGetDisposed_SectionOutletsRenderNothing()
}
[Fact]
- public void SectionContentIdChanges_MatchingSectionOutletRendersContent()
+ public void SectionContentSectionIdChanges_MatchingSectionOutletWithSectionNameRendersContent()
{
// Render Counter and TextComponent SectionContents with same Name
// TextComponent SectionContent overrides Counter SectionContent
_appElement.FindElement(By.Id("counter-render-section-content")).Click();
_appElement.FindElement(By.Id("text-render-section-content")).Click();
- _appElement.FindElement(By.Id("counter-change-section-content-name")).Click();
+ _appElement.FindElement(By.Id("counter-change-section-content-id")).Click();
Browser.Exists(By.Id("counter"));
}
@@ -110,11 +203,29 @@ public void SectionContentIdChangesToNonExisting_NoMatchingSectionOutletResultin
_appElement.FindElement(By.Id("counter-render-section-content")).Click();
_appElement.FindElement(By.Id("text-render-section-content")).Click();
- _appElement.FindElement(By.Id("counter-change-section-content-name-nonexisting")).Click();
+ _appElement.FindElement(By.Id("counter-change-section-content-id-nonexisting")).Click();
Browser.DoesNotExist(By.Id("counter"));
}
+ [Fact]
+ public void SectionContentSectionNameChanges_MatchingSectionOutletWithSectionIdRendersContent()
+ {
+ _appElement.FindElement(By.Id("section-content-with-name")).Click();
+
+ _appElement.FindElement(By.Id("counter-render-section-content")).Click();
+ _appElement.FindElement(By.Id("counter-change-section-content-id")).Click();
+
+ // Counter Component Content overrides second SectionContent
+ Browser.DoesNotExist(By.Id("test6"));
+ Browser.Exists(By.Id("counter"));
+
+ _appElement.FindElement(By.Id("section-content-with-name-change-name")).Click();
+
+ Browser.Exists(By.Id("test6"));
+ Browser.Exists(By.Id("counter"));
+ }
+
[Fact]
public void SectionOutletGetsDisposed_NoContentsRendered()
{
diff --git a/src/Components/test/testassets/BasicTestApp/SectionsTest/ParentComponentWithTwoChildren.razor b/src/Components/test/testassets/BasicTestApp/SectionsTest/ParentComponentWithTwoChildren.razor
index 4834b62abcd2..1d48ec85a868 100644
--- a/src/Components/test/testassets/BasicTestApp/SectionsTest/ParentComponentWithTwoChildren.razor
+++ b/src/Components/test/testassets/BasicTestApp/SectionsTest/ParentComponentWithTwoChildren.razor
@@ -2,20 +2,118 @@
Parent Component
-@if (SectionOutletExists)
+@if (FirstSectionOutletExists)
{
}
Text between two section outlets
-
+
+
+Text between two section outlets
+
+
+
+@if (SectionOutletWithSameSectionIdExists)
+{
+
+}
+
+
+
+@if (SectionOutletWithSameSectionNameExists)
+{
+
+
+}
+
+
+
+@if (SectionOutletWithEqualSectionNameToSectionIdExist)
+{
+
+
+}
+
+
+
+@if (SectionOutletWithSectionNameAndSectionIdExists)
+{
+
+}
+
+
+
+@if (SectionOutletWithoutSectionNameAndSectionIdExists)
+{
+
+}
+
+
+
+@if (SectionContentWithSectionNameAndSectionIdExists)
+{
+
+ Test4
+
+}
+
+
+
+@if (SectionContentWithoutSectionNameAndSectionIdExists)
+{
+
+ Test5
+
+}
+
+
+
+@if (SectionContentWithSectionNameExists)
+{
+
+ Test6
+
+}
+
+
+
+
+
@@ -33,16 +131,22 @@
Dispose Counter SectionContent
-