using System; using NUnit.Framework; using PV178.Homework1; using System.Collections.Generic; // You will need to download and install NUnit to use this test. // Also, classes PV178.Homework1.IMonster and PV178.Homework1.Mutant // are needed. namespace NunitMutantTest { /// /// Nunit test of a Mutant class. /// [NUnit.Framework.TestFixture] public class MutantTest { private Mutant m; /// /// This method will be executed once at the test initialization. /// [TestFixtureSetUp] public void InitClass() { Console.WriteLine("Set Up Fixture!"); } /// /// This method is called before the execution of every test method. /// [SetUp] public void Init() { m = new Mutant(); Console.WriteLine("SetUp!"); } [Test(Description="Constructor test")] public void TestConstructor() { IMonster m = new Mutant(); } /// /// Testing throwing of an exception. This test uses a collection /// "testCollection" as input. /// /// input of the test [Test] [TestCaseSource("testCollection")] public void TestEyes(int eyes) { if (eyes < 0) { try { m.NumberOfEyes = eyes; Assert.Fail(); } catch (ArgumentException aEx) { } } } /// /// Collection used as an input for testing. /// private IEnumerable testCollection = new List() { -5, -1, 0, 10, 50 }; } }