Skip to content

Commit

Permalink
add test for ProtoUrlConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
blowfishpro committed Apr 20, 2019
1 parent 6e6a465 commit a0c1dfc
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions ModuleManagerTests/ModuleManagerTests.csproj
Expand Up @@ -108,6 +108,7 @@
<Compile Include="Patches\PatchCompilerTest.cs" />
<Compile Include="Patches\ProtoPatchBuilderTest.cs" />
<Compile Include="PatchListTest.cs" />
<Compile Include="ProtoUrlConfigTest.cs" />
<Compile Include="Collections\ArrayEnumeratorTest.cs" />
<Compile Include="Collections\ImmutableStackTest.cs" />
<Compile Include="Collections\KeyValueCacheTest.cs" />
Expand Down
74 changes: 74 additions & 0 deletions ModuleManagerTests/ProtoUrlConfigTest.cs
@@ -0,0 +1,74 @@
using System;
using Xunit;
using TestUtils;
using ModuleManager;

namespace ModuleManagerTests
{
public class ProtoUrlConfigTest
{
[Fact]
public void TestContructor__UrlFileNull()
{
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(delegate
{
new ProtoUrlConfig(null, new ConfigNode());
});

Assert.Equal("urlFile", ex.ParamName);
}

[Fact]
public void TestContructor__NodeNull()
{
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(delegate
{
new ProtoUrlConfig(UrlBuilder.CreateFile("foo/bar"), null);
});

Assert.Equal("node", ex.ParamName);
}

[Fact]
public void TestUrlFile()
{
UrlDir.UrlFile urlFile = UrlBuilder.CreateFile("abc/def.cfg");
ProtoUrlConfig protoUrlConfig = new ProtoUrlConfig(urlFile, new ConfigNode());

Assert.Same(urlFile, protoUrlConfig.UrlFile);
}

[Fact]
public void TestNode()
{
ConfigNode node = new ConfigNode("NODE");
ProtoUrlConfig protoUrlConfig = new ProtoUrlConfig(UrlBuilder.CreateFile("foo/bar"), node);

Assert.Same(node, protoUrlConfig.Node);
}

[Fact]
public void TestFileUrl()
{
ProtoUrlConfig protoUrlConfig = new ProtoUrlConfig(UrlBuilder.CreateFile("abc/def.cfg"), new ConfigNode());

Assert.Equal("abc/def.cfg", protoUrlConfig.FileUrl);
}

[Fact]
public void TestNodeType()
{
ProtoUrlConfig protoUrlConfig = new ProtoUrlConfig(UrlBuilder.CreateFile("abc/def"), new ConfigNode("SOME_NODE"));

Assert.Equal("SOME_NODE", protoUrlConfig.NodeType);
}

[Fact]
public void TestFullUrl()
{
ProtoUrlConfig protoUrlConfig = new ProtoUrlConfig(UrlBuilder.CreateFile("abc/def.cfg"), new ConfigNode("SOME_NODE"));

Assert.Equal("abc/def.cfg/SOME_NODE", protoUrlConfig.FullUrl);
}
}
}

0 comments on commit a0c1dfc

Please sign in to comment.