Skip to content

Commit cabadb7

Browse files
committed
IDN extension + test
1 parent d484155 commit cabadb7

4 files changed

Lines changed: 71 additions & 0 deletions

File tree

EppLib.UnitTests/EppLib.UnitTests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</CodeAnalysisDependentAssemblyPaths>
5353
</ItemGroup>
5454
<ItemGroup>
55+
<Compile Include="IdnExtensionLocalTest.cs" />
5556
<Compile Include="LaunchPhaseExtensionLocalTest.cs" />
5657
<Compile Include="LocalTest.cs" />
5758
<Compile Include="NominetExtensionLocalTest.cs" />
@@ -118,6 +119,9 @@
118119
<Content Include="TestData\ContactUpdateResponse1.xml">
119120
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
120121
</Content>
122+
<Content Include="TestData\IdnDomainCreateCommand.xml">
123+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
124+
</Content>
121125
<Content Include="TestData\FuryGetAgreementResponse.xml">
122126
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
123127
</Content>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using EppLib.Entities;
2+
using EppLib.Extensions.Idn;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using System.IO;
5+
6+
namespace EppLib.Tests
7+
{
8+
[TestClass]
9+
public class IdnExtensionLocalTest
10+
{
11+
[TestMethod]
12+
[TestCategory("FuryExtension")]
13+
[DeploymentItem("TestData/IdnDomainCreateCommand.xml")]
14+
public void Test()
15+
{
16+
string expected = File.ReadAllText("IdnDomainCreateCommand.xml");
17+
18+
var command = new DomainCreate("xn--espaol-zwa.example.com", "jd1234");
19+
command.Password = "2fooBAR";
20+
command.DomainContacts.Add(new DomainContact("sh8013", "admin"));
21+
command.DomainContacts.Add(new DomainContact("sh8013", "tech"));
22+
23+
command.Extensions.Add(new IdnExtension("es", "español.example.com"));
24+
25+
var xml = command.ToXml().InnerXml;
26+
27+
Assert.AreEqual(expected, xml);
28+
}
29+
30+
}
31+
}

EppLib/EppLib.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<Compile Include="Extensions\Fury\FuryGetAgreementExtension.cs" />
5858
<Compile Include="Extensions\Fury\GetAgreement.cs" />
5959
<Compile Include="Extensions\Fury\GetAgreementResponse.cs" />
60+
<Compile Include="Extensions\Idn\IdnExtension.cs" />
6061
<Compile Include="Extensions\Iis\IisContactCreate.cs" />
6162
<Compile Include="Extensions\Iis\IisContactCreateExtension.cs" />
6263
<Compile Include="Extensions\Iis\IisContactExtension.cs" />
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using EppLib.Entities;
2+
using System.Xml;
3+
4+
namespace EppLib.Extensions.Idn
5+
{
6+
public class IdnExtension : EppExtension
7+
{
8+
private string _ns = "urn:ietf:params:xml:ns:idn-1.0";
9+
10+
private string table;
11+
private string uname;
12+
13+
public IdnExtension(string table, string uname)
14+
{
15+
this.table = table;
16+
this.uname = uname;
17+
}
18+
19+
protected override string Namespace
20+
{
21+
get { return _ns; }
22+
set { _ns = value; }
23+
}
24+
25+
public override XmlNode ToXml(XmlDocument doc)
26+
{
27+
var root = CreateElement(doc, "idn:data");
28+
29+
AddXmlElement(doc, root, "idn:table", table);
30+
AddXmlElement(doc, root, "idn:uname", uname);
31+
32+
return root;
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)