Created
December 3, 2012 16:01
-
-
Save nnasaki/4195940 to your computer and use it in GitHub Desktop.
入力値によってFizzBuzzの文字列を返すことが出来るSteps
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.Diagnostics; | |
using System.Globalization; | |
using TechTalk.SpecFlow; | |
using TechTalk.SpecFlow.Assist; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace FizzBuzz.Specs | |
{ | |
public class Decision | |
{ | |
public int 入力値 { get; set; } | |
public bool 三の倍数 { get; set; } | |
public bool 五の倍数 { get; set; } | |
public string 結果 { get; set; } | |
} | |
[Binding] | |
public class 入力値によってFizzBuzzの文字列を返すことが出来るSteps | |
{ | |
private System.Collections.Generic.IEnumerable<Decision> _decisionTable; | |
[Given(@"以下のデシジョンテーブルによって入力値と動作を定義する")] | |
public void Setup(Table table) | |
{ | |
_decisionTable = table.CreateSet<Decision>(); | |
} | |
[Then(@"デシジョンテーブルの入力値に対応する結果を表示する")] | |
public void Assert() | |
{ | |
foreach (var decision in _decisionTable) | |
{ | |
Debug.Print(decision.入力値.ToString(CultureInfo.InvariantCulture)); | |
var fizzBuzz = new FizzBuzz(decision.入力値); | |
fizzBuzz.Is三の倍数().Is(decision.三の倍数); | |
fizzBuzz.Is五の倍数().Is(decision.五の倍数); | |
fizzBuzz.Say().Is(decision.結果); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment