TDD Boot Camp ã®ãé¡ã C# 㨠Git ã§ãã£ã¦ã¿ã
èªåã§èãããé¡ãèªåã§è§£ãã¨ããããªãã¦ããããã³ãã»ã»ã»
æã¡ä¸ãçµäºå¾ã®ããã«ã¨ãç¿æ¥ã®å¸°ãã®æ°å¹¹ç·ã®ä¸ã§æ¸ããã³ã¼ããé çªã«è¿½ã£ã¦ã¿ã¾ãã
æºåãããã®ã¯ Git ã§ãããã¨ãããã®ã¯ Visual Studio 2010 㨠NUnit ã§ãã
ã¾ããå²ã¨å°ããã³ã¼ã (ãã¹ããå«ãã¦ã 300 è¡ããªã) ã ã C# ãç¥ããªã人ã§ããããªãã«é°å²æ°ã¯æ´ããã¨æãã¾ãã
ãããã®ã¨ã³ããªããªãé·ãã§ãã
æºå
Windows ã®å ´åãGit Bash ãéãã¦ãé©å½ãªãã©ã«ãã«ç§»åãã¦
git clone git://github.com/bleis-tift/MotsunabeZombieProject.git cd MotsunabeZombieProject
ã¨ãã¦ãã ããã
MotsunabeZombieProject ã¨ãããã©ã«ããã§ãã¦ããã®ä¸ã« Git ã®ãªãã¸ããªã¨ããã§ãã¾ãã
Mac ã¨ã Linux ã¨ãã§ãåºæ¬ãããªæãã§ãã¾ã㯠clone ãã¦ãã¦ãã ããã
git clone ã¯å½æ¥èª¬æããªãã£ããã©ããã§ã«ãããªãã¸ããªã丸ãã¨åã£ã¦ããã³ãã³ãã§ãã
git init ã空ã£ã½ã®ãªãã¸ããªãä½ãã®ã«å¯¾ãã¦ãgit clone ã¯æ¢åã®ãªãã¸ããªã®ã³ãã¼ããã¼ã«ã«ã«ä½ãã¾ãã
clone ããããgitk --all & ãã¦ã¿ã¦ãã ããã
master ãã©ã³ãã®ä»ã«ãã¿ã°ãããã¤ãããã¯ãã§ãã
ãããã®ã¿ã°ã¯ãgit now --rebase ããåã«æã£ãã¿ã°ãªã®ã§ãã©ãããã¿ã¤ãã³ã°ã§ git now ãã¦ãããã®åèã«ãã¦ãã ããã
ãé¡
ãé¡ãç°¡åã«ã¾ã¨ããã¨ããã¤ã¶ããã®ç¨®å¥ãå¤å®ããã·ã¹ãã ãã§ãã
ãã±ããã¨ãã¦ã¯ã
- æ®éã®ã¤ã¶ãããå¤å®
- ããã·ã¥ã¿ã°ãå«ãã¤ã¶ãããå¤å®
- ãªãã©ã¤ãå«ãã¤ã¶ãããå¤å®
- ã¡ã³ã·ã§ã³ãå«ãã¤ã¶ãããå¤å®
- è¤æ°ã®ç¨®å¥ãå«ãã¤ã¶ãããå¤å®
- ãããã¯ã¼ã¯ããã¤ã¶ãããåå¾ãã¦å¤å®
- éå ¬å¼ RT ãå«ãå¤å®
- ç¾å¨æå»ã®åå¾ 30 åã®ã¤ã¶ãããæ大 20 件å¤å®
- URL ãå«ãã¤ã¶ãããå¤å®
- ç縮 URL ã®å±é
ã® 10 åã§ããã®ä¸ã® 1 ã 6 ã¾ã§ãå®è£
ãã¦ããã¾ãã
ã¿ã°ã«å«ã¾ããæ°åã¨ããã®ãªã¹ãã®æ°åã対å¿ãã¦ãã¾ãã
ã¾ãã¯æçµå½¢ãçºãã
ã¨ããããã©ããªãã¡ã¤ã«ããããè¦ã¦ã¿ã¾ãããã
- MotsunabeZombieProject/
- CategorizedResult.cs
- TweetAnalyzer.cs
- TweetCategorizer.cs
- MotsunabeZombieProject.Tests/
- CategorizedResultTest.cs
- TweetAnalyzerTest.cs
- TweetCategorizerTest.cs
éè¦ãªãã¡ã¤ã«ã¯ãã® 6 ã¤ã§ãã
ãã¹ããé¤ãã¨ãã¯ã©ã¹ã¨ãã¦ã¯ 3 ãã¡ã¤ã«ã« 4 ã¤ã®ã¯ã©ã¹ãå®ç¾©ããã¦ãã¾ãã
- TweetCategorizer
- ã¤ã¶ããã®ç¨®é¡ãå¤å®ããããã®ã¯ã©ã¹
- CategorizedResult
- å¤å®çµæãªã©ãä¿æããã¯ã©ã¹
- TweetAnalyzer
- ä¸ãããã URL ã®ã¤ã¶ãããå¤å®ããããã®ã¯ã©ã¹
- TweetProvider
- ã¤ã¶ããã TweetAnalyzer ã«ä¸ããããã®ã¯ã©ã¹
ç¹å¾´çãªã®ã¯ãCategorizedResult ãå°å
¥ããã¨ããã§ããããã
ãã®ã¯ã©ã¹ãå°å
¥ãããããã«ãã´ãªã«å¯¾ãããã¹ã (TweetCategorizerTest.cs) ãç°¡æ½ãã¤åããããããªãã¾ããã
ããã¯ãæååã¸ã®å¤æã CategorizedResult èªä½ã«æããããã¨ã«ãã£ã¦ãTweetCategorizerTest ã®æ¹ã§ã¯æååã®ä¸ç¹æ¯è¼ãè¡ãå¿
è¦ããªããªã£ãããã§ãã
TweetProvider ã¨ããã¯ã©ã¹å㯠Java ã®ãã¢ã使ã£ã¦ãããã®ããã®ã¾ã¾ä½¿ããã¦ãããã¾ããã
ããã¤ã¯ãã¹ãç¨ã®ã¯ã©ã¹ã§ãå¤é¨ããæååé
åã渡ãããã®ã TweetAnalyzer ã«è¨å®ããã¨ãã®æååé
åã使ã£ã¦ããã¾ãã
ä½ãè¨å®ããªããã°ãTweetAnalyzer ã¯ããã©ã«ãã® TweetProvider ã使ããããHTTP éä¿¡ãè¡ã£ã¦ã¤ã¶ãããåå¾ãã¾ãã
ãã®å°ããªã¯ã©ã¹ã«éä¿¡ãä»»ãã¦ãããããä»ã®é¨åã§ã¯ãããã¯ã¼ã¯ãå
¨ãæèããå¿
è¦ãããã¾ãããããã¹ããå®å
¨ã«ãªãã©ã¤ã³ã§å®è¡ã§ããããã«ãªã£ã¦ãã¾ãã
ãã¹ããé¤ãåãã¡ã¤ã«ã®è¡æ°ãè¦ã¦ã¿ãã¨ãã©ãã 50 è¡ã«åã¾ã£ã¦ãã¾ãã
ã¡ã½ããå
ã®è¡æ°ãæ°ãã¦ã¿ã¦ããä»ã®ã¨ããæé·ã§ 6 è¡ã¨ãé常ã«ã³ã³ãã¯ãã«åã¾ã£ã¦ãã¾ãã
ãã¹ãã³ã¼ãã¨ãããã¯ã·ã§ã³ã³ã¼ãã®è¡æ°ãè¦ã¦ã¿ãã¨ããã¹ãã³ã¼ããç´ 140 è¡ããããã¯ã·ã§ã³ã³ã¼ããç´ 130 è¡ã¨ãã ãããåã
ã«ãªãã¾ããã
ãã¹ãã®ç·æ°ã¯ 23 åã§ãã«ãã¬ãã¸ã¯ 87.04 % ã§ãã
ã«ãã¼ããã¦ããªãã¨ãããè¦ãã¨ã
- å®éã«ãããã¯ã¼ã¯ã«æ¥ç¶ãã«è¡ãé¨å (TweetProvider.GetTweetsFromUrl ã¡ã½ãã) å ¨ã¦
- ãã®å¼ã³åºãé¨å (TweetProvider.GetTweets ã¡ã½ãã) ã®ä¸é¨
- Debug.Assert ã§åææ¡ä»¶ãåãè¾¼ãã§ããé¨å
- æ£è¦è¡¨ç¾ã®ä¸é¨
ã¨ãªã£ã¦ãã¾ãããæå¾ãè¥å¹²æ°ã«ãªãã¾ãããä»ã¯åé¡ãªãããã§ãã
å®è£ æéã¯åè¨ 4 æéãããã§ãæ®ã£ã¦ããã³ãããéã®æéã調ã¹ã¦ã¿ãã¨ã
æé· | æç | å¹³å |
---|---|---|
ç´20å | 0.4å | ç´4.8å |
ã¨ãªãã¾ããã
ã³ãããç·æ°ã¯ 67 ã§ãããæ®ãã¦ããªã git-now ã®ã³ãããããããããå®éã«ã¯ããã¡ãã£ã¨å¢ãã¾ãã
æ®éã®ã¤ã¶ããã®å¤å®
gitk ã¯ç«ã¡ä¸ãã£ã¦ããã§ããããï¼ç«ã¡ä¸ãã£ã¦ããªãå ´åã
gitk --all &
ã¨ãã¦ç«ã¡ä¸ãã¦ããã¦ãã ããã
ãã¦ãã§ã¯ãã±ãã 1 ã®å®è£
ããè¦ã¦ããã¾ãããã
æã®ç¶æ
ãåã£ã¦ããã®ã«ã¯ãcheckout ã使ãã¾ãã
ã§ããããã§ã¯ãã©ã³ãã«é¦´æãã§ãããããã«ã³ã¼ãã追ãããã®ãã©ã³ããä½ã£ã¦ããã©ã³ãã移åããããã¨ã§ã³ã¼ãã追ãã¾ãããã
git checkout -b hoge da1939
ããã§ã³ã¼ãã追ãããã®ãã©ã³ã hoge ãä½æãããã®ãã©ã³ãã«åãæ¿ããã¾ããã
da1939 ã¨ããã®ã¯ããã©ã³ããä½æããã³ãããã®ããã·ã¥å¤ã®å
é 6 æåã§ãã
Git ã§ã¯ Subversion ã¨éãããªãã¸ã§ã³çªå·ã§ã¯ãªãããã·ã¥å¤ã«ãã£ã¦ã³ããããèå¥ãã¾ã*1ã
gitk ã«ç§»ããF5 ãã¼ãæ¼ãã¦ãã ããã
å·¦ä¸ã®é å (ã³ãããã°ã©ã) ãä¸çªä¸ã¾ã§ã¹ã¯ãã¼ã«ããã¨ãå
ã»ã©ä½ã£ã hoge ãã©ã³ãã確èªã§ãã¾ãã
hoge ã太åã«ãªã£ã¦ãããã¨ããããããããã«ãç¾å¨ã®ä½æ¥ãã£ã¬ã¯ããªã®ä¸ã¯ãã£ãã¾ã§ã®ææ°ã®ãã®ã§ã¯ãªããda1939 ã®ãã®ã«ãªã£ã¦ãã¾ãã
ããããã³ã¼ãã§ãã
TweetCategorizerTest ãè¦ãã¨ããã¹ãã±ã¼ã¹ãä¸ã¤ã ãæ¸ããã¦ãã¾ãã
var categorizer = new TweetCategorizer(); var result = categorizer.Categorize("bleis\tã»ãã»ã"); Assert.That(result, Is.EqualTo("Normal\tã»ãã»ã"));
ãã¹ãã³ã¼ããæ¸ãã¨ãã®çãªãã§ãããã¾ã Assert.That(result, Is.EqualTo("Normal\tã»ãã»ã")); ã¾ã§ãä¸æ°ã«æ¸ãä¸ãã¦ãã¾ãã¾ãã
ããã¦ãvar result = ... ã¨ä¸ã«ä¸ã«çµã¿ç«ã¦ã¦ããã¾ã*2ã
ãããããã¨ã«ãã£ã¦ããçµæã¨ãã¦ã»ãããã®ãã¨ãã©ããã£ã¦ãããæã«å
¥ããã¹ããããåæã«èããå¿
è¦ããªããªãã¾ãã
ã¾ãã¯çµæã¨ãã¦æ¬²ãããã®ãæ¸ãä¸ãã¦ããã¦ãããããã©ããã£ã¦ãããæã«å
¥ãããã® API ãèãã¦ãããã¨ãããã¨ã§ãã
ãã®ããã
var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize("bleis\tã»ãã»ã"), Is.EqualTo("Normal\tã»ãã»ã"));
ã¨ã¯åä½ã¨ãã¦ã¯åããªã®ã§ãããèãæ¹ã¨ãã¦ã¯å
¨ãå¥ (ãã¡ã㯠API ãã¾ãèãã¦ããã®çµæãå¾ã§èãã¦ãã) ã¨è¨ãã¾ãã
ãã¡ããããã¹ãã³ã¼ãã®ãªãã¡ã¯ã¿ãªã³ã°ãè¡ã£ã¦å¾è
ã®å½¢ã«ãããã¨ãããã¾ã*3ã
次ã«å®è£
ã³ã¼ããè¦ã¦ã¿ã¾ãããã
TweetCategorizer ã§ãããã¾ã æ®éã®ã¤ã¶ããã«ãã対å¿ããªããããæ¬æã®å
é ã« "Normal\t" ã追å ããã ãã«ãªã£ã¦ãã¾ãã
ç¹ã«èª¬æããé¨åãããã¾ããã®ã§ã次ã«è¡ãã¾ãããã
ããã·ã¥ã¿ã°ãå«ãã¤ã¶ããã®å¤å®
以ä¸ã®ã³ãã³ããå®è¡ãã¦ãã ããã
git reset --hard d6950
ãã®ã³ãããã¯ããã£ãè¦ãã³ãããã®æ¬¡ã®ã§ãã
ãã¹ãã±ã¼ã¹ã追å ãããããæºããå®è£
ãè¡ã£ã¦ãã¾ãã
ç¹ã«åé¡ã¯ãªãã§ããããé²ã¿ã¾ãã
git reset --hard e36fb
ã³ããããä¸ã¤é£ã°ãã¾ããã
ãã®ã³ãããã®åã«ãããã·ã¥ã¿ã°ã®å¤å®ã®ã±ã¼ã¹ãå¢ãããã¨ãã¦ãã¹ãã¡ã½ãããæ¸ãå§ããã®ã§ããã»ã»ã»
[Test] public void ããã·ã¥ã¿ã°ä»ãã®TweetãHashTagã«å¤å®ããã() { var categorizer = new TweetCategorizer(); var result = categorizer.Categorize("bleis\tã»ãã»ã #hash"); Assert.That(result, Is.EqualTo("HashTag\tã»ãã»ã #hash")); } [Test] public void æ°åã®ã¿ã®å ´åã¯Normalã¨å¤å®ããã() { var categorizer = new TweetCategorizer(); var result = categorizer.Categorize("bleis\tã»ãã»ã #1234"); Assert.That(result, Is.EqualTo("Normal\tã»ãã»ã #1234")); }
ã¨ãã»ã¨ãã©åãå
容ã«ãªãããã ã£ãã®ã§ããã®ããã«æ¸ããã« TestCase å±æ§ã使ãããã«ãã¹ãããªãã¡ã¯ã¿ãªã³ã°ãããã¨æããªããã¾ããã
ãã®ã³ãããã¯ãã®ç¬¬ä¸æ©ã§ãã¾ãæ¢åã®ãã¹ãã¨åããã®ã TestCase å±æ§ã使ã£ã¦æ¸ãç´ãã¦ãã¾ã*4ã
git reset --hard 4a15
ãã£ãã®ã³ãããã®æ¬¡ã®ã³ãããã§ãããTestCase å±æ§ã®ãã¹ããéã£ãã®ã§ãæ¢åã®ãã¹ããåé¤ãã¾ããã
ãã以éãgit now ã使ã£ã¦ TDD ã®ãµã¤ã¯ã«ãåãã¦è¡ã£ã¦ãã¾ã (work/2 ã®ã¿ã°ãåç
§)ã
ãã®éã®å git now ã®ééã¯ãæé·ç´ 5 åã¨ãªã£ã¦ãã¾ãã
èªåã®å ´å㯠git now ã®ééããã TDD ã®ãµã¤ã¯ã«ã®æ¹ãçã *5 ã®ã§ãTDD ã®ãµã¤ã¯ã«ã¯ 4 åã¨ã 3 åã¨ãã§åãã¦ããæãã«ãªãã¾ãã
git reset --hard 772a
ãã±ãã 2 ãã¨ããããçµãã£ãç¶æ
ã§ãã
ãã¹ãã±ã¼ã¹ãããã¤ã追å ããã¦ãããå®è£
ããªãã¡ã¯ã¿ãªã³ã°ã«ãã£ã¦ãããããããªã£ã¦ãã¾ãã
ç¹ã«ãã¹ãã±ã¼ã¹ã¯ TestCase å±æ§ãå°å
¥ãããã¨ã«ãã£ã¦ãç¡é§ã«è¡æ°ãå¢ãããã«ãã¹ãã±ã¼ã¹ã追å ã§ãã¦ãã¾ããç´ æµã
ãªãã©ã¤ãå«ãã¤ã¶ããã®å¤å®
git reset --hard 7d57
ãã®æç¹ã®ãã¹ããæç²ãã¾ãã
[TestCase("bleis\tã»ãã»ã #hash", "HashTag\tã»ãã»ã #hash")] [TestCase("bleis\tã»ãã»ã #1234", "Normal\tã»ãã»ã #1234")] [TestCase("bleis\tã»ãã»ãa#hash", "Normal\tã»ãã»ãa#hash")] [TestCase("bleis\tã»ãã»ãã#hash", "HashTag\tã»ãã»ãã#hash")] [TestCase("bleis\t#hash", "HashTag\t#hash")] [TestCase("bleis\tã»ãã»ã#hash", "HashTag\tã»ãã»ã#hash")] public void ããã·ã¥ã¿ã°ä»ãã®TweetãHashTagã«å¤å®ããã(string record, string expected) { var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize(record), Is.EqualTo(expected)); } [TestCase("bleis\t@t_wada ã»ãã»ã", "Reply\t@t_wada ã»ãã»ã")] [TestCase("bleis\t@ ã»ãã»ã", "Normal\t@ ã»ãã»ã")] [TestCase("bleis\t.@t_wada ã»ãã»ã", "Normal\t.@t_wada ã»ãã»ã")] public void ãªãã©ã¤ä»ãã®TweetãReplyã«å¤å®ããã(string record, string expected) { var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize(record), Is.EqualTo(expected)); }
ã¾ãéè¤ãç®ã«ã¤ãããã«ãªã£ã¦ãã¾ããã®ã§ããã¹ãã³ã¼ãããªãã¡ã¯ã¿ãªã³ã°ãããã¨ã«ãã¾ããã
git reset --hard b029
ScreenName ã¯ç¹ã«ä½¿ã£ã¦ãã¾ãããã常ã«åºå®ã§ãåé¡ããã¾ããã®ã§ããã«ãã¡ã½ããã使ãããã«ãã¾ããã
string _(string body) { return "bleis\t" + body; }
ããã«ãªãã¡ã¯ã¿ãªã³ã°ãç¶ãã¾ãã
git reset --hard d6555
ãã£ãã®ãªãã¡ã¯ã¿ãªã³ã°ã§ããã¹ãã¡ã½ããã®å¼æ°ã¯ body ã®ã¿ãåãåãããã«ãªãã¾ããã
ã¨ãããã¨ã¯ãæå¾
ããçµæã¯ã«ãã´ãªã¨ body ãã¿ãæåã§é£çµããã°ãããã¨ã«ãªãã¾ãã
string _(string category, string body) { return category + "\t" + body; }
ãã£ãã®ãªãã¡ã¯ã¿ãªã³ã°ã§è¿½å ããã®ã¨åããã2 ã¤ã®ã¡ã½ãããå°å ¥ãããã¨ã§ãã¹ãã³ã¼ãã¯ãããªãã¾ããã
[TestCase("ã»ãã»ã #hash", "HashTag")] [TestCase("ã»ãã»ã #1234", "Normal")] [TestCase("ã»ãã»ãa#hash", "Normal")] [TestCase("ã»ãã»ãã#hash", "HashTag")] [TestCase("#hash", "HashTag")] [TestCase("ã»ãã»ã#hash", "HashTag")] public void ããã·ã¥ã¿ã°ä»ãã®TweetãHashTagã«å¤å®ããã(string body, string expectedCategory) { var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize(_(body)), Is.EqualTo(_(expectedCategory, body))); } [TestCase("@t_wada ã»ãã»ã", "Reply")] [TestCase("@ ã»ãã»ã", "Normal")] [TestCase(".@t_wada ã»ãã»ã", "Normal")] public void ãªãã©ã¤ä»ãã®TweetãReplyã«å¤å®ããã(string body, string expectedCategory) { var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize(_(body)), Is.EqualTo(_(expectedCategory, body))); }
éè¤ãæ¶ãå»ã£ãä¸ãã©ããã£ããã¹ãã±ã¼ã¹ãªã®ããé常ã«ãããããããªãã¾ããã
å®è£
ã³ã¼ãã®ãªãã¡ã¯ã¿ãªã³ã°ã軽ãè¡ã£ã¦ããã±ãã 3 çµäºã§ãã
ã¡ã³ã·ã§ã³ãå«ãã¤ã¶ããã®å¤å®
git reset --hard 95774
å®è£ ãã¨ããããçµãã段éã§ãããä»åº¦ã¯ãã¹ãã¡ã½ããã®ä¸ã®éè¤ãæ°ã«ãªã£ã¦ãã¾ããã
var categorizer = new TweetCategorizer();
Assert.That(categorizer.Categorize(_(body)), Is.EqualTo(_(expectedCategory, body)));
ãã®ã³ã¼ãã 3 åæã§ä½¿ããã¦ãã¾ããããããªãã¡ã¯ã¿ãªã³ã°ãã¦ãã¾ãã¾ãããã
git reset --hard 9b065
ããã§ãã£ãã¾ã§ä½¿ã£ã¦ãããã«ãã¡ã½ãã 2 ã¤ãåé¤ããæ°ãã« AssertCategory ã¡ã½ããã追å ãã¾ããã
void AssertCategory(string body, string expectedCategory) { var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize("bleis\t" + body), Is.EqualTo(expectedCategory + "\t" + body)); }
ããã«ãã£ã¦ããã¹ãã¡ã½ããã®ä¸ã¯ãããªãã¾ããã
AssertCategory(body, expectedCategory);
ããæãã§ãã
æ´ã« 3 ã¤ã®ã¡ã½ãã
- ããã·ã¥ã¿ã°ä»ãã®TweetãHashTagã«å¤å®ããã
- ãªãã©ã¤ä»ãã®TweetãReplyã«å¤å®ããã
- ã¡ã³ã·ã§ã³ä»ãã®TweetãMentionã«å¤å®ããã
ãä¸ã¤ã®ã¡ã½ããã«ã¾ã¨ãããã¨ãã§ããã®ã§ããããããã¯ãã¹ãã±ã¼ã¹ã¨ãã¦ã¯å¥ç©ã ã¨æã£ã¦ããã®ã§ãã¾ã¨ãã¦ãã¾ãã*6ã
è¤æ°ã®ç¨®å¥ãå«ãã¤ã¶ããã®å¤å®
git reset --hard 6ff2
ã¨ããããæ¸ãã¦ã¿ããã®ã®ããã¹ãã¡ã½ãããå¾®å¦ã§ãã
[TestCase("@t_wada ã»ãã»ã#hash", new[] { "Reply,HashTag", "HashTag,Reply" })] public void è¤æ°ã®ç¨®é¡ãå«ãTweetãã«ã³ãåºåãã§é£çµããã(string body, string[] expectedCategories) { var categorizer = new TweetCategorizer(); var result = categorizer.Categorize("bleis\t" + body); // é çªã¯ã©ãã§ããã foreach (var exCat in expectedCategories) { if (result.StartsWith(exCat + "\t")) { Assert.Pass(); return; } } Assert.Fail(string.Format("expected starts with [{0}] but [{1}].", string.Join(" or ", expectedCategories), result)); }
ããã¨è¦ã¦ããããªãã®ãã¹ããªã®ãå
¨ããããã¾ããã
ããã¯ãã¡ã ã¨æããå¤å®çµæã表ãã¯ã©ã¹ãå°å
¥ãã¦ã¿ããã¨ã«ãã¾ããã
git reset --hard 27190
CategorizedResult ã¨ããã¯ã©ã¹ãå°å
¥ãã¾ããã
ã¤ã¶ããæ¬ä½ã¨å¤å®ãããã«ãã´ãªãæã¤ã ãã®åç´ãªã¯ã©ã¹ã§ãã
git reset --hard 706b
CategorizedResult ã« ToString ã追å ãã¾ããã
ããã«ãã£ã¦ãçµæã®æååãçãããã¨ã確èªãããã¹ãã¨ãå¤å®ãããã«ãã´ãªãæ£ãããã¨ã確èªãããã¹ããåé¢ãããã¨ãã§ãããã§ãã
git reset --hard f7cc
ããããã³ã¼ããç½®ãæãã¦ããã¾ããGit ãããã®ã§ãå®å¿ãã¦ç½®ãæãã試ãã¦ã¿ããã¨ãã§ãã¾ãã
ã¾ãã¯æ®éã®ã¤ã¶ããã®å¤å®ãè¡ããã¹ãããCategorizedResult ã使ã£ã¦æ¸ãç´ãã¦ã¿ã¾ããã
var categorizer = new TweetCategorizer(); var result = categorizer.Categorize("bleis\tã»ãã»ã"); Assert.That(result.Categories, Is.EqualTo(new[] { "Normal" }));
ãã¡ãããcategorizer.Categorize("bleis\tã»ãã»ã") ã®æ»ãå¤ã®å㯠string ãªã®ã§ãã¾ã ã³ã³ãã¤ã«ã¯éãã¾ããã
git reset --hard 43592
Green ãã¼ãè¦ããã®ã§ãCategorizedResult ãè¿ãããã« Categorize ã¡ã½ãããæ¸ãæãã¾ãã
ããã§ã³ã³ãã¤ã«ãéãã¨æã£ããã§ãããä»åº¦ã¯ Categorize ã¡ã½ããã®æ»ãå¤ã®åã string ã¨ãã¦æ±ã£ã¦ãããã¹ããæ®ã£ã¦ãããããã³ã³ãã¤ã«ãéãã¾ããã§ããã
git reset --hard 5b5f
é¢åãªã®ã§ #if false ã #endif ã§ç¡å¹åãã¡ããã¾ãããã³ã³ãã¤ã«ã¯éãã¾ããããã¹ãã Green ã§ãã
ãã¨ã¯ãã¹ããæ¸ãæãã¦ãã£ã¦ãç¡å¹åããç¯å²ãçãã¦ããã¾ãã
ãã¹ãã³ã¼ãã®ãªãã¡ã¯ã¿ãªã³ã°ãè¡ã£ã¦ãéè¤é¨åãããªãåã£ã¦ãããããç½®ãæãã¯é常ã«ç°¡åã«è¡ããã¨ãã§ãã¾ããã
CategorizedResult å°å ¥ã®ãã£ããã¨ãªã£ããã¹ãããCategorizedResult ãå°å ¥ãããã¨ã§ã©ããªã£ããè¦ã¦ã¿ã¾ãããã
git reset --hard 498a
[TestCase("@t_wada ã»ãã»ã#hash", new[] { "Reply", "HashTag" })] [TestCase("@t_wada ã»ãã»ã#hash", new[] { "HashTag", "Reply" }, Description="é ä¸å")] public void è¤æ°ã®ç¨®é¡ãå«ãTweetã®å¤å®çµæã«å«ã¾ãããã¹ã¦ã®ç¨®é¡ãåå¨ãã(string body, string[] expectedCategories) { var categorizer = new TweetCategorizer(); Assert.That(categorizer.Categorize("bleis\t" + body).Categories, Is.EquivalentTo(expectedCategories)); }
é常ã«ãã£ãããããã¹ãã«ãªãã¾ããã
NUnit ã® EquivalentTo ã¯é çªãèæ
®ããªãæ¯è¼ãè¡ã£ã¦ããã¾ãã
ç½®ãæãåã¯ã²ã¨ã¤ã®ãã¹ãã±ã¼ã¹ã«çµæã®çµã¿åããã人åã§è¨è¿°ãã¦ãã¾ããããCategorizedResult ãå°å
¥ãããã¨ã«ãããã®å¿
è¦ããªããªãã¾ããã
ãã®ããããã¹ãã®è¿½å ãé常ã«ç°¡åã«ã§ããããã«ããªã£ã¦ãã¾ãã
ããã¤ããã¹ãã追å ãã¦ããã±ãã 5 ã¯çµäºã§ãã
ãããã¯ã¼ã¯ããã¤ã¶ãããåå¾ãã¦å¤å®
TDD Boot Camp ç¦å²¡ã§ã¯ãããã§å
¥åå½¢å¼ã®å¤æ´ã¨ããä»æ§å¤æ´ãå
¥ãã¾ããã
ä»ã¾ã§ã¯ ScreenName 㨠Body ãã¿ãæåã§åºåãããå½¢å¼ã ã£ãã®ã§ããããããã㯠yyyy/MM/dd HH:mm:ss å½¢å¼ã®æ¥ä»ãå
é ã«ãã£ã¤ããScreenName ã¨ã®éã«ã¿ãæåãç½®ããã¾ãã
ã¤ã¾ããæ¥æ㨠ScreenName 㨠Body ãã¿ãæåã§åºåãããå½¢å¼ã§ãã
ãã®å¤æ´ã«å¯¾å¿ããããã«ãã¨ãããããã¹ããã²ã¨ã¤ä¿®æ£ãã¦ã¿ã¾ãã
git reset --hard 4b14
ãã¹ããå®è¡ãã¦ã¿ãã¨ãGreen ã§ãã
ã»ã»ã»ããï¼ä»æ§å¤æ´ã®å½±é¿ãåãã¦ããªãï¼ã¨æãã¤ã¤ãã»ãã®ãã¹ããæ°å½¢å¼ã«ä¿®æ£ãã¦ã¿ã¾ããã
git reset --hard 4efe
è½ã¡ã¾ããããªãã©ã¤å¤å®ç¨ã®æ£è¦è¡¨ç¾ã§ãå
é ã«ãããã¨ããæ¡ä»¶ãå«ã¾ãã¦ãã¾ããã
æ°å½¢å¼ããã®ã¾ã¾æ¢åã® Categorize ã¡ã½ããã«æ¸¡ãã¨ãæ¥ä»ã®é¨åã ScreenName ã¨ãã¦ãScreenName 以éã Body ã¨ãã¦èªèããã¦ãã¾ããããReply ãæå¾
ãã¦ãããã¹ãããã¨ãã¨ãè½ã¡ã¾ããã
git reset --hard ee2e
Body é¨åã®åå¾æ¹æ³ãä¿®æ£ããæ°å½¢å¼ã¸ã®å¯¾å¿å®äºã§ãã
ããããGetCategory ã¡ã½ããå
é¨ã§ã³ã¬ã¯ã·ã§ã³ãã«ã³ãã§ãã£ã¤ãã¦æåååãããããå¼ã³åºãå´ã§ Split ããã¨ããé¨åãç®ã«ã¤ããã®ã§ããªãã¡ã¯ã¿ãªã³ã°ãè¡ããã¨ã«ãã¾ããã
ãã®éããã±ããã¨ãã¦åããã®ãé¢åãªã®ã§åããã±ããå
ã§ãã£ã¦ãã¾ããã¨ãå¤ãã§ãã
git reset --hard 04e1
ããã« LINQ ã使ã£ã¦å é¨ãæ¸ãç´ããã¨ããã§ããã±ãã 6 æ¬æ¥ã®ä½æ¥ã«å ¥ãã¾ãã
git reset --hard d4d8
ãã®ã³ããã㧠TweetAnalyzer ãå°å
¥ãã¦ãã¾ãããååã®ä»ãæ¹ã«è¿·ãã20 åããã使ã£ã¦ãã¾ãã
çµå±ãæçµçã«ã¯ã¤ã¶ããã®åæãè¡ããã¨ã«ãªããããªã¹ãã¼ãªã¼ã ã£ãã®ã§*7ãTweetAnalyzer ã¨ãã¾ããã
æ´ã«ãTweetAnalyzer ã§ã¯ Categorize ããã®ãç®çã§ã¯ãªãã¨ããå¤æãããCategorize ã¡ã½ãã㯠public ã§ã¯ãªã internal ã«ãã¾ããã
git reset --hard c0554
ããã¾ã§ã®ã³ãããã¯ãAPI ã決ããããã«å³å¾å·¦å¾ãã¦ãæçµçã«æ®ã£ãã³ãããã§ãã
TweetProvider ã¯ã©ã¹ãå°å
¥ãã¦ããã¼ã¿ã®åå¾å
ããã®ã¯ã©ã¹ã«é ãºããããã¨ã«ãã¾ããã
ãããããããã§ããªãããã§ããªãã¨è©¦è¡é¯èª¤ããªãããæçµçãªå®è£
ã«è½ã¡çãã¾ããã
git reset --hard work/6
ããã§ã¿ã¤ã ã¢ãããæ°å¹¹ç·ãåå¤å±ã«çããããã§ãã
家㧠git now --rebase ãã¦ãã´ãã®é¤å»ã¨ãã¹ãã軽ããªãã¡ã¯ã¿ãªã³ã°ãããã®ã GitHub ã«å
¬éãã¾ããã
ã¾ã¨ã
- æåã®ãã¹ã㯠Assert First (Assert ããæ¸ã)
- çµæã決ãã¦ãã API ãè¨è¨ãã (ã´ã¼ã«ãè¦ããç¶æ ã«ãã¦ããã®ã¯éè¦)
- ä¸ã¸ä¸ã¸æ¸ãã¦ããã®ã§ãVsVim ã便å©
- Assert.That å¯æãã Assert.That
- ãã¹ãã±ã¼ã¹ã®ãªãã¡ã¯ã¿ãªã³ã°
- ãã«ãã¡ã½ããã®å°å ¥
- TestCase å±æ§
- TestCaseSource å±æ§
- ãã¹ãã±ã¼ã¹ãç°¡æ½ã«æ¸ãããã«ã¯ã©ã¹ãå°å ¥
- git
- git now 㯠TDD ã¨ã®ç¸æ§ããã
- git now --rebase ããåã«ã¿ã°ãæã¤ãã¨ã§ãèªåã®å¾åãç¥ããã¨ãã§ãã
- git ã®ãã©ã³ãã¯ã¨ã¦ã軽ãã®ã§æ°è»½ã«ä½¿ãã*8
*1:ãªãã§ããã·ã¥å¤ãªãã¦ããããããªããã®ã使ã£ã¦ãã®ï¼ã¨ããçåãæã£ãæ¹ã¯ãå ¥é Git (大æåã®æ¹) ãå®ç¨ Git ãã©ããã[http://d.hatena.ne.jp/bleis-tift/20100922/1285140344#_commitid:title=ãªãã¸ã§ã³çªå·ããªã話]ããããã©ãã
*2:VsVim ã使ã£ã¦ããå ´åã
*3:ãªã®ã§ããã¹ã対象ã®ã¡ã½ããå¼ã³åºãã®å¾ããã¡ã½ãããã§ã¤ã³ã§ã¤ãªãã¦ããã®ã¯ TDD ã¨ã¯ç¸æ§ãæªãã§ãããã¡ãããæ¢åã®ã³ã¼ãã«å¯¾ãã¦ãã¹ãã追å ããå ´åã¯ãããããã¹ãã£ã³ã°ãã¬ã¼ã ã¯ã¼ã¯ã¯å¼·åã§ãããããNUnit ã® Assert 㯠TDD ã¨ç¸æ§ãããã®ã§ããä¸é¨ C#er ãã㯠Assert.That ãªããã¼ãã¨ãè¨ããã¡ãã£ã¦ã¾ããã©ã俺ã¯ã¢ãªæ´¾ã§ããAssert.That ä¸æ³ï¼
*4:ãã®é result å¤æ°ãé¤å»ãã¦ãã¾ãããããç¨åº¦ API ãåºã¾ã£ãã¨æããããã« assert first ãä¸æ¦ããã¾ãããAPI ãåºã¾ã£ã¦ããã®ã« assert first ããã®ã«ãã¾ãã¡ãªãããæããªãããã§ãããã®è¾ºãã¯äººã«ãã£ã¦èãæ¹ãéãããã
*5:VS ä¸ã§ git ã®æä½ãã§ããªãã¨ããã®ã git now ã®éé㨠TDD ã®ãµã¤ã¯ã«ãä¸è´ããªã主ãªåå ã ã¨æãã¾ãããã¹ããå®è¡ããæé㯠TestDriven.NET ã«ãã£ã¦ã»ã¨ãã©ãªãã§ãããgit ã®ã³ãã³ããå®è¡ããããã«ã¯ã¦ã£ã³ãã¦ãåãæ¿ããå¿ è¦ããã
*6:ãã ãã¡ã³ã·ã§ã³ã®ãã¹ãã¨ãªãã©ã¤ã®ãã¹ãã«å®å ¨ã«åããã®ãããã®ã§ãããã¯æ¶ããæ¹ãããã®ããã
*7:å¾ã§ä½ããã®å½¢ã§ãé¡ãå ¬éãããã¨æãã¾ãã®ã§ãåå è 以å¤ã®æ¹ã¯ããã¾ã§ããããããªãããããã¾ãããããããªæãã ã£ãã®ã§ãã
*8:ä»åãã©ã³ãã使ã£ã¦éå»ã®ã³ã¼ããåãåºãã¦ãã¾ããããã©ãã§ãããï¼å ¨ç¶é ããªãã£ãã®ã§ã¯ãªãã§ããããï¼