Skip to content

Commit 9e739c8

Browse files
committed
Merge pull request #31 from JakeGinnivan/AddingSamples
Added sample app and sample tests to help people get started!
2 parents a079108 + 9412b1c commit 9e739c8

33 files changed

+1169
-6
lines changed

ConventionTests.sln

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.20617.1 PREVIEW
4+
VisualStudioVersion = 12.0.20623.1 VSUPREVIEW
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConventionTests", "ConventionTests\ConventionTests.csproj", "{1E12EA0C-9182-4029-991A-B0B9D38F5783}"
77
EndProject
@@ -23,6 +23,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{35B8E1
2323
EndProject
2424
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly", "TestAssembly\TestAssembly.csproj", "{D5A0D078-C660-4654-8A14-DDC816BEBC54}"
2525
EndProject
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{E971721A-1271-4359-8F76-9FF17C29582B}"
27+
EndProject
28+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp.Tests", "SampleApp.Tests\SampleApp.Tests.csproj", "{8FEF48A8-6FF5-4B65-B84A-6690D735C703}"
29+
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "SampleApp\SampleApp.csproj", "{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}"
31+
EndProject
2632
Global
2733
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2834
Debug|Any CPU = Debug|Any CPU
@@ -45,8 +51,20 @@ Global
4551
{D5A0D078-C660-4654-8A14-DDC816BEBC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
4652
{D5A0D078-C660-4654-8A14-DDC816BEBC54}.Release|Any CPU.ActiveCfg = Release|Any CPU
4753
{D5A0D078-C660-4654-8A14-DDC816BEBC54}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Release|Any CPU.Build.0 = Release|Any CPU
4862
EndGlobalSection
4963
GlobalSection(SolutionProperties) = preSolution
5064
HideSolutionNode = FALSE
5165
EndGlobalSection
66+
GlobalSection(NestedProjects) = preSolution
67+
{8FEF48A8-6FF5-4B65-B84A-6690D735C703} = {E971721A-1271-4359-8F76-9FF17C29582B}
68+
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A} = {E971721A-1271-4359-8F76-9FF17C29582B}
69+
EndGlobalSection
5270
EndGlobal

ConventionTests.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=SampleApp_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
23
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentNameForLiteralExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
34
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=all/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="all"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;ALWAYS_IMPLICIT&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_IMPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;/Profile&gt;</s:String>
45
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">all</s:String>

SampleApp.Tests/DomainTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
namespace SampleApp.Tests
2+
{
3+
using System.Linq;
4+
using NUnit.Framework;
5+
using SampleApp.Domain;
6+
using TestStack.ConventionTests;
7+
using TestStack.ConventionTests.ConventionData;
8+
using TestStack.ConventionTests.Conventions;
9+
10+
[TestFixture]
11+
public class DomainTests
12+
{
13+
readonly Types domainEntities;
14+
15+
public DomainTests()
16+
{
17+
domainEntities = Types.InAssemblyOf<DomainClass>("Domain Entities",
18+
types => types.Where(t=>t.Namespace.StartsWith("SampleApp.Domain")));
19+
}
20+
21+
[Test]
22+
public void DomainClassesShouldHaveDefaultConstructor()
23+
{
24+
Convention.Is(new AllClassesHaveDefaultConstructor(), domainEntities);
25+
}
26+
27+
[Test]
28+
public void DomainClassesShouldHaveVirtualProperties()
29+
{
30+
Convention.Is(new AllMethodsAreVirtual(), domainEntities);
31+
}
32+
}
33+
}

SampleApp.Tests/DtoTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace SampleApp.Tests
2+
{
3+
using NUnit.Framework;
4+
using SampleApp.Dtos;
5+
using TestStack.ConventionTests;
6+
using TestStack.ConventionTests.ConventionData;
7+
using TestStack.ConventionTests.Conventions;
8+
9+
[TestFixture]
10+
public class DtoTests
11+
{
12+
[Test]
13+
public void DtosMustOnlyExistInDtoNameSpace()
14+
{
15+
Convention.Is(new ClassTypeHasSpecificNamespace(t=>t.Name.EndsWith("Dto"), "SampleApp.Dtos", "Dto"),
16+
Types.InAssemblyOf<SomeDto>());
17+
}
18+
}
19+
}

SampleApp.Tests/MvcTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace SampleApp.Tests
2+
{
3+
using NUnit.Framework;
4+
using SampleApp.Mvc;
5+
using TestStack.ConventionTests;
6+
using TestStack.ConventionTests.ConventionData;
7+
using TestStack.ConventionTests.Conventions;
8+
9+
[TestFixture]
10+
public class MvcTests
11+
{
12+
[Test]
13+
public void MvcControllerTest()
14+
{
15+
Convention.Is(new MvcControllerNameAndBaseClassConvention(), Types.InAssemblyOf<TestController>());
16+
}
17+
}
18+
}
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+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SampleApp.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("SampleApp.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("7b4d34d3-0454-4676-8f40-0ee1c01b984f")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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>{8FEF48A8-6FF5-4B65-B84A-6690D735C703}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>SampleApp.Tests</RootNamespace>
11+
<AssemblyName>SampleApp.Tests</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</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="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
34+
<SpecificVersion>False</SpecificVersion>
35+
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
36+
</Reference>
37+
<Reference Include="nunit.framework">
38+
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
39+
</Reference>
40+
<Reference Include="System" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
44+
</Reference>
45+
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
47+
</Reference>
48+
<Reference Include="System.Net.Http.WebRequest, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
50+
</Reference>
51+
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
52+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll</HintPath>
53+
</Reference>
54+
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
55+
<Reference Include="System.Xml.Linq" />
56+
<Reference Include="System.Data.DataSetExtensions" />
57+
<Reference Include="Microsoft.CSharp" />
58+
<Reference Include="System.Data" />
59+
<Reference Include="System.Xml" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="DomainTests.cs" />
63+
<Compile Include="DtoTests.cs" />
64+
<Compile Include="MvcTests.cs" />
65+
<Compile Include="Properties\AssemblyInfo.cs" />
66+
<Compile Include="SqlScriptTests.cs" />
67+
<Compile Include="WebApiTests.cs" />
68+
<Compile Include="WpfTests.cs" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<ProjectReference Include="..\SampleApp\SampleApp.csproj">
72+
<Project>{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}</Project>
73+
<Name>SampleApp</Name>
74+
</ProjectReference>
75+
<ProjectReference Include="..\TestStack.ConventionTests\TestStack.ConventionTests.csproj">
76+
<Project>{955B0236-089F-434D-BA02-63A1E24C2B7C}</Project>
77+
<Name>TestStack.ConventionTests</Name>
78+
</ProjectReference>
79+
</ItemGroup>
80+
<ItemGroup>
81+
<None Include="packages.config" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<Content Include="__TryItOut__.txt" />
85+
</ItemGroup>
86+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
87+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
88+
Other similar extension points exist, see Microsoft.Common.targets.
89+
<Target Name="BeforeBuild">
90+
</Target>
91+
<Target Name="AfterBuild">
92+
</Target>
93+
-->
94+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<ProjectConfiguration>
2+
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
3+
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
4+
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
5+
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
6+
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
7+
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
8+
<RunPreBuildEvents>false</RunPreBuildEvents>
9+
<RunPostBuildEvents>false</RunPostBuildEvents>
10+
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
11+
<InstrumentAssembly>true</InstrumentAssembly>
12+
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
13+
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
14+
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
15+
<DefaultTestTimeout>60000</DefaultTestTimeout>
16+
<UseBuildConfiguration />
17+
<UseBuildPlatform />
18+
<ProxyProcessPath />
19+
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
20+
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
21+
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
22+
</ProjectConfiguration>

SampleApp.Tests/SqlScriptTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace SampleApp.Tests
2+
{
3+
using NUnit.Framework;
4+
using SampleApp.Domain;
5+
using TestStack.ConventionTests;
6+
using TestStack.ConventionTests.ConventionData;
7+
using TestStack.ConventionTests.Conventions;
8+
9+
[TestFixture]
10+
public class SqlScriptTests
11+
{
12+
[Test]
13+
public void SqlScriptsShouldBeEmbeddedResources()
14+
{
15+
Convention.Is(new FilesAreEmbeddedResources(".sql"), new ProjectFiles(typeof(DomainClass).Assembly));
16+
}
17+
}
18+
}

SampleApp.Tests/WebApiTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace SampleApp.Tests
2+
{
3+
using NUnit.Framework;
4+
using SampleApp.WebApi;
5+
using TestStack.ConventionTests;
6+
using TestStack.ConventionTests.ConventionData;
7+
using TestStack.ConventionTests.Conventions;
8+
9+
[TestFixture]
10+
public class WebApiTests
11+
{
12+
[Test]
13+
public void WebApiConventions()
14+
{
15+
Convention.Is(new ApiControllerNamingAndBaseClassConvention(), Types.InAssemblyOf<TestApiController>());
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)