|
using System;
using System.Net;
using Bdev.Net.Dns;
using NUnit.Framework;
namespace Bdev.Net.Dns.NUnit
{
/// <summary>
/// Summary description for Class1.
/// </summary>
[TestFixture]
public class Exceptions
{
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void MXLookupNullFirstParameter()
{
MXRecord[] records = Resolver.MXLookup(null, IPAddress.Parse("127.0.0.1"));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void MXLookupNullSecondParameter()
{
MXRecord[] records = Resolver.MXLookup("codeproject.com", null);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void MXLookupNullBothParameters()
{
MXRecord[] records = Resolver.MXLookup(null, null);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void MXLookupBadDomainName()
{
MXRecord[] records = Resolver.MXLookup("!�$%^&*()", IPAddress.Parse("127.0.0.1"));
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void MXLookupEmptyDomainName()
{
MXRecord[] records = Resolver.MXLookup(string.Empty, IPAddress.Parse("127.0.0.1"));
}
// --------------------------
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void LookupNullFirstParameter()
{
Response response = Resolver.Lookup(null, IPAddress.Parse("127.0.0.1"));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void LookupNullSecondParameter()
{
Response response = Resolver.Lookup(new Request(), null);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void LookupNullBothParameters()
{
Response response = Resolver.Lookup(null, null);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void NewQuestionDomainNull()
{
Question question = new Question(null, DnsType.MX, DnsClass.IN);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void NewQuestionDomainBad()
{
Question question = new Question("$$$$$.com", DnsType.MX, DnsClass.IN);
}
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void NewQuestionBadType()
{
Question question = new Question("codeproject.com", (DnsType)1999, DnsClass.IN);
}
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void NewQuestionBadClass()
{
Question question = new Question("codeproject.com", DnsType.ANAME, (DnsClass)1999);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a .NET architect/developer based in London working mostly on financial trading systems. My love of computers started at an early age with BASIC on a 3KB VIC20 and progressed onto a 32KB BBC Micro using BASIC and 6502 assembly language. From there I moved on to the blisteringly fast Acorn Archimedes using BASIC and ARM assembly.
I started developing with C++ since 1990, where it was introduced to me in my first year studying for a Computer Science degree at the University of Nottingham. I started professionally with Visual C++ version 1.51 in 1993.
I moved over to C# and .NET in early 2004 after a long period of denial that anything could improve upon C++.
Recently I did a bit of work in my old language of C++ and I now realise that frankly, it's a total pain in the arse.