<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>进化的测试 &#187; MOCK</title>
	<atom:link href="http://magustest.com/blog/tag/mock/feed/" rel="self" type="application/rss+xml" />
	<link>http://magustest.com/blog</link>
	<description>关注软件测试，白盒测试，自动化测试，性能测试</description>
	<lastBuildDate>Tue, 31 Aug 2010 16:19:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>NMock2入门经验</title>
		<link>http://magustest.com/blog/whiteboxtesting/beginning-nmock/</link>
		<comments>http://magustest.com/blog/whiteboxtesting/beginning-nmock/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 19:29:23 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[白盒测试]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[MOCK]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=105</guid>
		<description><![CDATA[每个做单元测试的人都应该一种技术&#8211;MOCK~什么是MOCK？其实没什么神秘的，就是打桩~网上流行的一些.NET的mock框架有：NMock2，Rhino.Mocks等…… NMock2是ThoughtWorks维护的一个开源项目，不知道是不是ThoughtWorks的风格就是敏捷开发基本没有文档，网络上很难找到关于NMock2的文档。而且网上给的例子也很简单，简单到需要自己补充一些东西上去才能跑通。还是用官网上的那个例子：现在有一个银行系统，它实现了一个功能，就是允许两个同名帐户之间实现转账功能。但是很不巧的是，在两个帐户之间转账涉及到汇率的问题，而这个汇率又是天天变的，需要从一个外部的服务来实现的。简单来说就是： 一个接口：IAccountService，实现转账的功能 一个接口：ICurrencyService，实现获取汇率的功能 1 2 3 4 5 6 7 8 9 10 public interface IAccountService &#160;     &#123;          void TransferFunds&#40;Account from, Account to, double amount&#41;;     &#125; &#160;     public interface ICurrencyService     &#123;         double GetConversionRate&#40;string fromCurrency, string toCurrency&#41;;     &#125; 一个类：Account，就是一个一个的帐户 1 2 3 4 5 6 7 8 9 [...]


Related posts:<ol><li><a href='http://magustest.com/blog/whiteboxtesting/refactoring-unit-test/' rel='bookmark' title='Permanent Link: 测试代码重构实例'>测试代码重构实例</a></li>
<li><a href='http://magustest.com/blog/net/automatic-generate-xml-instance-by-using-xsd/' rel='bookmark' title='Permanent Link: 用XSD自动生成XML对应的.NET实体类'>用XSD自动生成XML对应的.NET实体类</a></li>
<li><a href='http://magustest.com/blog/whiteboxtesting/using-linq-to-object-in-testing/' rel='bookmark' title='Permanent Link: Linq to Object在测试中的应用'>Linq to Object在测试中的应用</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>每个做单元测试的人都应该一种技术&#8211;MOCK~什么是MOCK？其实没什么神秘的，就是打桩~网上流行的一些.NET的mock框架有：NMock2，Rhino.Mocks等……</p>
<p>NMock2是ThoughtWorks维护的一个开源项目，不知道是不是ThoughtWorks的风格就是敏捷开发基本没有文档，网络上很难找到关于NMock2的文档。而且网上给的例子也很简单，简单到需要自己补充一些东西上去才能跑通。还是用官网上的那个例子：现在有一个银行系统，它实现了一个功能，就是允许两个同名帐户之间实现转账功能。但是很不巧的是，在两个帐户之间转账涉及到汇率的问题，而这个汇率又是天天变的，需要从一个外部的服务来实现的。简单来说就是：<br />
<span id="more-105"></span></p>
<p align="justify">一个接口：IAccountService，实现转账的功能<br />
一个接口：ICurrencyService，实现获取汇率的功能</p>
<p align="justify">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> IAccountService
&nbsp;
    <span style="color: #000000;">&#123;</span>
         <span style="color: #0600FF;">void</span> TransferFunds<span style="color: #000000;">&#40;</span>Account from, Account to, <span style="color: #FF0000;">double</span> amount<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> ICurrencyService
    <span style="color: #000000;">&#123;</span>
        <span style="color: #FF0000;">double</span> GetConversionRate<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> fromCurrency, <span style="color: #FF0000;">string</span> toCurrency<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>一个类：Account，就是一个一个的帐户</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Account
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">double</span> _balance<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _name<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _currency<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">double</span> balance
        <span style="color: #000000;">&#123;</span>
            get
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> _balance<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">private</span> set
            <span style="color: #000000;">&#123;</span>
                _balance <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> name
        <span style="color: #000000;">&#123;</span>
            get
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> _name<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            set
            <span style="color: #000000;">&#123;</span>
                _name <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Currency
        <span style="color: #000000;">&#123;</span>
            get
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> _currency<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            set
            <span style="color: #000000;">&#123;</span>
                _currency <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> Account<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">name</span> <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Currency</span> <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> Account<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> name, <span style="color: #FF0000;">string</span> currency<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">name</span> <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Currency</span> <span style="color: #008000;">=</span> currency<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Withdraw<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">double</span> amount<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">balance</span> <span style="color: #008000;">-=</span> amount<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Deposit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">double</span> amount<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">balance</span> <span style="color: #008000;">+=</span> amount<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>还有一个实现了IAccountService接口的AccountService类</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">   <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> AccountService <span style="color: #008000;">:</span> IAccountService
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> ICurrencyService currencyService<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> AccountService<span style="color: #000000;">&#40;</span>ICurrencyService currencyService<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">currencyService</span> <span style="color: #008000;">=</span> currencyService<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> TransferFunds<span style="color: #000000;">&#40;</span>Account from, Account to, <span style="color: #FF0000;">double</span> amount<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            from.<span style="color: #0000FF;">Withdraw</span><span style="color: #000000;">&#40;</span>amount<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #FF0000;">double</span> conversionRate <span style="color: #008000;">=</span> currencyService.<span style="color: #0000FF;">GetConversionRate</span><span style="color: #000000;">&#40;</span>from.<span style="color: #0000FF;">Currency</span>, to.<span style="color: #0000FF;">Currency</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #FF0000;">double</span> convertedAmount <span style="color: #008000;">=</span> amount <span style="color: #008000;">*</span> conversionRate<span style="color: #008000;">;</span>
            to.<span style="color: #0000FF;">Deposit</span><span style="color: #000000;">&#40;</span>convertedAmount<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>这里我们就对ICurrencyService接口实现一个Mock，给测试程序传递一个假的对象</p>
<p>首先在NUnit的代码里面定义需要用到的对象</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">        Mockery mocks<span style="color: #008000;">;</span> 
        ICurrencyService mockCurrencyService<span style="color: #008000;">;</span> 
        IAccountService accountService<span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>然后在单元测试的TestInitialize方法里面初始化mock</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        mocks <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Mockery<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>  <span style="color: #008080; font-style: italic;">//初始化mocks</span>
        mockCurrencyService <span style="color: #008000;">=</span> mocks.<span style="color: #0000FF;">NewMock</span><span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>ICurrencyService<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//产生一个mock对象</span>
        accountService <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> AccountService<span style="color: #000000;">&#40;</span>mockCurrencyService<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//用mock对象初始化accountService</span></pre></div></div>

<p>最后就是测试的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> ShouldUseCurrencyServiceToDetermineConversionRateBetweenAccounts<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">//生成2个帐号</span>
            Account canadianAccount <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Account<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;John Doe&quot;</span>, <span style="color: #666666;">&quot;CAD&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> 
            Account britishAccount <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Account<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Jane Doe&quot;</span>, <span style="color: #666666;">&quot;GBP&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">//给英国人存100块</span>
            britishAccount.<span style="color: #0000FF;">Deposit</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">100</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Expect.<span style="color: #0000FF;">Once</span>.<span style="color: #0000FF;">On</span><span style="color: #000000;">&#40;</span>mockCurrencyService<span style="color: #000000;">&#41;</span>.
                Method<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;GetConversionRate&quot;</span><span style="color: #000000;">&#41;</span>.
                With<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;GBP&quot;</span>, <span style="color: #666666;">&quot;CAD&quot;</span><span style="color: #000000;">&#41;</span>.
                Will<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Return</span>.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2.20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//对于mockCurrencyService对象，如果他的GetConversionRate方法被调用，而且参数分别是(&quot;GBP&quot;, &quot;CAD&quot;)，那么就返回一个值2.20</span>
&nbsp;
            accountService.<span style="color: #0000FF;">TransferFunds</span><span style="color: #000000;">&#40;</span>britishAccount, canadianAccount, <span style="color: #FF0000;">100</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">double</span><span style="color: #000000;">&#41;</span><span style="color: #FF0000;">0</span>, britishAccount.<span style="color: #0000FF;">balance</span>,<span style="color: #FF0000;">0.00001</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">double</span><span style="color: #000000;">&#41;</span><span style="color: #FF0000;">220</span>, canadianAccount.<span style="color: #0000FF;">balance</span>,<span style="color: #FF0000;">0.00001</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            mocks.<span style="color: #0000FF;">VerifyAllExpectationsHaveBeenMet</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>




Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://magustest.com/blog/feed/" title="RSS"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&amp;title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&amp;annotation=%E6%AF%8F%E4%B8%AA%E5%81%9A%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95%E7%9A%84%E4%BA%BA%E9%83%BD%E5%BA%94%E8%AF%A5%E4%B8%80%E7%A7%8D%E6%8A%80%E6%9C%AF--MOCK%7E%E4%BB%80%E4%B9%88%E6%98%AFMOCK%EF%BC%9F%E5%85%B6%E5%AE%9E%E6%B2%A1%E4%BB%80%E4%B9%88%E7%A5%9E%E7%A7%98%E7%9A%84%EF%BC%8C%E5%B0%B1%E6%98%AF%E6%89%93%E6%A1%A9%7E%E7%BD%91%E4%B8%8A%E6%B5%81%E8%A1%8C%E7%9A%84%E4%B8%80%E4%BA%9B.NET%E7%9A%84mock%E6%A1%86%E6%9E%B6%E6%9C%89%EF%BC%9ANMock2%EF%BC%8CRhino.Mocks%E7%AD%89%E2%80%A6%E2%80%A6%0D%0A%0D%0ANMock2%E6%98%AFThoughtWorks%E7%BB%B4%E6%8A%A4%E7%9A%84%E4%B8%80%E4%B8%AA%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%EF%BC%8C%E4%B8%8D%E7%9F%A5%E9%81%93%E6%98" title="Google Bookmarks"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&amp;title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&amp;bodytext=%E6%AF%8F%E4%B8%AA%E5%81%9A%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95%E7%9A%84%E4%BA%BA%E9%83%BD%E5%BA%94%E8%AF%A5%E4%B8%80%E7%A7%8D%E6%8A%80%E6%9C%AF--MOCK%7E%E4%BB%80%E4%B9%88%E6%98%AFMOCK%EF%BC%9F%E5%85%B6%E5%AE%9E%E6%B2%A1%E4%BB%80%E4%B9%88%E7%A5%9E%E7%A7%98%E7%9A%84%EF%BC%8C%E5%B0%B1%E6%98%AF%E6%89%93%E6%A1%A9%7E%E7%BD%91%E4%B8%8A%E6%B5%81%E8%A1%8C%E7%9A%84%E4%B8%80%E4%BA%9B.NET%E7%9A%84mock%E6%A1%86%E6%9E%B6%E6%9C%89%EF%BC%9ANMock2%EF%BC%8CRhino.Mocks%E7%AD%89%E2%80%A6%E2%80%A6%0D%0A%0D%0ANMock2%E6%98%AFThoughtWorks%E7%BB%B4%E6%8A%A4%E7%9A%84%E4%B8%80%E4%B8%AA%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%EF%BC%8C%E4%B8%8D%E7%9F%A5%E9%81%93%E6%98" title="Digg"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&amp;title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&amp;notes=%E6%AF%8F%E4%B8%AA%E5%81%9A%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95%E7%9A%84%E4%BA%BA%E9%83%BD%E5%BA%94%E8%AF%A5%E4%B8%80%E7%A7%8D%E6%8A%80%E6%9C%AF--MOCK%7E%E4%BB%80%E4%B9%88%E6%98%AFMOCK%EF%BC%9F%E5%85%B6%E5%AE%9E%E6%B2%A1%E4%BB%80%E4%B9%88%E7%A5%9E%E7%A7%98%E7%9A%84%EF%BC%8C%E5%B0%B1%E6%98%AF%E6%89%93%E6%A1%A9%7E%E7%BD%91%E4%B8%8A%E6%B5%81%E8%A1%8C%E7%9A%84%E4%B8%80%E4%BA%9B.NET%E7%9A%84mock%E6%A1%86%E6%9E%B6%E6%9C%89%EF%BC%9ANMock2%EF%BC%8CRhino.Mocks%E7%AD%89%E2%80%A6%E2%80%A6%0D%0A%0D%0ANMock2%E6%98%AFThoughtWorks%E7%BB%B4%E6%8A%A4%E7%9A%84%E4%B8%80%E4%B8%AA%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%EF%BC%8C%E4%B8%8D%E7%9F%A5%E9%81%93%E6%98" title="del.icio.us"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&amp;t=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C" title="Facebook"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C" title="豆瓣"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&n=1" title="豆瓣九点"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.friendfeed.com/share?title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&amp;link=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F" title="FriendFeed"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&amp;title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C" title="Live"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F&amp;title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&amp;body=%E6%AF%8F%E4%B8%AA%E5%81%9A%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95%E7%9A%84%E4%BA%BA%E9%83%BD%E5%BA%94%E8%AF%A5%E4%B8%80%E7%A7%8D%E6%8A%80%E6%9C%AF--MOCK%7E%E4%BB%80%E4%B9%88%E6%98%AFMOCK%EF%BC%9F%E5%85%B6%E5%AE%9E%E6%B2%A1%E4%BB%80%E4%B9%88%E7%A5%9E%E7%A7%98%E7%9A%84%EF%BC%8C%E5%B0%B1%E6%98%AF%E6%89%93%E6%A1%A9%7E%E7%BD%91%E4%B8%8A%E6%B5%81%E8%A1%8C%E7%9A%84%E4%B8%80%E4%BA%9B.NET%E7%9A%84mock%E6%A1%86%E6%9E%B6%E6%9C%89%EF%BC%9ANMock2%EF%BC%8CRhino.Mocks%E7%AD%89%E2%80%A6%E2%80%A6%0D%0A%0D%0ANMock2%E6%98%AFThoughtWorks%E7%BB%B4%E6%8A%A4%E7%9A%84%E4%B8%80%E4%B8%AA%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%EF%BC%8C%E4%B8%8D%E7%9F%A5%E9%81%93%E6%98" title="Ping.fm"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://shuqian.qq.com/post?jumpback=1&title=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C&uri=http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F" title="QQ书签"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=NMock2%E5%85%A5%E9%97%A8%E7%BB%8F%E9%AA%8C%20-%20http%3A%2F%2Fmagustest.com%2Fblog%2Fwhiteboxtesting%2Fbeginning-nmock%2F" title="Twitter"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>

<p>Related posts:<ol><li><a href='http://magustest.com/blog/whiteboxtesting/refactoring-unit-test/' rel='bookmark' title='Permanent Link: 测试代码重构实例'>测试代码重构实例</a></li>
<li><a href='http://magustest.com/blog/net/automatic-generate-xml-instance-by-using-xsd/' rel='bookmark' title='Permanent Link: 用XSD自动生成XML对应的.NET实体类'>用XSD自动生成XML对应的.NET实体类</a></li>
<li><a href='http://magustest.com/blog/whiteboxtesting/using-linq-to-object-in-testing/' rel='bookmark' title='Permanent Link: Linq to Object在测试中的应用'>Linq to Object在测试中的应用</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/whiteboxtesting/beginning-nmock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
