Changes between Version 2 and Version 3 of codekata/refactor


Ignore:
Timestamp:
11/06/2013 04:53:43 PM (12 years ago)
Author:
zhangyihui
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • codekata/refactor

    v2 v3  
    6868 
    6969 
    70 活动开始前,咱们组的陈阳童鞋一马当先,只管抢占键盘,是的,他只用键盘,就已经将需要重构的方法提炼出来,完全忽略鼠标,看得我眼睛一眨一眨的,暗下决定要学好vi的使用。 
    71  
    72  
    73  
    74  
    75  
    76  
    77  
    78  
    79  
    80  
    81  
    82  
    83  
    84  
    85  
    86  
    87  
     70活动开始前,咱们组的陈阳童鞋一马当先,只管抢占键盘,是的,他只用键盘,就已经将需要重构的方法提炼出来,完全忽略鼠标,看得我眼睛一眨一眨的,[[BR]] 
     71虽然用时比较长,但还是暗下决定要学好vi的使用。[[BR]] 
     72题目一出来,只见鸿源同志如风一般坐在了陈阳童鞋刚刚坐的位置,立马听到一连串的键盘音,声音过后,一个重构的新方法名就出来了,还带着测试类出来,[[BR]] 
     73跟着,与他组队的炳岳同志讨论下一步该怎么做。当然,这一过程是非常激烈的,但慢慢地,他们的意见终于统一了,想法达成一致,这时,鸿源同志二话不说[[BR]] 
     74马上又敲起键盘,将想法转变成测试代码。[[BR]] 
     75时间是无情的,正当键盘敲得起劲的时候,每人7分钟的演练时间到了,这时咱们只有将想写的,但不够时间写的代码,换成语言,去跟下一位进行代码演示的童鞋交流[[BR]] 
     76非常像头脑风暴,大量信息量同时在大脑出现,并且需要快速思考,学到的不仅仅是一段代码,还有思考问题的方法。[[BR]] 
     77现在,咱们来看下测试代码[[BR]] 
     78 
     79{{{ 
     80import junit.framework.Assert; 
     81 
     82import org.junit.Before; 
     83import org.junit.Ignore; 
     84import org.junit.Test; 
     85 
     86public class FunctionsTest { 
     87 
     88        private String appName = null; 
     89        private String itAppName = null; 
     90        private String rootUrl = null; 
     91        private String ucRoot = null; 
     92        private Topic topic = null; 
     93        private Forum forum = null; 
     94        private Post post = null; 
     95        private User user = null; 
     96 
     97        @Before 
     98        public void setUp() { 
     99                appName = "pcauto"; 
     100                itAppName = "itbbs"; 
     101                rootUrl = "http://bbs.pcauto.com.cn"; 
     102                ucRoot = "http://my.pcauto.com.cn"; 
     103                topic = new Topic(); 
     104                forum = new Forum(); 
     105                post = new Post(); 
     106                user = new User(); 
     107                forum.setFid(123L); 
     108        } 
     109 
     110        @Ignore 
     111        public void testHtmlUrl() { 
     112                // 变化的对象 Object,rootUrl,appName, 
     113                // Object是变化的,rootUrl,appName=auto 是固定的 
     114                Assert.assertEquals(rootUrl + "/topic-1342.html", 
     115                                Functions.htmlUrl(topic)); 
     116                Assert.assertEquals(rootUrl + "/404.html", 
     117                                Functions.htmlUrl((Topic) null)); 
     118                Assert.assertEquals(rootUrl + "/forum-123.html", 
     119                                Functions.htmlUrl(forum)); 
     120                Assert.assertEquals(rootUrl + "/post-789789_2424242.html", 
     121                                Functions.htmlUrl(post)); 
     122                Assert.assertEquals(ucRoot + "/2424", 
     123                                Functions.htmlUrl(user)); 
     124                Assert.assertEquals("1234567", 
     125                                Functions.htmlUrl("1234567")); 
     126 
     127        } 
     128 
     129        @Test 
     130        public void testHtmlUrlForum() { 
     131                Assert.assertEquals(rootUrl + "/forum-123.html", 
     132                                Functions.htmlUrl(forum)); 
     133                 
     134//              Assert.assertEquals(rootUrl + "/f123.html", 
     135//                              Functions.htmlUrl(forum, rootUrl, itAppName)); 
     136 
     137                Assert.assertEquals(rootUrl + "/404.html", 
     138                                Functions.htmlUrl((Forum) null)); 
     139 
     140        } 
     141 
     142        @Test 
     143        public void testHtmlUrlTopic() { 
     144                Assert.assertEquals(rootUrl + "/topic-1342.html", 
     145                                Functions.htmlUrl(topic)); 
     146 
     147//              Assert.assertEquals(rootUrl + "/1342.html", 
     148//                              Functions.htmlUrl(topic, rootUrl, itAppName)); 
     149                 
     150                Assert.assertEquals(rootUrl + "/404.html", 
     151                                Functions.htmlUrl((Topic) null)); 
     152        } 
     153 
     154        @Test 
     155        public void testHtmlUrlUser() { 
     156                Assert.assertEquals(ucRoot + "/2424/", 
     157                                Functions.htmlUrl(user)); 
     158                 
     159//              Assert.assertEquals(rootUrl + "/123.html", 
     160//                              Functions.htmlUrl(user, ucRoot, itAppName)); 
     161 
     162                Assert.assertEquals(rootUrl + "/404.html", 
     163                                Functions.htmlUrl((User) null)); 
     164        } 
     165 
     166        @Test 
     167        public void testHtmlUrlPost() { 
     168                Assert.assertEquals(rootUrl + "/post-789789_2424242.html", 
     169                                Functions.htmlUrl(post)); 
     170                 
     171//              Assert.assertEquals(rootUrl + "/p789789_2424242.html", 
     172//                              Functions.htmlUrl(post, rootUrl, itAppName)); 
     173 
     174                Assert.assertEquals(rootUrl + "/404.html", 
     175                                Functions.htmlUrl((Post) null)); 
     176        } 
     177 
     178        @Test 
     179        public void testHtmlUrlString() { 
     180                Assert.assertEquals("123456", 
     181                                Functions.htmlUrl("123456")); 
     182                 
     183//              Assert.assertEquals("123456", 
     184//                              Functions.htmlUrl("123456", rootUrl, itAppName)); 
     185 
     186                Assert.assertEquals(rootUrl + "/404.html", 
     187                                Functions.htmlUrl((String) null)); 
     188        } 
     189         
     190} 
     191}}}[[BR]] 
     192 
     193 
     194 
     195 
     196 
     197 
     198 
     199 
     200 
     201 
     202 
     203 
     204 
     205 
     206 
     207 
     208 
     209