Forked from Souzooka/gist:4bf061547d4c28d13cf9897242ab7ce4
Created
August 30, 2017 19:20
-
-
Save petkovicm/4379f4fab44c6391fe9f8b218f3d3b22 to your computer and use it in GitHub Desktop.
Kata Test Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To set this project up: | |
| // Go to Project -> Manage NuGet Packages | |
| // Install NUnit and NUnit3TestAdapter | |
| // Run any tests on the left in Test Explorer | |
| namespace Kata_Test_Template | |
| { | |
| // User solution | |
| using System; | |
| public class Kata | |
| { | |
| public static string HowMuchILoveYou(int nb_petals) | |
| { | |
| string[] choices = new string[] { "I love you", "a little", "a lot", "passionately", "madly", "not at all" }; | |
| int petal = nb_petals % 6; | |
| return choices[petal]; | |
| } | |
| } | |
| // User solution end | |
| // Needed to compile | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| } | |
| } | |
| } | |
| // Tests | |
| // Any tests can be copied into this segment. | |
| // If tests are replaced, make sure namespace Solution has the "using Kata_Test_Template;" directive | |
| namespace Solution | |
| { | |
| using Kata_Test_Template; | |
| using NUnit.Framework; | |
| using System; | |
| using System.Collections.Generic; | |
| [TestFixture, Description("Petal Tests")] | |
| public class Test | |
| { | |
| public static IEnumerable<TestCaseData> TestCases | |
| { | |
| get | |
| { | |
| yield return new TestCaseData(7).Returns("I love you").SetName("Should return first element after full loop"); | |
| yield return new TestCaseData(3).Returns("a lot").SetName("Should return third element"); | |
| yield return new TestCaseData(6).Returns("not at all").SetName("Should return sixth element"); | |
| } | |
| } | |
| [Test, TestCaseSource("TestCases")] | |
| public string FixedTest(int n) => Kata.HowMuchILoveYou(n); | |
| } | |
| } | |
| // End Tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment