Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Added a check for documentation/decision content being specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Aug 15, 2018
1 parent 87a86f5 commit 3b156b9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Structurizr.Core.Tests/Documentation/DocumentationTests.cs
Expand Up @@ -45,6 +45,20 @@ public void test_addSection_ThrowsAnException_WhenTheTitleIsNotSpecified()
}
}

[Fact]
public void test_addSection_ThrowsAnException_WhenTheContentIsNotSpecified()
{
try
{
_documentation.AddSection(null, "Title", Format.Markdown, null);
throw new TestFailedException();
}
catch (ArgumentException iae)
{
Assert.Equal("Content must be specified.", iae.Message);
}
}

[Fact]
public void test_addSection_ThrowsAnException_WhenASectionExistsWithTheSameTitle()
{
Expand Down Expand Up @@ -132,6 +146,20 @@ public void test_addDecision_ThrowsAnException_WhenTheTitleIsNotSpecified()
}
}

[Fact]
public void test_addDecision_ThrowsAnException_WhenTheContentIsNotSpecified()
{
try
{
_documentation.AddDecision("1", new DateTime(), "Title", DecisionStatus.Accepted, Format.Markdown, null);
throw new TestFailedException();
}
catch (ArgumentException iae)
{
Assert.Equal("Content must be specified.", iae.Message);
}
}

[Fact]
public void test_addDecision_ThrowsAnException_WhenADecisionExistsWithTheSameId()
{
Expand Down
10 changes: 10 additions & 0 deletions Structurizr.Core/Documentation/Documentation.cs
Expand Up @@ -72,6 +72,7 @@ internal Section AddSection(Element element, string title, Format format, string
}

CheckTitleIsSpecified(title);
CheckContentIsSpecified(content);
CheckSectionIsUnique(element, title);
CheckFormatIsSpecified(format);

Expand All @@ -88,6 +89,14 @@ private void CheckTitleIsSpecified(string title)
}
}

private void CheckContentIsSpecified(string title)
{
if (String.IsNullOrWhiteSpace(title))
{
throw new ArgumentException("Content must be specified.");
}
}

private void CheckFormatIsSpecified(Format format)
{
if (format == null)
Expand Down Expand Up @@ -129,6 +138,7 @@ public Decision AddDecision(SoftwareSystem softwareSystem, string id, DateTime d
{
CheckIdIsSpecified(id);
CheckTitleIsSpecified(title);
CheckContentIsSpecified(content);
CheckDecisionStatusIsSpecified(status);
CheckFormatIsSpecified(format);
CheckDecisionIsUnique(softwareSystem, id);
Expand Down

0 comments on commit 3b156b9

Please sign in to comment.