Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ucm: Unit tests #12

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion NUcmSerializer/NUcmSerializer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUcmSerializer", "src\NUcmSerializer.csproj", "{3149996B-8671-4E26-8A24-710BD4DC7EBB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUcmSerializer", "src\NUcmSerializer.csproj", "{3149996B-8671-4E26-8A24-710BD4DC7EBB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUcmSerializerTests", "tests\NUcmSerializerTests.csproj", "{019E547D-2604-4111-921B-A71A9849280B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Debug|x64.ActiveCfg = Debug|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Debug|x64.Build.0 = Debug|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Release|Any CPU.Build.0 = Release|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Release|x64.ActiveCfg = Release|Any CPU
{3149996B-8671-4E26-8A24-710BD4DC7EBB}.Release|x64.Build.0 = Release|Any CPU
{019E547D-2604-4111-921B-A71A9849280B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{019E547D-2604-4111-921B-A71A9849280B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{019E547D-2604-4111-921B-A71A9849280B}.Debug|x64.ActiveCfg = Debug|x64
{019E547D-2604-4111-921B-A71A9849280B}.Debug|x64.Build.0 = Debug|x64
{019E547D-2604-4111-921B-A71A9849280B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{019E547D-2604-4111-921B-A71A9849280B}.Release|Any CPU.Build.0 = Release|Any CPU
{019E547D-2604-4111-921B-A71A9849280B}.Release|x64.ActiveCfg = Release|x64
{019E547D-2604-4111-921B-A71A9849280B}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions NUcmSerializer/src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: InternalsVisibleTo("NUcmSerializerTests")]
12 changes: 12 additions & 0 deletions NUcmSerializer/tests/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.1.9",
"commands": [
"reportgenerator"
]
}
}
}
2 changes: 2 additions & 0 deletions NUcmSerializer/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Unit tests artifacts
TestResults/
17 changes: 17 additions & 0 deletions NUcmSerializer/tests/.runsettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>TestResults</ResultsDirectory>
<SolutionDirectory>..\</SolutionDirectory>
<CollectSourceInformation>False</CollectSourceInformation>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>cobertura</Format>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
151 changes: 151 additions & 0 deletions NUcmSerializer/tests/AttributesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using NUcmSerializer;
using Xunit;

namespace NUcmSerializerTests
{
public class UcmNamedTagAttributesTests
{
[Fact]
public void TestPropertyName()
{
Assert.Equal(string.Empty, new UcmElementAttribute("").Name);
}
}

public class UcmElementAttributeTests
{
[Fact]
public void TestConstructor()
{
new UcmElementAttribute(string.Empty);
new UcmElementAttribute(null);
new UcmElementAttribute();
}
}

public class UcmArrayAttributeTests
{
UcmArrayAttribute attribute;

public UcmArrayAttributeTests()
{
attribute = new UcmArrayAttribute();
}

[Fact]
public void TestConstructor()
{
new UcmArrayAttribute(string.Empty, true);
new UcmArrayAttribute(null, false);
new UcmArrayAttribute(true);
new UcmArrayAttribute(null);
new UcmArrayAttribute();
}

[Fact]
public void TestPropertyInline()
{
bool flag = true;

attribute.Inline = flag;
Assert.Equal(flag, attribute.Inline);
}

[Fact]
public void TestPropertyTagElements()
{
bool flag = true;

attribute.TagElements = flag;
Assert.Equal(flag, attribute.TagElements);
}
}

public class UcmSectionAttributeTests
{
UcmSectionAttribute attribute;

public UcmSectionAttributeTests()
{
attribute = new UcmSectionAttribute();
}

[Fact]
public void TestConstructor()
{
new UcmSectionAttribute(string.Empty, "id");
new UcmSectionAttribute(null, null);
new UcmSectionAttribute(null);
new UcmSectionAttribute();
}

[Fact]
public void TestPropertyIdentifier()
{
string s = "module0";

attribute.Identifier = s;
Assert.Equal(s, attribute.Identifier);
attribute.Identifier = null;
Assert.Null(attribute.Identifier);
}
}

public class UcmExclusiveAttributeTests
{
UcmExclusiveAttribute attribute;

public UcmExclusiveAttributeTests()
{
attribute = new UcmExclusiveAttribute();
}

[Fact]
public void TestConstructor()
{
new UcmExclusiveAttribute(string.Empty);
new UcmExclusiveAttribute(null);
new UcmExclusiveAttribute();
}

[Fact]
public void TestPropertyNamespace()
{
string s = "internal";

attribute.Namespace = s;
Assert.Equal(s, attribute.Namespace);
attribute.Namespace = null;
Assert.Null(attribute.Namespace);
}
}

public class UcmEnumAttributeTests
{
UcmEnumAttribute attribute;

public UcmEnumAttributeTests()
{
attribute = new UcmEnumAttribute();
}

[Fact]
public void TestConstructor()
{
new UcmEnumAttribute(string.Empty);
new UcmEnumAttribute(null);
new UcmEnumAttribute();
}

[Fact]
public void TestPropertyName()
{
string s = "constants";

attribute.Name = s;
Assert.Equal(s, attribute.Name);
attribute.Name = null;
Assert.Null(attribute.Name);
}
}
}
Loading