73 lines
3.4 KiB
C#
73 lines
3.4 KiB
C#
|
using System;
|
|||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||
|
using Cloudfare_DNS_Updater;
|
|||
|
using System.IO;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Threading;
|
|||
|
|
|||
|
namespace CloudflareDNSTests
|
|||
|
{
|
|||
|
[TestClass]
|
|||
|
public class UnitTest1
|
|||
|
{
|
|||
|
[TestInitialize]
|
|||
|
public void TestInitilisation()
|
|||
|
{
|
|||
|
Program.WriteFile(Environment.CurrentDirectory + "\\Credentials.dat", new string[] { Authority.auth_domain_tag + " = " + "test", Authority.auth_email_tag + " = " + "tester@test.com", Authority.auth_key_tag + " = " + "1234", Authority.auth_zone_tag + " = " + "te", Authority.auth_dns_tag + " = " + "tester" });
|
|||
|
Program.WriteFile(Environment.CurrentDirectory + "\\CredentialsMultiple.dat",
|
|||
|
new string[] { Authority.auth_domain_tag + " = " + "test", Authority.auth_email_tag + " = " + "tester@test.com", Authority.auth_key_tag + " = " + "1234", Authority.auth_zone_tag + " = " + "te", Authority.auth_dns_tag + " = " + "tester",
|
|||
|
"-###",
|
|||
|
Authority.auth_domain_tag + " = " + "test2", Authority.auth_email_tag + " = " + "tester2@test.com", Authority.auth_key_tag + " = " + "21234", Authority.auth_zone_tag + " = " + "te2", Authority.auth_dns_tag + " = " + "tester2"});
|
|||
|
}
|
|||
|
|
|||
|
[TestCleanup]
|
|||
|
public void TestCleanup()
|
|||
|
{
|
|||
|
int attempts = 0;
|
|||
|
while (attempts++ < 10)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
File.Delete(Environment.CurrentDirectory + "\\Credentials.dat");
|
|||
|
File.Delete(Environment.CurrentDirectory + "\\CredentialsMultiple.dat");
|
|||
|
attempts = 10;
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
Thread.Sleep(500);
|
|||
|
}
|
|||
|
}
|
|||
|
[TestMethod]
|
|||
|
public void TestLoadFile()
|
|||
|
{
|
|||
|
object[] data1 = Program.LoadData(Environment.CurrentDirectory + "\\Credentials.dat");
|
|||
|
List<Authority> authorities = (List<Authority>)data1[1];
|
|||
|
Assert.AreEqual(authorities[0].DomainTag.EvaluateAll(), "test");
|
|||
|
Assert.AreEqual(authorities[0].EmailTag.EvaluateAll(), "tester@test.com");
|
|||
|
Assert.AreEqual(authorities[0].KeyTag.EvaluateAll(), "1234");
|
|||
|
Assert.AreEqual(authorities[0].ZoneTag.EvaluateAll(), "te");
|
|||
|
Assert.AreEqual(authorities[0].DnsTag.EvaluateAll(), "tester");
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void TestLoadFileDouble()
|
|||
|
{
|
|||
|
object[] data1 = Program.LoadData(Environment.CurrentDirectory + "\\CredentialsMultiple.dat");
|
|||
|
List<Authority> authorities = (List<Authority>)data1[1];
|
|||
|
Assert.AreEqual(authorities[0].DomainTag.EvaluateAll(), "test");
|
|||
|
Assert.AreEqual(authorities[0].EmailTag.EvaluateAll(), "tester@test.com");
|
|||
|
Assert.AreEqual(authorities[0].KeyTag.EvaluateAll(), "1234");
|
|||
|
Assert.AreEqual(authorities[0].ZoneTag.EvaluateAll(), "te");
|
|||
|
Assert.AreEqual(authorities[0].DnsTag.EvaluateAll(), "tester");
|
|||
|
|
|||
|
Assert.AreEqual(authorities[1].DomainTag.EvaluateAll(), "test2");
|
|||
|
Assert.AreEqual(authorities[1].EmailTag.EvaluateAll(), "tester2@test.com");
|
|||
|
Assert.AreEqual(authorities[1].KeyTag.EvaluateAll(), "21234");
|
|||
|
Assert.AreEqual(authorities[1].ZoneTag.EvaluateAll(), "te2");
|
|||
|
Assert.AreEqual(authorities[1].DnsTag.EvaluateAll(), "tester2");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|