Skip to content

Commit ff6bb75

Browse files
author
demofan
committed
2 parents ec78766 + acd346c commit ff6bb75

File tree

156 files changed

+55570
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+55570
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Ch14-AutoTesting/14-2 Stub and Mock Sample/StubAndMockSample/StubAndMockSample/obj/
2+
Ch14-AutoTesting/14-2 Stub and Mock Sample/StubAndMockSample/StubAndMockSampleTests/bin/
3+
Ch14-AutoTesting/14-1 first unit test/CalculatorSample/CalculatorSample/obj/
4+
Ch14-AutoTesting/14-1 first unit test/CalculatorSample/CalculatorSampleTests/obj/
5+
Ch14-AutoTesting/14-2 Stub and Mock Sample/StubAndMockSample/StubAndMockSampleTests/obj/
6+
Ch14-AutoTesting/14-3 selenium Sample/SeleniumSample/packages/
7+
Ch14-AutoTesting/14-3 selenium Sample/SeleniumSample/SeleniumSample/bin/
8+
Ch14-AutoTesting/14-3 selenium Sample/SeleniumSample/SeleniumSample/obj/
9+
Ch14-AutoTesting/14-3 selenium Sample/SeleniumSample/SeleniumSample.Tests/obj/
10+
Ch14-AutoTesting/14-3 selenium Sample/SeleniumSample/SeleniumSample.Tests/bin/
11+
Ch14-AutoTesting/14-4 refactoring sample/RefactoringSample/CalculateShippingFee.Tests/bin/
12+
Ch14-AutoTesting/14-4 refactoring sample/RefactoringSample/packages/
13+
Ch14-AutoTesting/14-4 refactoring sample/RefactoringSample/CalculateShippingFee/obj/
14+
Ch14-AutoTesting/14-4 refactoring sample/RefactoringSample/CalculateShippingFee.Tests/obj/
15+
Ch14-AutoTesting/14-4 refactoring sample/RefactoringSample/CalculateShippingFee/bin/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.21005.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CalculatorSample", "CalculatorSample\CalculatorSample.csproj", "{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CalculatorSampleTests", "CalculatorSampleTests\CalculatorSampleTests.csproj", "{3EB16709-B6FB-4326-A8D0-3CB2CD2E48BD}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{3EB16709-B6FB-4326-A8D0-3CB2CD2E48BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{3EB16709-B6FB-4326-A8D0-3CB2CD2E48BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{3EB16709-B6FB-4326-A8D0-3CB2CD2E48BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{3EB16709-B6FB-4326-A8D0-3CB2CD2E48BD}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
namespace CalculatorSample
3+
{
4+
public class Calculator
5+
{
6+
public int Add(int firstNumber, int secondNumber)
7+
{
8+
if (firstNumber == 0)
9+
{
10+
throw new ArgumentOutOfRangeException("firstNumber");
11+
}
12+
13+
return firstNumber + secondNumber;
14+
}
15+
}
16+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CalculatorSample</RootNamespace>
11+
<AssemblyName>CalculatorSample</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Xml.Linq" />
36+
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Xml" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="Calculator.cs" />
43+
<Compile Include="Properties\AssemblyInfo.cs" />
44+
</ItemGroup>
45+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
46+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
47+
Other similar extension points exist, see Microsoft.Common.targets.
48+
<Target Name="BeforeBuild">
49+
</Target>
50+
<Target Name="AfterBuild">
51+
</Target>
52+
-->
53+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 組件的一般資訊是由下列的屬性集控制。
6+
// 變更這些屬性的值即可修改組件的相關
7+
// 資訊。
8+
[assembly: AssemblyTitle("CalculatorSample")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("CalculatorSample")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// 將 ComVisible 設定為 false 會使得這個組件中的類型
18+
// 對 COM 元件而言為不可見。如果您需要從 COM 存取這個組件中
19+
// 的類型,請在該類型上將 ComVisible 屬性設定為 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID
23+
[assembly: Guid("40ca132a-9d6e-4b04-bfb7-f44561a61a6b")]
24+
25+
// 組件的版本資訊是由下列四項值構成:
26+
//
27+
// 主要版本
28+
// 次要版本
29+
// 組建編號
30+
// 修訂編號
31+
//
32+
// 您可以指定所有的值,也可以依照以下的方式,使用 '*' 將組建和修訂編號
33+
// 指定為預設值:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{3EB16709-B6FB-4326-A8D0-3CB2CD2E48BD}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>CalculatorSampleTests</RootNamespace>
10+
<AssemblyName>CalculatorSampleTests</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
<TargetFrameworkProfile />
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
22+
<DebugSymbols>true</DebugSymbols>
23+
<DebugType>full</DebugType>
24+
<Optimize>false</Optimize>
25+
<OutputPath>bin\Debug\</OutputPath>
26+
<DefineConstants>DEBUG;TRACE</DefineConstants>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="System" />
40+
</ItemGroup>
41+
<Choose>
42+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
43+
<ItemGroup>
44+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
45+
</ItemGroup>
46+
</When>
47+
<Otherwise>
48+
<ItemGroup>
49+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
50+
</ItemGroup>
51+
</Otherwise>
52+
</Choose>
53+
<ItemGroup>
54+
<Compile Include="CalculatorTests.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<ProjectReference Include="..\CalculatorSample\CalculatorSample.csproj">
59+
<Project>{E60B0A96-4D19-4CB6-8CB2-A1BB05BF92E8}</Project>
60+
<Name>CalculatorSample</Name>
61+
</ProjectReference>
62+
</ItemGroup>
63+
<Choose>
64+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
65+
<ItemGroup>
66+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
67+
<Private>False</Private>
68+
</Reference>
69+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
70+
<Private>False</Private>
71+
</Reference>
72+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
73+
<Private>False</Private>
74+
</Reference>
75+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
76+
<Private>False</Private>
77+
</Reference>
78+
</ItemGroup>
79+
</When>
80+
</Choose>
81+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
82+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
83+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
84+
Other similar extension points exist, see Microsoft.Common.targets.
85+
<Target Name="BeforeBuild">
86+
</Target>
87+
<Target Name="AfterBuild">
88+
</Target>
89+
-->
90+
</Project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using CalculatorSample;
7+
using Microsoft.VisualStudio.TestTools.UnitTesting;
8+
namespace CalculatorSample.Tests
9+
{
10+
[TestClass()]
11+
public class CalculatorTests
12+
{
13+
[TestMethod()]
14+
public void AddTest_first為1_second為2_result應為3()
15+
{
16+
//arrange
17+
var target = new Calculator();
18+
19+
var first = 1;
20+
var second = 2;
21+
22+
var expected =3;
23+
24+
//act
25+
var actual = target.Add(first, second);
26+
27+
//assert
28+
Assert.AreEqual(expected, actual);
29+
}
30+
}
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 組件的一般資訊是由下列的屬性集控制。
6+
// 變更這些屬性的值即可修改組件的相關
7+
// 資訊。
8+
[assembly: AssemblyTitle("CalculatorSampleTests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("CalculatorSampleTests")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// 將 ComVisible 設定為 false 會使得這個組件中的類型
18+
// 對 COM 元件而言為不可見。如果您需要從 COM 存取此組件中
19+
// 的類型,請在該類型上將 ComVisible 屬性設定為 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID
23+
[assembly: Guid("361e5355-f6f8-4959-a925-8497cb5a5709")]
24+
25+
// 組件的版本資訊是由下列四項值構成:
26+
//
27+
// 主要版本
28+
// 次要版本
29+
// 組建編號
30+
// 修訂編號
31+
//
32+
// 您可以指定所有的值,也可以依照以下的方式,使用 '*' 將組建和修訂編號
33+
// 指定為預設值:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30501.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubAndMockSample", "StubAndMockSample\StubAndMockSample.csproj", "{AF94BC1F-E03C-4988-9A89-D7C18A437EED}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubAndMockSampleTests", "StubAndMockSampleTests\StubAndMockSampleTests.csproj", "{46E8C985-4F9D-4985-AAEF-F44FA54270CC}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{AF94BC1F-E03C-4988-9A89-D7C18A437EED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{AF94BC1F-E03C-4988-9A89-D7C18A437EED}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{AF94BC1F-E03C-4988-9A89-D7C18A437EED}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{AF94BC1F-E03C-4988-9A89-D7C18A437EED}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{46E8C985-4F9D-4985-AAEF-F44FA54270CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{46E8C985-4F9D-4985-AAEF-F44FA54270CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{46E8C985-4F9D-4985-AAEF-F44FA54270CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{46E8C985-4F9D-4985-AAEF-F44FA54270CC}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 組件的一般資訊是由下列的屬性集控制。
6+
// 變更這些屬性的值即可修改組件的相關
7+
// 資訊。
8+
[assembly: AssemblyTitle("StubAndMockSample")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("StubAndMockSample")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// 將 ComVisible 設定為 false 會使得這個組件中的類型
18+
// 對 COM 元件而言為不可見。如果您需要從 COM 存取這個組件中
19+
// 的類型,請在該類型上將 ComVisible 屬性設定為 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID
23+
[assembly: Guid("93f7bac1-38ed-4986-9701-ee2b341c209b")]
24+
25+
// 組件的版本資訊是由下列四項值構成:
26+
//
27+
// 主要版本
28+
// 次要版本
29+
// 組建編號
30+
// 修訂編號
31+
//
32+
// 您可以指定所有的值,也可以依照以下的方式,使用 '*' 將組建和修訂編號
33+
// 指定為預設值:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)