{"id":5254,"date":"2013-12-01T01:38:15","date_gmt":"2013-11-30T16:38:15","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=5254"},"modified":"2013-12-01T17:58:07","modified_gmt":"2013-12-01T08:58:07","slug":"%e3%83%8e%e3%83%bc%e3%83%9e%e3%83%ab%e3%81%abmstest%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/5254","title":{"rendered":"\u30ce\u30fc\u30de\u30eb\u306bMSTest\u3092\u4f7f\u304a\u3046"},"content":{"rendered":"<p>TDD Advent Calendar 2013\u306e\u53c2\u52a0\u72b6\u6cc1\u78ba\u8a8d\u30fb\u53c2\u52a0\u767b\u9332 &#8211; Qiita [\u30ad\u30fc\u30bf]<br \/>\n<a href=\"http:\/\/qiita.com\/advent-calendar\/2013\/tddadventjp\/participants\">http:\/\/qiita.com\/advent-calendar\/2013\/tddadventjp\/participants<\/a><\/p>\n<p>\u306e\u4e00\u767a\u76ee\u3067\u3059\u3002\u30c8\u30c3\u30d7\u30d0\u30c3\u30bf\u30fc\u306a\u306e\u3067\u3001\u30ce\u30fc\u30de\u30eb\u306b MSTest \u3092\u4f7f\u3046\u8a71\u30921\u6642\u9593\u307b\u3069\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002TDD\u3067\u4f55\u304c\u3067\u304d\u308b\u306e\uff1f\u3068\u304b\u3001PHPUnit\u3068\u304b\u3001NUnit\u3068\u304b\u3001gtest\u3068\u304b\u3001CppUnit\u3068\u304b\u3001\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d\u306e\u304a\u8a71\u306f\u5148\u884c\u304d\u51fa\u3066\u304f\u308b\u306f\u305a\uff08\uff1f\uff09\u306a\u306e\u3067\u3001\u305d\u3061\u3089\u306b\u8b72\u308b\u3068\u3057\u3066\u3001Visual Studio 2013 \u306e <a href=\"http:\/\/www.microsoft.com\/ja-jp\/download\/details.aspx?id=40787\">Express 2013 for Widnwos Desktop<\/a> \u3092\u4f7f\u3063\u3066\u3001MSTest \u3092\u4f7f\u3063\u3066\u898b\u3088\u3046\u3001\u3068\u3044\u3046\u611f\u3058\u3067\u9032\u3081\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u25a0\u3044\u304d\u306a\u308aUI\u3092\u4f5c\u308b<\/h2>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"344\" height=\"260\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3001\u3044\u304d\u306a\u308aUI\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002\u6700\u521d\u306eTextBox1\u3068TextBox2\u306e\u5185\u5bb9\u3092\u8db3\u3057\u305f\u3089\u3001TextBox3\u306b\u5165\u308b\u3001\u3068\u3044\u3046\u7c21\u5358\u306a\u8a08\u7b97\u6a5f\u3067\u3059\u306d\u3002\u3064\u30fc\u304b\u3001\u7c21\u5358\u3059\u304e\u3066\u3042\u308c\u306a\u306e\u3067\u3059\u304c\u3001\u307e\u3042\u3001\u3053\u308c\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u25a0\u3044\u304d\u306a\u308a\u8a08\u7b97\u3092\u3059\u308b\u3002<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ \u8a08\u7b97\u3059\u308b\r\nprivate void button1_Click(object sender, EventArgs e)\r\n{\r\n\tint x = int.Parse(textBox1.Text);\r\n\tint y = int.Parse(textBox2.Text);\r\n\tint z = x + y;\r\n\ttextBox3.Text = z.ToString();\r\n}\r\n<\/pre>\n<p>\u3044\u304d\u306a\u308a\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002\u3053\u308c\u3050\u3089\u3044\u306e\u30b3\u30fc\u30c9\u306a\u3089\u3070UI\u306b\u305d\u306e\u307e\u307e\u66f8\u3044\u3066\u3044\u3044\u3088\u306d\u3001\u3063\u3066\u5177\u5408\u306b\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u304c\u3001\u3053\u308c\u3058\u3083\u30c0\u30e1\u306a\u306e\u306f\u308f\u304b\u308a\u304d\u3063\u3066\u307e\u3059\u306d\u3002\u3060\u3063\u3066\u3001TextBox1.Text \u304c\u7a7a\u6b04\u306e\u3068\u304d\u306f\u3001int.Parse \u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3057\u3001\u306a\u3093\u304b\u3001\u3044\u308d\u3044\u308d TDD \u7684\u306b\u30c0\u30e1\u306a\u3068\u3053\u308d\u304c\u6e80\u8f09\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb1.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"650\" height=\"266\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u30c7\u30d0\u30c3\u30b0\u5b9f\u884c\u3057\u3066\u3001\u3061\u307e\u3061\u307e\u3068\u30a8\u30e9\u30fc\u7b87\u6240\u3092\u76f4\u3059\u306e\u3082\u30a2\u30ea\u306a\u306e\u3067\u3059\u304c\u3001\u3072\u3068\u624b\u9593\u304b\u3051\u3066\u3001\u3082\u3046\u5c11\u3057\u306a\u3093\u3068\u304b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u25a0\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u3068\u8a08\u7b97\u3059\u308b\u90e8\u5206\u3092\u5206\u3051\u308b<\/h2>\n<p>\u305b\u3081\u3066\u300cUI\u3068\u30ed\u30b8\u30c3\u30af\u300d\u3092\u5206\u3051\u3088\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u3053\u308d\u3068\u3001\u5b9f\u969b\u306b\u8a08\u7b97\u3059\u308b\u3068\u3053\u308d\u3092\u5206\u3051\u307e\u3059\u3002\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306e\u6587\u5b57\u5217\u3092\u305d\u306e\u307e\u307e\u6e21\u3057\u3066\u3001\u6587\u5b57\u5217\u3067\u3082\u3089\u3063\u3066\u304f\u308b\u3068\u95a2\u6570\u3068\u3057\u3066\u697d\u3067\u3059\u3088\u306d\u3001\u3068\u3044\u3046\u767a\u60f3\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ \u8a08\u7b97\u3059\u308b\u30dc\u30bf\u30f3\u3092\u62bc\u3059\r\nprivate void button1_Click(object sender, EventArgs e)\r\n{\r\n\ttextBox3.Text = calc(textBox1.Text, textBox2.Text);\r\n}\r\n\r\n\/\/\/ \u8a08\u7b97\u3059\u308b\r\nprivate string calc(string x, string y)\r\n{\r\n\tint xx = 0;\r\n\tint yy = 0;\r\n\tif (int.TryParse(x, out xx) == false) return &quot;&quot;;\r\n\tif (int.TryParse(y, out yy) == false) return &quot;&quot;;\r\n\r\n\tint zz = xx + yy;\r\n\treturn zz.ToString();\r\n}\r\n<\/pre>\n<p>\u307e\u3042\u3001\u3053\u308c\u3082\u60aa\u304f\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u2026\u3001\u3048\u3048\u3068\u3001MSTest \u3092\u4f7f\u3046\u3068\u304d\u306f\u3001private \u30e1\u30bd\u30c3\u30c9\u3067\u306f\u7121\u7406\u306a\u306e\u3067\u3001public \u306b\u3057\u306a\u3044\u3068\u30c0\u30e1\u3067\u3059\u306d\u3002<\/p>\n<h2>\u25a0\u30c6\u30b9\u30c8\u5bfe\u8c61\u3092 public \u306b\u3059\u308b<\/h2>\n<p>calc \u30e1\u30bd\u30c3\u30c9\u3092 public \u306b\u3057\u3066\u30c6\u30b9\u30c8\u304b\u3089\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ \u8a08\u7b97\u3059\u308b\r\npublic string calc(string x, string y)\r\n{\r\n\tint xx = 0;\r\n\tint yy = 0;\r\n\tif (int.TryParse(x, out xx) == false) return &quot;&quot;;\r\n\tif (int.TryParse(y, out yy) == false) return &quot;&quot;;\r\n\r\n\tint zz = xx + yy;\r\n\treturn zz.ToString();\r\n}\r\n<\/pre>\n<p>\u304a\u304a\u3001\u3053\u308c\u306a\u3089 calc \u30e1\u30bd\u30c3\u30c9\u304c\u30c6\u30b9\u30c8\u3067\u304d\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<h2>\u25a0\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nusing System;\r\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\r\nusing WindowsFormsApplication1;\r\n\r\nnamespace UnitTestProject1\r\n{\r\n&#x5B;TestClass]\r\n\tpublic class UnitTest1\r\n\t{\r\n\t\t&#x5B;TestMethod]\r\n\t\tpublic void TestMethod1()\r\n\t\t{\r\n\t\t\tvar frm = new Form1();\r\n\t\t\tstring ans = frm.calc(&quot;1&quot;,&quot;2&quot;);\r\n\t\t\tAssert.AreEqual(&quot;3&quot;, ans);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3001\u6587\u5b57\u5217\u306e\u300c1\u300d\u3068\u6587\u5b57\u5217\u306e\u300c2\u300d\u3092\u6e21\u3057\u305f\u3089\u6587\u5b57\u5217\u306e\u300c3\u300d\u3092\u623b\u3059\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3059\u3002\u53c2\u7167\u8a2d\u5b9a\u3067\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u3042\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\u306e\u3068\u3001System.Windows.Forms \u3082\u53c2\u7167\u8a2d\u5b9a\u3059\u308b\u306e\u3092\u5fd8\u308c\u305a\u306b\u3002\u3061\u3087\u3063\u3068\u3084\u3084\u3053\u3057\u3044\u3067\u3059\u306d\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb2.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"557\" height=\"395\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u7121\u4e8b\u3001\u30c6\u30b9\u30c8\u304c\u6210\u529f\u3059\u308b\u3068\u3053\u3093\u306a\u98a8\u306b\u7dd1\u306e\u30c1\u30a7\u30c3\u30af\u30de\u30fc\u30af\u304c\u51fa\u307e\u3059\u3002<\/p>\n<p>\u305d\u3046\u305d\u3046\u3001\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u304c\u7a7a\u6b04\u306e\u5834\u5408\u3082\u8ffd\u52a0\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb3.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"643\" height=\"442\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u3053\u3093\u306a\u98a8\u306b\u6b21\u3005\u3068\u30c6\u30b9\u30c8\u304c\u66f8\u3051\u307e\u3059\u3002\u3081\u3067\u305f\u3057\u3081\u3067\u305f\u3057\u2026\u3067\u7d42\u308f\u308b\u3068\u6012\u3089\u308c\u305d\u3046\u3067\u3059\u306d\u3002\u30d5\u30a9\u30fc\u30e0\u3092\u305d\u306e\u307e\u307enew\u3059\u308b\u306e\u306f\u3001\u307e\u3042\u305d\u3053\u305d\u3053\u696d\u52d9\u306e\u30c6\u30b9\u30c8\u3068\u3057\u3066\u306f\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u3057\u304b\u3057\u30d5\u30a9\u30fc\u30e0\u306b\u3044\u308d\u3044\u308d\u306a\u90e8\u54c1\u304c\u4e57\u3063\u304b\u3063\u305f\u308a\u3001\u30d5\u30a9\u30fc\u30e0\u3092\u521d\u671f\u5316\u3059\u308b\u3068\u304d\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u305f\u308a\u3059\u308b\u3068\u304d\u306f\u3001\u30c6\u30b9\u30c8\u304c\u91cd\u304f\u306a\u308a\u305d\u3046\u3067\u3059\u3002\u307e\u3042\u3001\u5b9f\u969b\u91cd\u304f\u306a\u308b\u3057\u3001\u521d\u671f\u5316\u3067\u5931\u6557\u3057\u305f\u308a\u3057\u3066\u30c6\u30b9\u30c8\u304c\u81ea\u52d5\u5316\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h2>\u25a0\u30d5\u30a9\u30fc\u30e0\u3068\u306f\u5225\u306e\u30af\u30e9\u30b9\u306b\u3059\u308b<\/h2>\n<p>\u30d5\u30a9\u30fc\u30e0\u3092new\u3057\u305f\u304f\u306a\u3044\u306e\u3067\u3001calc\u30e1\u30bd\u30c3\u30c9\u3092\u5225\u306e\u30af\u30e9\u30b9\u306b\u79fb\u3057\u307e\u3059\u3002\u5225\u306bLogic\u30af\u30e9\u30b9\u3068\u3044\u3046\u306e\u3092\u4f5c\u3063\u3066\u3001<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic class Logic\r\n{\r\n\t\/\/\/ \u8a08\u7b97\u3059\u308b\r\n\tpublic string calc(string x, string y)\r\n\t{\r\n\t\tint xx = 0;\r\n\t\tint yy = 0;\r\n\t\tif (int.TryParse(x, out xx) == false) return &quot;&quot;;\r\n\t\tif (int.TryParse(y, out yy) == false) return &quot;&quot;;\r\n\r\n\t\tint zz = xx + yy;\r\n\t\treturn zz.ToString();\r\n\t}\r\n}\r\n<\/pre>\n<p>\u30d5\u30a9\u30fc\u30e0\u306e\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u90e8\u5206\u3092\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ \u8a08\u7b97\u3059\u308b\u30dc\u30bf\u30f3\u3092\u62bc\u3059\r\nprivate void button1_Click(object sender, EventArgs e)\r\n{\r\n\tvar l = new Logic();\r\n\ttextBox3.Text = l.calc(textBox1.Text, textBox2.Text);\r\n}\r\n<\/pre>\n<p>\u305d\u3046\u3057\u3066\u3001\u30c6\u30b9\u30c8\u3082\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nnamespace UnitTestProject1\r\n{\r\n\t&#x5B;TestClass]\r\n\tpublic class UnitTest1\r\n\t{\r\n\t\t&#x5B;TestMethod]\r\n\t\tpublic void TestMethod1()\r\n\t\t{\r\n\t\t\tvar l = new Logic();\r\n\t\t\tstring ans = l.calc(&quot;1&quot;,&quot;2&quot;);\r\n\t\t\tAssert.AreEqual(&quot;3&quot;, ans);\r\n\t\t}\r\n\r\n\t\t&#x5B;TestMethod]\r\n\t\tpublic void Test\u7a7a\u6b04\u306e\u5834\u5408()\r\n\t\t{\r\n\t\t\tvar l = new Logic();\r\n\t\t\tstring ans = l.calc(&quot;&quot;, &quot;2&quot;);\r\n\t\t\tAssert.AreEqual(&quot;&quot;, ans);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>\u30d5\u30a9\u30fc\u30e0\u81ea\u4f53\u3092\u547c\u3073\u51fa\u3055\u306a\u304f\u306a\u3063\u305f\u306e\u3067\u3001System.Windows.Forms \u306e\u53c2\u7167\u8a2d\u5b9a\u306f\u3044\u3089\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30a2\u30bb\u30f3\u30d6\u30ea\uff08\u3053\u306e\u5834\u5408\u306f\u3001Form1\u3092\u542b\u3080\u30a2\u30bb\u30f3\u30d6\u30ea\uff09\u3092\u53c2\u7167\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb4.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"602\" height=\"487\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u307b\u3069\u3088\u304f\u3001\u3044\u3044\u611f\u3058\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u25a0\u30ed\u30b8\u30c3\u30af\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u3059\u308b<\/h2>\n<p>\u3055\u3066\u3001calc \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u8db3\u3057\u7b97\u3092\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u304c\u3001\u5f15\u6570\u304c\u6587\u5b57\u5217\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u6587\u5b57\u5217\u306e\u8db3\u3057\u7b97\u306f\u6587\u5b57\u5217\u306e\u9023\u7d50\u306b\u898b\u3048\u308b\u3057\u3001\u6570\u5024\u3060\u3051\u3092\u8db3\u3059\u3088\u3046\u306b\u3057\u305f\u307b\u3046\u304c\u30ed\u30b8\u30c3\u30af\u304c\u30b7\u30f3\u30d7\u30eb\u306b\u306a\u308a\u307e\u3059\u3088\u306d\u3002\u306a\u306e\u3067\u3001calc \u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u3092\u6570\u5024\u306b\u5909\u3048\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic int calc( int x, int y)\r\n{\r\n\tint z = x + y;\r\n\treturn z;\r\n}\r\n<\/pre>\n<p>UI \u306e\u307b\u3046\u306f\u3001\u6570\u5024\u3092\u6e21\u3059\u3088\u3046\u306b\u5909\u66f4\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nprivate void button1_Click(object sender, EventArgs e)\r\n{\r\n\tstring x = textBox1.Text;\r\n\tstring y = textBox2.Text;\r\n\tint xx, yy;\r\n\tif (int.TryParse(x, out xx) == false) return ;\r\n\tif (int.TryParse(y, out yy) == false) return ;\r\n\r\n\tvar l = new Logic();\r\n\tint ans = l.calc(xx, yy);\r\n\ttextBox3.Text = ans.ToString();\r\n}\r\n<\/pre>\n<p>\u6b21\u3044\u3067\u306b\u30c6\u30b9\u30c8\u306e\u307b\u3046\u3082\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic void TestMethod1()\r\n{\r\n\tvar l = new Logic();\r\n\tint ans = l.calc(1,2);\r\n\tAssert.AreEqual(3, ans);\r\n}\r\n<\/pre>\n<p>\u7a7a\u6b04\u306e\u5834\u5408\u306f\u3001UI\u306e\u3068\u3053\u308d\u3067\u30c1\u30a7\u30c3\u30af\u3092\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30c6\u30b9\u30c8\u3092\u53d6\u308a\u9664\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb5.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"568\" height=\"389\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>calc \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u5fc5\u305a\u6570\u5024\u304c\u6e21\u3055\u308c\u308b\u306e\u3067\u3001\u30ed\u30b8\u30c3\u30af\u304c\u30b7\u30f3\u30d7\u30eb\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u5206\u3001UI\u3067\u6570\u5024\u4ee5\u5916\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3044\u308b\u306e\u3067\u3001UI\u304c\u8907\u96d1\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3002\u3044\u3084\u3044\u3084\u3001\u3053\u308c\u306f\u3053\u308c\u3067\u4fbf\u5229\u306a\u306e\u3067\u3059\u3002<\/p>\n<h2>\u25a0UI\u3067\u7a7a\u6b04\u3068\u6570\u5024\u4ee5\u5916\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b<\/h2>\n<p>UI\u306e\u5165\u529b\u6642\u306b\u3001\u7a7a\u6b04\u306e\u3068\u304d\u3068\u3001\u6570\u5024\u4ee5\u5916\u306e\uff12\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nprivate void button1_Click(object sender, EventArgs e)\r\n{\r\n\tstring x = textBox1.Text;\r\n\tstring y = textBox2.Text;\r\n\tif (x == &quot;&quot;)\r\n\t{\r\n\t\tMessageBox.Show(&quot;x\u304c\u7a7a\u6b04\u3067\u3059&quot;);\r\n\t\treturn;\r\n\t}\r\n\tif (y == &quot;&quot;)\r\n\t{\r\n\t\tMessageBox.Show(&quot;y\u304c\u7a7a\u6b04\u3067\u3059&quot;);\r\n\t\treturn;\r\n\t}\r\n\r\n\tint xx, yy;\r\n\tif (int.TryParse(x, out xx) == false)\r\n\t{\r\n\t\tMessageBox.Show(&quot;x\u306b\u6570\u5024\u3092\u5165\u308c\u3066\u304f\u3060\u3055\u3044&quot;);\r\n\t\treturn;\r\n\t}\r\n\tif (int.TryParse(y, out yy) == false)\r\n\t{\r\n\t\tMessageBox.Show(&quot;y\u306b\u6570\u5024\u3092\u5165\u308c\u3066\u304f\u3060\u3055\u3044&quot;);\r\n\t\treturn;\r\n\t}\r\n\r\n\tvar l = new Logic();\r\n\tint ans = l.calc(xx, yy);\r\n\ttextBox3.Text = ans.ToString();\r\n}\r\n<\/pre>\n<p>\u7d50\u69cb\u9577\u304f\u306a\u308a\u307e\u3059\u304c\u3001\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u5165\u529b\u3057\u305f\u5024\u3092\u3072\u3068\u3064\u3072\u3068\u3064\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u306d\uff08\u3053\u306e\u90e8\u5206\u3092\u30c6\u30b9\u30c8\u53ef\u80fd\u306b\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u3067\u306f\u30d5\u30a9\u30fc\u30e0\u3092\u624b\u52d5\u3067\u30c6\u30b9\u30c8\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\uff09\u3002\u30ed\u30b8\u30c3\u30af\u306e calc \u30e1\u30bd\u30c3\u30c9\u3067\u306f\u300c\u8a08\u7b97\u3059\u308b\u300d\u3053\u3068\u3060\u3051\u306b\u96c6\u4e2d\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u25a0\u7b54\u3048\u304c10\u4ee5\u4e0a\u306e\u6642\u306b\u3001\u30a8\u30e9\u30fc\u306b\u3059\u308b<\/h2>\n<p>\u4eca\u5ea6\u306f\u3001\u8a08\u7b97\u7d50\u679c\u304c10\u4ee5\u4e0a\u306b\u306a\u3063\u305f\u3089\u30a8\u30e9\u30fc\u306b\u3059\u308b\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u300210\u4ee5\u4e0a\u306b\u306a\u308b\u3053\u3068\u306f\u3001calc \u30e1\u30bd\u30c3\u30c9\u5185\u3067\u3057\u304b\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u3001\u4f8b\u5916\u51e6\u7406\u3092\u5165\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic int calc(int x, int y)\r\n{\r\n\tint z = x + y;\r\n\tif ( z &gt;= 10 )\r\n\t{\r\n\t\tthrow new Exception( &amp;quot;\u7b54\u3048\u304c10\u4ee5\u4e0a\u3067\u3059&amp;quot;);\r\n\t}\r\n\treturn z;\r\n}\r\n<\/pre>\n<p>UI \u306e\u307b\u3046\u3067\u306f\u3001calc \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u305f\u3068\u304d\u306b\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u3089\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3055\u305b\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\ntry\r\n{\r\n\tvar l = new Logic();\r\n\tint ans = l.calc(xx, yy);\r\n\ttextBox3.Text = ans.ToString();\r\n}\r\ncatch ( Exception ex)\r\n{\r\n\tMessageBox.Show(ex.Message);\r\n}\r\n<\/pre>\n<h2>\u25a0\u4f8b\u5916\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f<\/h2>\n<p>\u3069\u3046\u305b\u306a\u306e\u3067\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n &#x5B;TestMethod]\r\npublic void Test\u4f8b\u5916\u767a\u751f()\r\n{\r\n\tvar l = new Logic();\r\n\ttry\r\n\t{\r\n\t\tint ans = l.calc(5, 6);\r\n\t}\r\n\tcatch\r\n\t{\r\n\t\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3059\u308c\u3070OK\r\n\t\treturn;\r\n\t}\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u306a\u3044\u5834\u5408\r\n\tAssert.Fail();\r\n}\r\n<\/pre>\n<p>\u4f8b\u5916\u304c\u767a\u751f\u3057\u306a\u3044\u5834\u5408\u306b\u300c\u5931\u6557\u300d\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb6.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"603\" height=\"474\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<h2>\u25a0\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304b\u3089\u66f8\u3044\u3066\u307f\u308b<\/h2>\n<p>\u4eca\u5ea6\u306f\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306e\u307b\u3046\u3092\u5148\u306b\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002calc\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u304c0\u672a\u6e80\u306e\u5834\u5408\u306f\u30a8\u30e9\u30fc\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic void Test\u5f15\u6570\u30c1\u30a7\u30c3\u30af1()\r\n{\r\n\tvar l = new Logic();\r\n\ttry\r\n\t{\r\n\t\tint ans = l.calc(-1, 6);\r\n\t}\r\n\tcatch\r\n\t{\r\n\t\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3059\u308c\u3070OK\r\n\t\treturn;\r\n\t}\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u306a\u3044\u5834\u5408\r\n\tAssert.Fail();\r\n}\r\npublic void Test\u5f15\u6570\u30c1\u30a7\u30c3\u30af2()\r\n{\r\n\tvar l = new Logic();\r\n\ttry\r\n\t{\r\n\t\tint ans = l.calc(0, -1);\r\n\t}\r\n\tcatch\r\n\t{\r\n\t\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u3059\u308c\u3070OK\r\n\t\treturn;\r\n\t}\r\n\t\/\/ \u4f8b\u5916\u304c\u767a\u751f\u306a\u3044\u5834\u5408\r\n\tAssert.Fail();\r\n}\r\n<\/pre>\n<p>\u5f15\u6570\u306f2\u3064\u3042\u308b\u306e\u3067\u3001\u30c6\u30b9\u30c8\u306f2\u3064\u5fc5\u8981\u3067\u3059\u3002\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u30682\u3064\u300c\u5931\u6557\u300d\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb7.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"613\" height=\"416\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<h2>\u25a0\u30c6\u30b9\u30c8\u304c\u901a\u308b\u3088\u3046\u306b\u30ed\u30b8\u30c3\u30af\u3092\u66f8\u304d\u76f4\u3059<\/h2>\n<p>\u30ed\u30b8\u30c3\u30af\u306e\u307b\u3046\u3092\u76f4\u3057\u307e\u3059\u3002\u30c6\u30b9\u30c8\u3092\u3057\u305f\u3068\u304d\u306b\u30aa\u30fc\u30eb\u30b0\u30ea\u30fc\u30f3\u306b\u306a\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic int calc(int x, int y)\r\n{\r\n\tif (x &lt; 0 || y &lt; 0)\r\n\t{\r\n\t\tthrow new Exception(&amp;quot;\u6570\u5024\u306f0\u4ee5\u4e0a\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044&amp;quot;);\r\n\t}\r\n\tint z = x + y;\r\n\tif ( z &gt;= 10 )\r\n\t{\r\n\t\tthrow new Exception( &amp;quot;\u7b54\u3048\u304c10\u4ee5\u4e0a\u3067\u3059&amp;quot;);\r\n\t}\r\n\treturn z;\r\n}\r\n<\/pre>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2013\/12\/image_thumb8.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"584\" height=\"315\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<h2>\u25a0\u306a\u305c\u3001\u30ed\u30b8\u30c3\u30af\u3092UI\u304b\u3089\u5206\u96e2\u3055\u305b\u308b\u306e\u304b\uff1f<\/h2>\n<p>\u3053\u3053\u307e\u3067\u8a66\u3057\u305f\u65b9\u306f\u308f\u304b\u308b\u3068\u601d\u3044\u307e\u3059\u304c\uff08\u3044\u3084\u3044\u3084\u3001TDD\u3060\u304b\u3089\u5468\u77e5\u306e\u4e8b\u5b9f\u304b\u3082\u3057\u308c\u306a\u3044\u3051\u3069\uff09\u3001\u5206\u96e2\u3057\u305f\u307b\u3046\u304c\u30c6\u30b9\u30c8\u304c\u3057\u3084\u3059\u3044\u306e\u3067\u3059\u3002\u9006\u306b\u3044\u3048\u3070\u3001UI\u3079\u3063\u305f\u308a\u306b\u30ed\u30b8\u30c3\u30af\u3092\u5165\u308c\u3066\u3057\u307e\u3046\u3068\u30c6\u30b9\u30c8\u3057\u305a\u3089\u3044\u3002\u3042\u308b\u3044\u306f\u3001\u30c6\u30b9\u30c8\u3067\u304d\u306a\u3044\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u3002\u307e\u3042\u3001UI\u81ea\u4f53\u3092\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u306a\u306e\u3067\u3001\u30c6\u30b9\u30c8\u3067\u304d\u306a\u3044\u8a33\u3067\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3002\u305d\u308c\u306f\u305d\u308c\u3068\u3057\u3066\u3001TDD\u306e\u57fa\u672c\u306e\u57fa\u672c\u306f\u3053\u3053\u304b\u3089\u30b9\u30bf\u30fc\u30c8\u3067\u3059\u3002\u30b1\u30f3\u30c8\u30d9\u30c3\u30af\u306e<a href=\"http:\/\/www.amazon.co.jp\/%E3%83%86%E3%82%B9%E3%83%88%E9%A7%86%E5%8B%95%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80-%E3%82%B1%E3%83%B3%E3%83%88-%E3%83%99%E3%83%83%E3%82%AF\/dp\/4894717115\/ref=pd_sxp_f_i\">\u300c\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\u5165\u9580\u300d<\/a>\u306f\u6b8b\u5ff5\u306a\u304c\u3089\u7d76\u7248\u6271\u3044\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\uff08Phython\u3067\u66f8\u304b\u308c\u3066\u3044\u308b\uff09 \u3092\uff11\u56de\u901a\u3057\u3066\u307f\u308b\u3068\u3001\u3069\u3053\u306bTDD\u3092\u4f7f\u3048\u3070\u300c\u52b9\u679c\u7684\u306a\u306e\u304b\u300d\u304c\u308f\u304b\u308a\u307e\u3059\u3002\u9006\u306b\u8a00\u3048\u3070\u3001\u4f5c\u696d\u91cf\u3092\u8003\u3048\u305f\u3068\u304d\u306b\u52b9\u679c\u7684\u3067\u306a\u3044\u3068\u3053\u308d\u306bTDD\u3092\u5229\u7528\u3057\u3066\u3082\u30c0\u30e1\u306a\u3093\u3067\u3059\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3067\u3001\u79c1\u304c\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f\u3068\u304d\u306b\u6c17\u3092\u4ed8\u3051\u308b\u306e\u306f\u3001\u30c6\u30b9\u30c8\u304c\u3057\u3084\u3059\u3044\u30af\u30e9\u30b9\u3042\u308b\u3044\u306f\u8a2d\u8a08\u3092\u3059\u308b\u3001\u3068\u3053\u308d\u306b\u6ce8\u529b\u3057\u3066\u307e\u3059\u3002\u30c6\u30b9\u30c8\u53ef\u80fd\u306a\u30af\u30e9\u30b9\u2252\u30c6\u30b9\u30c8\u3057\u3084\u3059\u3044\u8a2d\u8a08\u2252\u4e0d\u5177\u5408\u5bfe\u51e6\u304c\u3057\u3084\u3059\u3044\u3001\u3068\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u306d\u3002\u307e\u3042\u3001\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3053\u3068\u3082\u591a\u3005\u3042\u308b\u306e\u3067\u3001\u5b8c\u5168\u306b\u3068\u3044\u3046\u8a33\u306b\u306f\u3044\u304d\u307e\u305b\u3093\u304c\u3001\u30b3\u30a2\u306a\u90e8\u5206\uff08\u30e9\u30a4\u30d6\u30e9\u30ea\u90e8\u5206\uff09\u3092\u30c6\u30b9\u30c8\u53ef\u80fd\u306b\u3057\u3066\u304a\u304f\u306e\u306f\u5fc5\u9808\u304b\u306a\u3001\u3068\u5e38\u3005\u601d\u3063\u3066\u3044\u307e\u3059\u3002\u307e\u3042\u3001\u3072\u3068\u307e\u305a\u3001\uff11\u65e5\u76ee\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3068\u3044\u3046\u3053\u3068\u3067\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TDD Advent Calendar 2013\u306e\u53c2\u52a0\u72b6\u6cc1\u78ba\u8a8d\u30fb\u53c2\u52a0\u767b\u9332 &#8211; Qiita [\u30ad\u30fc\u30bf] http:\/\/qiita.com\/advent-calendar\/2013\/tddadventjp\/par &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/5254\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-5254","post","type-post","status-publish","format-standard","hentry","category-etc"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/5254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=5254"}],"version-history":[{"count":7,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/5254\/revisions"}],"predecessor-version":[{"id":5259,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/5254\/revisions\/5259"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=5254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=5254"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=5254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}