Created
December 4, 2012 21:24
-
-
Save nnasaki/4208851 to your computer and use it in GitHub Desktop.
FizzBuzz の MSTest によるパラメタライズテスト
This file contains 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
using System; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace FizzBuzzTest | |
{ | |
[TestClass] | |
public class FizzBuzzTest | |
{ | |
public TestContext TestContext { get; set; } | |
[TestMethod] | |
// テストケースの順番は以下の通り | |
// 入力値、三の倍数、五の倍数、出力文字列 | |
[TestCase(3,true,false,"Fizz")] | |
[TestCase(5,false,true,"Buzz")] | |
[TestCase(15,true,true,"FizzBuzz")] | |
[TestCase(0,false,false,"0")] | |
[TestCase(7,false,false,"7")] | |
public void 入力値に応じてFizzBuzzを返す() | |
{ | |
TestContext.Run((int 入力値, bool 三の倍数, bool 五の倍数, string 結果) => | |
{ | |
// Arrange | |
var fizzBuzz = new FizzBuzz.FizzBuzz(入力値); | |
// Act & Assert | |
fizzBuzz.Is三の倍数().Is(三の倍数); | |
fizzBuzz.Is五の倍数().Is(五の倍数); | |
fizzBuzz.Say().Is(結果); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment