using System; using System.Collections.Generic; using System.Linq; using System.Text; using Chefbook.HelperMethods; using NUnit.Framework; namespace UnitTests.HelperMethodsTests { [TestFixture] public class ParameterValidationFixture { [Test] public void ThrowIfNullTest1() { object a = null; Assert.Throws(() => a.ThrowIfNull("a")); } [Test] public void ThrowIfNullTest2() { object a = new object(); object b = null; Assert.DoesNotThrow(() => b = a.ThrowIfNull("a")); Assert.AreEqual(a, b, "ThrowIfNull didn't return the value when it wasn't null"); } [Test] public void ThrowIfFalseTest1() { bool a = false; Assert.Throws(() => a.ThrowIfFalse("a")); } [Test] public void ThrowIfFalseTest2() { bool a = true; bool b = false; Assert.DoesNotThrow(() => b = a.ThrowIfNull("a")); Assert.AreEqual(a, b, "ThrowIfNull didn't return the value when it wasn't null"); } [Test] public void ValidateArgument1() { string test = "Testing"; Assert.Throws( () => ParameterValidation.ValidateArgument( () => test.Length == 3, "test")); } [Test] public void ValidateArgument2() { string test = "Testing"; Assert.DoesNotThrow( () => ParameterValidation.ValidateArgument( () => test.Length == 7, "test")); } } }