using CodeKata.Katas; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace CodeKataTests.Solutions { /// /// Karata Chop Tests. /// [TestClass] public class KarateChopTests { /// /// Returneds the index of the results are zero. /// [TestMethod] public void ReturnedResultsAreZeroIndex() { Assert.AreEqual(0, KarateChop.Chop(1, new int[] { 1 })); Assert.AreEqual(0, KarateChop.Chop(1, new int[] { 1, 3, 5 })); Assert.AreEqual(0, KarateChop.Chop(1, new int[] { 1, 3, 5, 7 })); } /// /// Determines whether this instance [can find targets]. /// [TestMethod] public void CanFindTargets() { Assert.AreEqual(1, KarateChop.Chop(3, new int[] { 1, 3, 5 })); Assert.AreEqual(2, KarateChop.Chop(5, new int[] { 1, 3, 5 })); Assert.AreEqual(1, KarateChop.Chop(3, new int[] { 1, 3, 5, 7 })); Assert.AreEqual(2, KarateChop.Chop(5, new int[] { 1, 3, 5, 7 })); Assert.AreEqual(3, KarateChop.Chop(7, new int[] { 1, 3, 5, 7 })); } /// /// Determines whether this instance [can handle empty arrays]. /// [TestMethod] public void CanHandleEmptyArrays() { Assert.AreEqual(-1, KarateChop.Chop(3, new int[] { })); } /// /// Determines whether this instance [can identify not found targets]. /// [TestMethod] public void CanIdentifyNotFoundTargets() { Assert.AreEqual(-1, KarateChop.Chop(3, new int[] { 1 })); Assert.AreEqual(-1, KarateChop.Chop(0, new int[] { 1, 3, 5 })); Assert.AreEqual(-1, KarateChop.Chop(2, new int[] { 1, 3, 5 })); Assert.AreEqual(-1, KarateChop.Chop(4, new int[] { 1, 3, 5 })); Assert.AreEqual(-1, KarateChop.Chop(6, new int[] { 1, 3, 5 })); Assert.AreEqual(-1, KarateChop.Chop(0, new int[] { 1, 3, 5, 7 })); Assert.AreEqual(-1, KarateChop.Chop(2, new int[] { 1, 3, 5, 7 })); Assert.AreEqual(-1, KarateChop.Chop(4, new int[] { 1, 3, 5, 7 })); Assert.AreEqual(-1, KarateChop.Chop(6, new int[] { 1, 3, 5, 7 })); Assert.AreEqual(-1, KarateChop.Chop(8, new int[] { 1, 3, 5, 7 })); } } }