using System; using System.Collections.Generic; using NUnit.Framework; using StuntJuice.Portal.Core.DesignByContract; namespace StuntJuice.Portal.Core.Tests { [TestFixture] public class DesignByContractTestCases { [Test] public void CanCall_ObjectCheckOptions() { List testList = new List(); Check.Parameter(testList).WithMessage("testList cannot be null").IsNotNull(); } [Test] [ExpectedException(typeof(ArgumentNullException))] public void Throws_ArgumentNullException_When_Parameter_IsNull() { List testList = new List(); testList = null; Check.Parameter(testList).IsNotNull(); } [Test] [ExpectedException(typeof(ArgumentNullException))] public void CanCall_ThrowArgumentNullException_WithoutMessage() { Check.ThrowArgumentNullException(""); } [Test] [ExpectedException(typeof(ArgumentNullException), "some message")] public void CanCall_ThrowArgumentNullException_WithMessage() { Check.ThrowArgumentNullException("some message"); } [Test] public void CanCall_Parameter() { Check.Parameter("some string"); Check.Parameter(new List()); } [Test] public void CanCall_IsNotNullOrEmpty() { StringCheckOptions checkOptions = new StringCheckOptions("someval"); checkOptions.IsNotNullOrEmpty(); } [Test] [ExpectedException(typeof(ArgumentNullException), "something")] public void Throws_ArgumentNullException_If_IsNullOrEmpty() { StringCheckOptions checkOptions = new StringCheckOptions(""); checkOptions.WithMessage("something").IsNotNullOrEmpty(); } } }