Skip to content

Instantly share code, notes, and snippets.

@Souzooka
Last active August 30, 2017 19:20
Show Gist options
  • Select an option

  • Save Souzooka/4bf061547d4c28d13cf9897242ab7ce4 to your computer and use it in GitHub Desktop.

Select an option

Save Souzooka/4bf061547d4c28d13cf9897242ab7ce4 to your computer and use it in GitHub Desktop.
Kata Test Template
// 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