SPRNET-1536 add SPRNET-CODECONFIG migration sample to reinforce the docs
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Primes", "src\Primes\Primes.2008.csproj", "{865E1A8E-88F3-48D8-869F-B584C5A36740}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Primes.Tests", "test\Primes.Tests\Primes.Tests.2008.csproj", "{32476935-0852-4A11-B938-4D202D8B4454}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpringApp", "src\SpringApp\SpringApp.2008.csproj", "{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Primes", "src\Primes\Primes.2010.csproj", "{865E1A8E-88F3-48D8-869F-B584C5A36740}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Primes.Tests", "test\Primes.Tests\Primes.Tests.2010.csproj", "{32476935-0852-4A11-B938-4D202D8B4454}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpringApp", "src\SpringApp\SpringApp.2010.csproj", "{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{865E1A8E-88F3-48D8-869F-B584C5A36740}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32476935-0852-4A11-B938-4D202D8B4454}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Primes
|
||||
{
|
||||
public class ConsoleReport
|
||||
{
|
||||
private IOutputFormatter _outputFormatter;
|
||||
|
||||
private IPrimeGenerator _primeGenerator;
|
||||
|
||||
private int _maxNumber;
|
||||
|
||||
public ConsoleReport(IOutputFormatter outputFormatter, IPrimeGenerator primeGenerator)
|
||||
{
|
||||
_outputFormatter = outputFormatter;
|
||||
_primeGenerator = primeGenerator;
|
||||
}
|
||||
public IOutputFormatter OutputFormatter
|
||||
{
|
||||
set { _outputFormatter = value; }
|
||||
}
|
||||
|
||||
public int MaxNumber
|
||||
{
|
||||
get { return _maxNumber; }
|
||||
set { _maxNumber = value; }
|
||||
}
|
||||
|
||||
public void Write()
|
||||
{
|
||||
IList<string> results = _outputFormatter.Format(_primeGenerator.GeneratePrimesUpTo(_maxNumber));
|
||||
|
||||
foreach (string item in results)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Primes
|
||||
{
|
||||
public interface IOutputFormatter
|
||||
{
|
||||
IList<string> Format(string input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Primes
|
||||
{
|
||||
public interface IPrimeGenerator
|
||||
{
|
||||
string GeneratePrimesUpTo(int max);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Primes
|
||||
{
|
||||
public class LinqPrimeGenerator : IPrimeGenerator
|
||||
{
|
||||
#region IPrimeGenerator Members
|
||||
|
||||
public string GeneratePrimesUpTo(int maxNumber)
|
||||
{
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if (maxNumber <= 0)
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
Func<int, IEnumerable<int>> primeNumbers = max =>
|
||||
from i in Enumerable.Range(2, max - 1)
|
||||
where Enumerable.Range(2, i - 2).All(j => i%j != 0)
|
||||
select i;
|
||||
|
||||
IEnumerable<int> result = primeNumbers(maxNumber);
|
||||
|
||||
foreach (int i in result)
|
||||
{
|
||||
sb.Append(i.ToString());
|
||||
sb.Append(",");
|
||||
}
|
||||
|
||||
string theString = sb.ToString();
|
||||
|
||||
if (theString.Contains(","))
|
||||
theString = theString.Remove(theString.LastIndexOf(","));
|
||||
|
||||
return theString;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Primes
|
||||
{
|
||||
public class OutputFormatter : IOutputFormatter
|
||||
{
|
||||
public IList<string> Format(string input)
|
||||
{
|
||||
string[] elements = input.Split(",".ToCharArray());
|
||||
|
||||
IList<string> result = new List<string>();
|
||||
|
||||
int lineCount = 0;
|
||||
|
||||
for (int i = 0; i < elements.Length; i += 5)
|
||||
{
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
for (int j = i; j < i + 5; j++)
|
||||
{
|
||||
sb.Append(elements[j]);
|
||||
sb.Append(",");
|
||||
if (j == elements.Length - 1)
|
||||
break;
|
||||
}
|
||||
|
||||
string theString = sb.ToString();
|
||||
|
||||
if (theString.EndsWith(","))
|
||||
theString = theString.Substring(0, theString.Length - 1);
|
||||
|
||||
if (lineCount > 0 && (lineCount % 10 == 0))
|
||||
result.Add("Count: " + i);
|
||||
|
||||
lineCount += 1;
|
||||
|
||||
result.Add(theString);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Primes
|
||||
{
|
||||
public class PrimeEvaluationEngine
|
||||
{
|
||||
public bool IsPrime(int candidate)
|
||||
{
|
||||
if (candidate <= 1)
|
||||
return false;
|
||||
|
||||
if (candidate == 2)
|
||||
return true;
|
||||
|
||||
if (candidate % 2 == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 3; i < Math.Sqrt(candidate); i += 2)
|
||||
{
|
||||
if (candidate % i == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Primes
|
||||
{
|
||||
public class PrimeGenerator : IPrimeGenerator
|
||||
{
|
||||
private PrimeEvaluationEngine _primeEvaluationEngine;
|
||||
|
||||
public string GeneratePrimesUpTo(int max)
|
||||
{
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
if (_primeEvaluationEngine.IsPrime(i))
|
||||
{
|
||||
sb.Append(i.ToString());
|
||||
sb.Append(",");
|
||||
}
|
||||
}
|
||||
|
||||
string theString = sb.ToString();
|
||||
|
||||
if (theString.Contains(","))
|
||||
theString = theString.Remove(theString.LastIndexOf(","));
|
||||
|
||||
return theString;
|
||||
}
|
||||
|
||||
|
||||
public PrimeGenerator(PrimeEvaluationEngine primeEvaluationEngine)
|
||||
{
|
||||
_primeEvaluationEngine = primeEvaluationEngine;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{865E1A8E-88F3-48D8-869F-B584C5A36740}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Primes</RootNamespace>
|
||||
<AssemblyName>Primes</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</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="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IOutputFormatter.cs" />
|
||||
<Compile Include="IPrimeGenerator.cs" />
|
||||
<Compile Include="LinqPrimeGenerator.cs" />
|
||||
<Compile Include="OutputFormatter.cs" />
|
||||
<Compile Include="PrimeEvaluationEngine.cs" />
|
||||
<Compile Include="PrimeGenerator.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ConsoleReport.cs" />
|
||||
</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>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{865E1A8E-88F3-48D8-869F-B584C5A36740}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Primes</RootNamespace>
|
||||
<AssemblyName>Primes</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<TargetFrameworkProfile />
|
||||
</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="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IOutputFormatter.cs" />
|
||||
<Compile Include="IPrimeGenerator.cs" />
|
||||
<Compile Include="LinqPrimeGenerator.cs" />
|
||||
<Compile Include="OutputFormatter.cs" />
|
||||
<Compile Include="PrimeEvaluationEngine.cs" />
|
||||
<Compile Include="PrimeGenerator.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ConsoleReport.cs" />
|
||||
</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>
|
||||
@@ -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("Primes")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Primes")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2009")]
|
||||
[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("62a3a729-c953-47fb-95a0-6e66956cbe94")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="MaximumNumber" value="1000"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using Primes;
|
||||
using Spring.Context.Attributes;
|
||||
|
||||
namespace SpringApp
|
||||
{
|
||||
[Configuration]
|
||||
public class PrimesConfiguration
|
||||
{
|
||||
[ObjectDef]
|
||||
public virtual ConsoleReport ConsoleReport()
|
||||
{
|
||||
ConsoleReport report = new ConsoleReport(OutputFormatter(), PrimeGenerator());
|
||||
|
||||
report.MaxNumber = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MaximumNumber"));
|
||||
return report;
|
||||
}
|
||||
|
||||
[ObjectDef]
|
||||
public virtual IOutputFormatter OutputFormatter()
|
||||
{
|
||||
return new OutputFormatter();
|
||||
}
|
||||
|
||||
[ObjectDef]
|
||||
public virtual IPrimeGenerator PrimeGenerator()
|
||||
{
|
||||
return new PrimeGenerator(new PrimeEvaluationEngine());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Primes;
|
||||
using Spring.Context;
|
||||
using Spring.Context.Attributes;
|
||||
using Spring.Context.Support;
|
||||
using Spring.Objects.Factory.Config;
|
||||
using Spring.Objects.Factory.Support;
|
||||
using System.Linq;
|
||||
|
||||
namespace SpringApp
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//uncomment this next line to to use XML to assemble the container
|
||||
//IApplicationContext ctx = CreateContainerUsingXML();
|
||||
|
||||
//uncomment this next line to to use CodeConfig to assemble the container
|
||||
IApplicationContext ctx = CreateContainerUsingCodeConfig();
|
||||
|
||||
ConsoleReport report = ctx["ConsoleReport"] as ConsoleReport;
|
||||
report.Write();
|
||||
|
||||
ctx.Dispose();
|
||||
|
||||
Console.WriteLine("--- hit enter to exit --");
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
|
||||
private static IApplicationContext CreateContainerUsingXML()
|
||||
{
|
||||
return new XmlApplicationContext("application-context.xml");
|
||||
}
|
||||
|
||||
private static IApplicationContext CreateContainerUsingCodeConfig()
|
||||
{
|
||||
CodeConfigApplicationContext ctx = new CodeConfigApplicationContext();
|
||||
ctx.ScanAllAssemblies();
|
||||
ctx.Refresh();
|
||||
return ctx;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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("SpringApp")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SpringApp")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2009")]
|
||||
[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("d8ce7151-6f8b-4c3b-a0f5-ec8606579384")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SpringApp</RootNamespace>
|
||||
<AssemblyName>SpringApp</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</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="Common.Logging">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\net\3.5\Common.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Spring.Core, Version=0.0.0.35000, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\bin\net\3.5\debug\Spring.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PrimesConfiguration.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="application-context.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Primes\Primes.2008.csproj">
|
||||
<Project>{865E1A8E-88F3-48D8-869F-B584C5A36740}</Project>
|
||||
<Name>Primes</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</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>
|
||||
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{08A8AC17-E5E1-48FC-9958-76ECA8C08D71}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SpringApp</RootNamespace>
|
||||
<AssemblyName>SpringApp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</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="Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\bin\net\3.5\debug\Common.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Spring.Core, Version=0.0.0.35000, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\bin\net\3.5\debug\Spring.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PrimesConfiguration.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="application-context.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Primes\Primes.2010.csproj">
|
||||
<Project>{865E1A8E-88F3-48D8-869F-B584C5A36740}</Project>
|
||||
<Name>Primes</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</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>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<objects xmlns="http://www.springframework.net">
|
||||
|
||||
<object name="ConsoleReport" type="Primes.ConsoleReport, Primes">
|
||||
<constructor-arg ref="PrimeGenerator"/>
|
||||
<constructor-arg ref="OutputFormatter"/>
|
||||
<property name="MaxNumber" value="1000"/>
|
||||
</object>
|
||||
|
||||
<object name="PrimeGenerator" type="Primes.PrimeGenerator, Primes">
|
||||
<constructor-arg>
|
||||
<object type="Primes.PrimeEvaluationEngine, Primes"/>
|
||||
</constructor-arg>
|
||||
</object>
|
||||
|
||||
<object name="OutputFormatter" type="Primes.OutputFormatter, Primes"/>
|
||||
|
||||
|
||||
</objects>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{32476935-0852-4A11-B938-4D202D8B4454}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Primes</RootNamespace>
|
||||
<AssemblyName>Primes.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</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="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\lib\Net\2.0\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Even.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Negative.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_One.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Two.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Zero.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Constructing_PrimeEvaluator.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Number_is_evaluated.cs" />
|
||||
<Compile Include="Primes\Formatter\When_Constructing_Formatter.cs" />
|
||||
<Compile Include="Primes\Formatter\When_Formatting_Output.cs" />
|
||||
<Compile Include="Primes\Generator\When_Calculating_Range_Of_Primes.cs" />
|
||||
<Compile Include="Primes\Generator\When_Constructing_Generator.cs" />
|
||||
<Compile Include="Primes\Generator\When_No_Primes_Found_In_Range.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Primes\Primes.2008.csproj">
|
||||
<Project>{865E1A8E-88F3-48D8-869F-B584C5A36740}</Project>
|
||||
<Name>Primes</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</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>
|
||||
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{32476935-0852-4A11-B938-4D202D8B4454}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Primes</RootNamespace>
|
||||
<AssemblyName>Primes.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</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="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\lib\Net\3.5\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Even.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Negative.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_One.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Two.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Candidate_Is_Zero.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Constructing_PrimeEvaluator.cs" />
|
||||
<Compile Include="Primes\EvaluationEngine\When_Number_is_evaluated.cs" />
|
||||
<Compile Include="Primes\Formatter\When_Constructing_Formatter.cs" />
|
||||
<Compile Include="Primes\Formatter\When_Formatting_Output.cs" />
|
||||
<Compile Include="Primes\Generator\When_Calculating_Range_Of_Primes.cs" />
|
||||
<Compile Include="Primes\Generator\When_Constructing_Generator.cs" />
|
||||
<Compile Include="Primes\Generator\When_No_Primes_Found_In_Range.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Primes\Primes.2010.csproj">
|
||||
<Project>{865E1A8E-88F3-48D8-869F-B584C5A36740}</Project>
|
||||
<Name>Primes</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</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>
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Candidate_Is_Even
|
||||
{
|
||||
[Test]
|
||||
public void Can_Reject_Candidate()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsFalse(primeEvaluationEngine.IsPrime(8));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Candidate_Is_Negative
|
||||
{
|
||||
[Test]
|
||||
public void Can_Reject_Candidate()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsFalse(primeEvaluationEngine.IsPrime(-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Candidate_Is_One
|
||||
{
|
||||
[Test]
|
||||
public void Can_Reject_Candidate()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsFalse(primeEvaluationEngine.IsPrime(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Candidate_Is_Two
|
||||
{
|
||||
[Test]
|
||||
public void Can_Accept_Candidate()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsTrue(primeEvaluationEngine.IsPrime(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Candidate_Is_Zero
|
||||
{
|
||||
[Test]
|
||||
public void Can_Reject_Candidate()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsFalse(primeEvaluationEngine.IsPrime(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Constructing_PrimeEvaluator
|
||||
{
|
||||
[Test]
|
||||
public void Can_Create_Instance()
|
||||
{
|
||||
var primeNumberEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsNotNull(primeNumberEngine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.EvaluationEngine
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Number_is_evaluated
|
||||
{
|
||||
private const int NON_PRIME_TEST_VALUE = 35;
|
||||
|
||||
private const int PRIME_TEST_VALUE = 17;
|
||||
|
||||
[Test]
|
||||
public void Can_Accept_Candidate_When_Prime()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsTrue(primeEvaluationEngine.IsPrime(PRIME_TEST_VALUE));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Reject_Candidate_When_Not_Prime()
|
||||
{
|
||||
var primeEvaluationEngine = new PrimeEvaluationEngine();
|
||||
|
||||
Assert.IsFalse(primeEvaluationEngine.IsPrime(NON_PRIME_TEST_VALUE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.Formatter
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Constructing_Formatter
|
||||
{
|
||||
[Test]
|
||||
public void Can_Create_Instance()
|
||||
{
|
||||
var outputFormatter = new OutputFormatter();
|
||||
|
||||
Assert.IsNotNull(outputFormatter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.Formatter
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Formatting_Output
|
||||
{
|
||||
private string _generatedPrimes;
|
||||
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void _TestFixtureSetUp()
|
||||
{
|
||||
_generatedPrimes = new PrimeGenerator(new PrimeEvaluationEngine()).GeneratePrimesUpTo(20);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Collection_of_Output_Lines_is_Returned()
|
||||
{
|
||||
var outputFormatter = new OutputFormatter();
|
||||
|
||||
IList<string> formattedOutput = outputFormatter.Format(_generatedPrimes);
|
||||
|
||||
Assert.IsAssignableFrom(typeof (List<string>), formattedOutput);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Each_Output_Line_Contains_No_More_Than_Five_Items()
|
||||
{
|
||||
var outputFormatter = new OutputFormatter();
|
||||
|
||||
IList<string> formattedOutput = outputFormatter.Format(_generatedPrimes);
|
||||
|
||||
string[] splitPrimes;
|
||||
|
||||
foreach (string item in formattedOutput)
|
||||
{
|
||||
splitPrimes = item.Split(",".ToCharArray());
|
||||
|
||||
Assert.LessOrEqual(splitPrimes.Length, 5);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Every_Tenth_Line_Contains_Count()
|
||||
{
|
||||
var generatedPrimes = new PrimeGenerator(new PrimeEvaluationEngine()).GeneratePrimesUpTo(2000);
|
||||
|
||||
var outputFormatter = new OutputFormatter();
|
||||
|
||||
IList<string> formattedOutput = outputFormatter.Format(generatedPrimes);
|
||||
|
||||
for (int i = 10; i < formattedOutput.Count; i += 11)
|
||||
{
|
||||
Assert.IsTrue(formattedOutput[i].Contains("Count:"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.Generator
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Calculating_Range_Of_Primes
|
||||
{
|
||||
[Test]
|
||||
public void Can_Return_Values_Comma_Delimited()
|
||||
{
|
||||
var primeGenerator = new PrimeGenerator(new PrimeEvaluationEngine());
|
||||
|
||||
string actual = primeGenerator.GeneratePrimesUpTo(10);
|
||||
|
||||
Assert.AreEqual("2,3,5,7,9", actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.Generator
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_Constructing_Generator
|
||||
{
|
||||
[Test]
|
||||
public void Can_Create_Instance()
|
||||
{
|
||||
var generator = new PrimeGenerator(new PrimeEvaluationEngine());
|
||||
|
||||
Assert.IsNotNull(generator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using Primes;
|
||||
|
||||
namespace Tests.Generator
|
||||
{
|
||||
[TestFixture]
|
||||
public class When_No_Primes_Found_In_Range
|
||||
{
|
||||
[Test]
|
||||
public void Can_Return_Empty_String()
|
||||
{
|
||||
var primeGenerator = new PrimeGenerator(new PrimeEvaluationEngine());
|
||||
|
||||
Assert.AreEqual(string.Empty, primeGenerator.GeneratePrimesUpTo(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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("Primes.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Primes.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2009")]
|
||||
[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("ce7b9b23-5d7c-4f4b-8d7c-885050ef836a")]
|
||||
|
||||
// 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")]
|
||||
Reference in New Issue
Block a user