using System; using Core.Components.DotSpatial.Exceptions; using Microsoft.Win32; using NUnit.Framework; namespace Core.Components.DotSpatial.Test.Exceptions { [TestFixture] public class MapDataExceptionTest { [Test] public void DefaultConstructor_InnerExceptionNullAndMessageDefault() { // Setup string expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(MapDataException).FullName); // Call MapDataException exception = new MapDataException(); // Assert Assert.IsInstanceOf(exception); Assert.IsNull(exception.InnerException); Assert.AreEqual(expectedMessage, exception.Message); } [Test] public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom() { // Setup const string expectedMessage = "Some exception message"; // Call MapDataException exception = new MapDataException(expectedMessage); // Assert Assert.IsInstanceOf(exception); Assert.IsNull(exception.InnerException); Assert.AreEqual(expectedMessage, exception.Message); } [Test] public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom() { // Setup const string expectedMessage = "Some exception message"; Exception expectedInnerException = new Exception(); // Call MapDataException exception = new MapDataException(expectedMessage, expectedInnerException); // Assert Assert.IsInstanceOf(exception); Assert.AreSame(expectedInnerException, exception.InnerException); Assert.AreEqual(expectedMessage, exception.Message); } } }