Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ConventionTests.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.20617.1 PREVIEW
VisualStudioVersion = 12.0.20623.1 VSUPREVIEW
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConventionTests", "ConventionTests\ConventionTests.csproj", "{1E12EA0C-9182-4029-991A-B0B9D38F5783}"
EndProject
Expand All @@ -23,6 +23,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{35B8E1
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly", "TestAssembly\TestAssembly.csproj", "{D5A0D078-C660-4654-8A14-DDC816BEBC54}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{E971721A-1271-4359-8F76-9FF17C29582B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp.Tests", "SampleApp.Tests\SampleApp.Tests.csproj", "{8FEF48A8-6FF5-4B65-B84A-6690D735C703}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "SampleApp\SampleApp.csproj", "{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,8 +51,20 @@ Global
{D5A0D078-C660-4654-8A14-DDC816BEBC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5A0D078-C660-4654-8A14-DDC816BEBC54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5A0D078-C660-4654-8A14-DDC816BEBC54}.Release|Any CPU.Build.0 = Release|Any CPU
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FEF48A8-6FF5-4B65-B84A-6690D735C703}.Release|Any CPU.Build.0 = Release|Any CPU
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8FEF48A8-6FF5-4B65-B84A-6690D735C703} = {E971721A-1271-4359-8F76-9FF17C29582B}
{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A} = {E971721A-1271-4359-8F76-9FF17C29582B}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions ConventionTests.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<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">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=SampleApp_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentNameForLiteralExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<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>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">all</s:String>
Expand Down
33 changes: 33 additions & 0 deletions SampleApp.Tests/DomainTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace SampleApp.Tests
{
using System.Linq;
using NUnit.Framework;
using SampleApp.Domain;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;
using TestStack.ConventionTests.Conventions;

[TestFixture]
public class DomainTests
{
readonly Types domainEntities;

public DomainTests()
{
domainEntities = Types.InAssemblyOf<DomainClass>("Domain Entities",
types => types.Where(t=>t.Namespace.StartsWith("SampleApp.Domain")));
}

[Test]
public void DomainClassesShouldHaveDefaultConstructor()
{
Convention.Is(new AllClassesHaveDefaultConstructor(), domainEntities);
}

[Test]
public void DomainClassesShouldHaveVirtualProperties()
{
Convention.Is(new AllMethodsAreVirtual(), domainEntities);
}
}
}
19 changes: 19 additions & 0 deletions SampleApp.Tests/DtoTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace SampleApp.Tests
{
using NUnit.Framework;
using SampleApp.Dtos;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;
using TestStack.ConventionTests.Conventions;

[TestFixture]
public class DtoTests
{
[Test]
public void DtosMustOnlyExistInDtoNameSpace()
{
Convention.Is(new ClassTypeHasSpecificNamespace(t=>t.Name.EndsWith("Dto"), "SampleApp.Dtos", "Dto"),
Types.InAssemblyOf<SomeDto>());
}
}
}
18 changes: 18 additions & 0 deletions SampleApp.Tests/MvcTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SampleApp.Tests
{
using NUnit.Framework;
using SampleApp.Mvc;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;
using TestStack.ConventionTests.Conventions;

[TestFixture]
public class MvcTests
{
[Test]
public void MvcControllerTest()
{
Convention.Is(new MvcControllerNameAndBaseClassConvention(), Types.InAssemblyOf<TestController>());
}
}
}
36 changes: 36 additions & 0 deletions SampleApp.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SampleApp.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SampleApp.Tests")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("7b4d34d3-0454-4676-8f40-0ee1c01b984f")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
94 changes: 94 additions & 0 deletions SampleApp.Tests/SampleApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8FEF48A8-6FF5-4B65-B84A-6690D735C703}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleApp.Tests</RootNamespace>
<AssemblyName>SampleApp.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DomainTests.cs" />
<Compile Include="DtoTests.cs" />
<Compile Include="MvcTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlScriptTests.cs" />
<Compile Include="WebApiTests.cs" />
<Compile Include="WpfTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SampleApp\SampleApp.csproj">
<Project>{56467A5A-7DD6-45B3-A84C-144A3C5D0C7A}</Project>
<Name>SampleApp</Name>
</ProjectReference>
<ProjectReference Include="..\TestStack.ConventionTests\TestStack.ConventionTests.csproj">
<Project>{955B0236-089F-434D-BA02-63A1E24C2B7C}</Project>
<Name>TestStack.ConventionTests</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="__TryItOut__.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
22 changes: 22 additions & 0 deletions SampleApp.Tests/SampleApp.Tests.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>
18 changes: 18 additions & 0 deletions SampleApp.Tests/SqlScriptTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SampleApp.Tests
{
using NUnit.Framework;
using SampleApp.Domain;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;
using TestStack.ConventionTests.Conventions;

[TestFixture]
public class SqlScriptTests
{
[Test]
public void SqlScriptsShouldBeEmbeddedResources()
{
Convention.Is(new FilesAreEmbeddedResources(".sql"), new ProjectFiles(typeof(DomainClass).Assembly));
}
}
}
18 changes: 18 additions & 0 deletions SampleApp.Tests/WebApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SampleApp.Tests
{
using NUnit.Framework;
using SampleApp.WebApi;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;
using TestStack.ConventionTests.Conventions;

[TestFixture]
public class WebApiTests
{
[Test]
public void WebApiConventions()
{
Convention.Is(new ApiControllerNamingAndBaseClassConvention(), Types.InAssemblyOf<TestApiController>());
}
}
}
18 changes: 18 additions & 0 deletions SampleApp.Tests/WpfTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SampleApp.Tests
{
using NUnit.Framework;
using SampleApp.Wpf;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;
using TestStack.ConventionTests.Conventions;

[TestFixture]
public class WpfTests
{
[Test]
public void ViewModelCOnventions()
{
Convention.Is(new ViewModelShouldInheritFromINotifyPropertyChanged(), Types.InAssemblyOf<ViewModelBase>());
}
}
}
11 changes: 11 additions & 0 deletions SampleApp.Tests/__TryItOut__.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
There are a number of conventions setup in this project, to try convention tests out, simply violate a convention, then run the tests.

Some examples:

- Create a class ending in Dto outside the Dto namespace
- Add a non-virtual method to the domain class
- Make the domain class constructor private
- Change the SqlScripts\Script0001.sql file build action to Content (rather than EmbeddedResource)
- Create an API Controller where you incorrectly spell 'Controller'

These are some of the examples of conventions which are easily put in place with convention tests!
8 changes: 8 additions & 0 deletions SampleApp.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.30506.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.30506.0" targetFramework="net40" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
<package id="NUnit" version="2.6.2" targetFramework="net40" />
</packages>
11 changes: 11 additions & 0 deletions SampleApp/Domain/DomainClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace SampleApp.Domain
{
public class DomainClass
{
protected DomainClass() { }

public virtual string Prop { get; set; }

public virtual void SomeAction() { }
}
}
7 changes: 7 additions & 0 deletions SampleApp/Dtos/SomeDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SampleApp.Dtos
{
public class SomeDto
{
public string Prop { get; set; }
}
}
9 changes: 9 additions & 0 deletions SampleApp/Mvc/TestController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SampleApp.Mvc
{
using System.Web.Mvc;

public class TestController : Controller
{

}
}
Loading