mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Added unit tests
This commit is contained in:
parent
3906ee2b8d
commit
62fa51d8b5
335
.gitignore
vendored
335
.gitignore
vendored
@ -5,3 +5,338 @@
|
||||
python/.cache
|
||||
python/.coverage
|
||||
**/.idea
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
BIN
TestNinja/.DS_Store
vendored
Normal file
BIN
TestNinja/.DS_Store
vendored
Normal file
Binary file not shown.
20
TestNinja/TestNinja.UnitTests/Properties/AssemblyInfo.cs
Normal file
20
TestNinja/TestNinja.UnitTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("TestNinja.UnitTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestNinja.UnitTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("d077ad2c-59bc-41b1-8dba-99113b1ff8a9")]
|
||||
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
76
TestNinja/TestNinja.UnitTests/TestNinja.UnitTests.csproj
Normal file
76
TestNinja/TestNinja.UnitTests/TestNinja.UnitTests.csproj
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit.3.11.0\build\NUnit.props')" />
|
||||
<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>{D077AD2C-59BC-41B1-8DBA-99113B1FF8A9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TestNinja.UnitTests</RootNamespace>
|
||||
<AssemblyName>TestNinja.UnitTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</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=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="UnitTests\DemeritPointsCalculatorTests.cs" />
|
||||
<Compile Include="UnitTests\FizzBuzzTests.cs" />
|
||||
<Compile Include="UnitTests\CustomerControllerTests.cs" />
|
||||
<Compile Include="UnitTests\ErrorLoggerTests.cs" />
|
||||
<Compile Include="UnitTests\HtmlFormatterTests.cs" />
|
||||
<Compile Include="UnitTests\MathTests.cs" />
|
||||
<Compile Include="UnitTests\ReservationTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UnitTests\StackTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TestNinja\TestNinja.csproj">
|
||||
<Project>{7328740E-4B78-464F-8352-65D887F2145F}</Project>
|
||||
<Name>TestNinja</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit.3.11.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@ -0,0 +1,27 @@
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using NUnit.Framework;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class CustomerControllerTests
|
||||
{
|
||||
private CustomerController _customerController;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_customerController = new CustomerController();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetCustomer_IfIdIsGreaterThenZero_ReturnOk()
|
||||
{
|
||||
var result = _customerController.GetCustomer(4);
|
||||
Assert.That(result, Is.InstanceOf<ActionResult>());
|
||||
Assert.That(result, Is.TypeOf<Ok>());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class DemeritPointsCalculatorTests
|
||||
{
|
||||
private DemeritPointsCalculator _demeritPointsCalculator;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_demeritPointsCalculator = new DemeritPointsCalculator();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateDemeritPoints_SpeedIsNegative_ThrowArgumentOutOfRangeException()
|
||||
{
|
||||
Assert.That(() => _demeritPointsCalculator.CalculateDemeritPoints(-9),
|
||||
Throws.Exception.TypeOf<ArgumentOutOfRangeException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateDemeritPoints_SpeedIsGreaterThenMaxSpeed_ThrowArgumentOutOfRangeException()
|
||||
{
|
||||
Assert.That(() => _demeritPointsCalculator.CalculateDemeritPoints(350),
|
||||
Throws.Exception.TypeOf<ArgumentOutOfRangeException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(2)]
|
||||
[TestCase(30)]
|
||||
[TestCase(64)]
|
||||
[TestCase(65)]
|
||||
public void CalculateDemeritPoints_SpeedIsLessOrEqualSpeedLimit_ReturnZero(int speed)
|
||||
{
|
||||
var result = _demeritPointsCalculator.CalculateDemeritPoints(speed);
|
||||
Assert.That(result, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(66, 0)]
|
||||
[TestCase(70, 1)]
|
||||
[TestCase(80, 3)]
|
||||
public void CalculateDemeritPoints_SpeedIsOverSpeedLimit_ReturnDemeritPoints(int speed, int expectedResult)
|
||||
{
|
||||
var result = _demeritPointsCalculator.CalculateDemeritPoints(speed);
|
||||
Assert.That(result, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
44
TestNinja/TestNinja.UnitTests/UnitTests/ErrorLoggerTests.cs
Normal file
44
TestNinja/TestNinja.UnitTests/UnitTests/ErrorLoggerTests.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class ErrorLoggerTests
|
||||
{
|
||||
[Test]
|
||||
public void Log_WhenCalled_SetTheLastErrorProperty()
|
||||
{
|
||||
var errorLogger = new ErrorLogger();
|
||||
|
||||
errorLogger.Log("some error");
|
||||
|
||||
Assert.That(errorLogger.LastError, Is.EqualTo("some error"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(null)]
|
||||
[TestCase("")]
|
||||
[TestCase(" ")]
|
||||
public void Log_InvalidError_ThrowArgumentNullException(string error)
|
||||
{
|
||||
var logger = new ErrorLogger();
|
||||
Assert.That(() => logger.Log(error), Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Log_ValidError_RaiseErrorLoggedEvent()
|
||||
{
|
||||
var logger = new ErrorLogger();
|
||||
|
||||
var id = Guid.Empty;
|
||||
logger.ErrorLogged += (sender, args) => { id = args; };
|
||||
|
||||
logger.Log("a");
|
||||
|
||||
Assert.That(id, Is.Not.EqualTo(Guid.Empty));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
44
TestNinja/TestNinja.UnitTests/UnitTests/FizzBuzzTests.cs
Normal file
44
TestNinja/TestNinja.UnitTests/UnitTests/FizzBuzzTests.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using NUnit.Framework;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class FizzBuzzTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void GetOutput_DivisibleBy5And3_ReturnFizzBuzzString()
|
||||
{
|
||||
var result = FizzBuzz.GetOutput(15);
|
||||
|
||||
Assert.That(result, Is.EqualTo("FizzBuzz"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetOutput_DivisibleBy3Only_ReturnFizzString()
|
||||
{
|
||||
var result = FizzBuzz.GetOutput(3);
|
||||
|
||||
Assert.That(result, Is.EqualTo("Fizz"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetOutput_DivisibleBy5Only_ReturnBuzzString()
|
||||
{
|
||||
var result = FizzBuzz.GetOutput(5);
|
||||
|
||||
Assert.That(result, Is.EqualTo("Buzz"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetOutput_NotDivisibleBy5And3_ReturnNumberAsString()
|
||||
{
|
||||
var result = FizzBuzz.GetOutput(4);
|
||||
|
||||
Assert.That(result, Is.EqualTo("4"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class HtmlFormatterTests
|
||||
{
|
||||
[Test]
|
||||
public void FormatAsBold_WhenCalled_ShouldEncloseTheStringWithStrongElement()
|
||||
{
|
||||
var formatter = new HtmlFormatter();
|
||||
|
||||
var result = formatter.FormatAsBold("abc");
|
||||
|
||||
//specific assertion
|
||||
Assert.That(result, Is.EqualTo("<strong>abc</strong>").IgnoreCase);
|
||||
|
||||
//more general
|
||||
Assert.That(result, Does.StartWith("<strong>"));
|
||||
Assert.That(result, Does.EndWith("</strong>"));
|
||||
Assert.That(result, Does.Contain("abc"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
74
TestNinja/TestNinja.UnitTests/UnitTests/MathTests.cs
Normal file
74
TestNinja/TestNinja.UnitTests/UnitTests/MathTests.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using NUnit.Framework;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class MathTests
|
||||
{
|
||||
private Math _math;
|
||||
|
||||
// SetUp - before tests
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_math = new Math();
|
||||
}
|
||||
// TearDown - after tests
|
||||
|
||||
|
||||
[Test]
|
||||
[TestCase(1,2,3)]
|
||||
[TestCase(0, 0, 0)]
|
||||
[TestCase(10,20,30)]
|
||||
public void Add_WhenCalled_ReturnTheSUmOfArguments(int first, int second, int expectedResult)
|
||||
{
|
||||
var result = _math.Add(first, second);
|
||||
|
||||
Assert.That(result, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Because I wanted to!")]
|
||||
public void Max_FirstArgumentIsGreater_ReturnTheFirstArgument()
|
||||
{
|
||||
var result = _math.Max(5, 2);
|
||||
Assert.That(result, Is.EqualTo(5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Max_SecondArgumentIsGreater_ReturnTheSecondArgument()
|
||||
{
|
||||
var result = _math.Max(5, 15);
|
||||
Assert.That(result, Is.EqualTo(15));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Max_ArgumentsAreEqual_ReturnTheSameArgumentArgument()
|
||||
{
|
||||
var result = _math.Max(10, 10);
|
||||
Assert.That(result, Is.EqualTo(10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetOddNumbers_limitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
|
||||
{
|
||||
var result = _math.GetOddNumbers(5);
|
||||
|
||||
Assert.That(result, Is.Not.Empty);
|
||||
Assert.That(result.Count(), Is.EqualTo(3));
|
||||
Assert.That(result, Does.Contain(1));
|
||||
Assert.That(result, Does.Contain(3));
|
||||
Assert.That(result, Does.Contain(5));
|
||||
|
||||
Assert.That(result, Is.EquivalentTo(new [] {1, 3, 5}));
|
||||
|
||||
Assert.That(result, Is.Ordered);
|
||||
Assert.That(result, Is.Unique);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
65
TestNinja/TestNinja.UnitTests/UnitTests/ReservationTests.cs
Normal file
65
TestNinja/TestNinja.UnitTests/UnitTests/ReservationTests.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using NUnit.Framework;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ReservationTests
|
||||
{
|
||||
[Test]
|
||||
public void CanBeCancelledBy_AdminCancelling_ReturnsTrue()
|
||||
{
|
||||
//Arrange
|
||||
var reservation = new Reservation();
|
||||
|
||||
//Act
|
||||
var result = reservation.CanBeCancelledBy(new User { IsAdmin = true });
|
||||
|
||||
//Assert
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanBeCancelledBy_AdminCancelling_ReturnsFalse()
|
||||
{
|
||||
//Arrange
|
||||
var reservation = new Reservation();
|
||||
|
||||
//Act
|
||||
var result = reservation.CanBeCancelledBy(
|
||||
new User { IsAdmin = false });
|
||||
|
||||
//Assert
|
||||
Assert.IsFalse(result);
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanBeCancelledBy_SameUserCancellingTheReservation_ReturnTrue()
|
||||
{
|
||||
var user = new User();
|
||||
var reservation = new Reservation
|
||||
{
|
||||
MadeBy = user
|
||||
};
|
||||
|
||||
var result = reservation.CanBeCancelledBy(user);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanBeCancelledBy_AnotherUserCancellingTheReservation_ReturnFalse()
|
||||
{
|
||||
var user = new User();
|
||||
var reservation = new Reservation
|
||||
{
|
||||
MadeBy = user
|
||||
};
|
||||
|
||||
var result = reservation.CanBeCancelledBy(new User());
|
||||
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
85
TestNinja/TestNinja.UnitTests/UnitTests/StackTests.cs
Normal file
85
TestNinja/TestNinja.UnitTests/UnitTests/StackTests.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using TestNinja.Fundamentals;
|
||||
|
||||
namespace TestNinja.UnitTests.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
class StackTests
|
||||
{
|
||||
[Test]
|
||||
public void Push_PassNull_ThrowArgumentNullException()
|
||||
{
|
||||
var stack = new Stack<object>();
|
||||
Assert.That(() => stack.Push(null), Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Push_PassObject_StackIsNotEmpty()
|
||||
{
|
||||
var stack = new Stack<object>();
|
||||
stack.Push(new object());
|
||||
Assert.That(stack.Count, Is.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Count_EmptyStack_ReturnZero()
|
||||
{
|
||||
var stack = new Stack<object>();
|
||||
Assert.That(stack.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pop_EmptyStack_ThrowInvalidOperationException()
|
||||
{
|
||||
var stack = new Stack<object>();
|
||||
Assert.That(() => stack.Pop(), Throws.InvalidOperationException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pop_StackNotEmpty_ReturnTopElement()
|
||||
{
|
||||
var stack = new Stack<string>();
|
||||
stack.Push("dog");
|
||||
stack.Push("mouse");
|
||||
stack.Push("cat");
|
||||
|
||||
var result = stack.Pop();
|
||||
|
||||
Assert.That(result, Is.EqualTo("cat"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pop_StackNotEmpty_RemoveTopElement()
|
||||
{
|
||||
var stack = new Stack<string>();
|
||||
stack.Push("dog");
|
||||
stack.Push("mouse");
|
||||
stack.Push("cat");
|
||||
|
||||
stack.Pop();
|
||||
var result = stack.Peek();
|
||||
|
||||
Assert.That(stack.Count, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Peek_EmptyStack_ThrowInvalidOperationException()
|
||||
{
|
||||
var stack = new Stack<string>();
|
||||
Assert.That(() => stack.Peek(), Throws.InvalidOperationException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Peek_NotEmptyStack_ReturnElementAtTheTop()
|
||||
{
|
||||
var stack = new Stack<string>();
|
||||
|
||||
stack.Push("dog");
|
||||
var result = stack.Peek();
|
||||
|
||||
Assert.That(result, Is.EqualTo("dog"));
|
||||
}
|
||||
}
|
||||
}
|
||||
4
TestNinja/TestNinja.UnitTests/packages.config
Normal file
4
TestNinja/TestNinja.UnitTests/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.11.0" targetFramework="net461" />
|
||||
</packages>
|
||||
22
TestNinja/TestNinja.sln
Normal file
22
TestNinja/TestNinja.sln
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.0.0
|
||||
MinimumVisualStudioVersion = 10.0.0.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestNinja", "TestNinja/TestNinja.csproj", "{7328740E-4B78-464F-8352-65D887F2145F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
TestNinja/TestNinja/.DS_Store
vendored
Normal file
BIN
TestNinja/TestNinja/.DS_Store
vendored
Normal file
Binary file not shown.
6
TestNinja/TestNinja/App.config
Normal file
6
TestNinja/TestNinja/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
</configSections>
|
||||
</configuration>
|
||||
19
TestNinja/TestNinja/Fundamentals/CustomerController.cs
Normal file
19
TestNinja/TestNinja/Fundamentals/CustomerController.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class CustomerController
|
||||
{
|
||||
public ActionResult GetCustomer(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
return new NotFound();
|
||||
|
||||
return new Ok();
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionResult { }
|
||||
|
||||
public class NotFound : ActionResult { }
|
||||
|
||||
public class Ok : ActionResult { }
|
||||
}
|
||||
12
TestNinja/TestNinja/Fundamentals/DateHelper.cs
Normal file
12
TestNinja/TestNinja/Fundamentals/DateHelper.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class DateHelper
|
||||
{
|
||||
public static DateTime FirstOfNextMonth(DateTime date)
|
||||
{
|
||||
return date.Month == 12 ? new DateTime(date.Year + 1, 1, 1) : new DateTime(date.Year, date.Month + 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
TestNinja/TestNinja/Fundamentals/DemeritPointsCalculator.cs
Normal file
23
TestNinja/TestNinja/Fundamentals/DemeritPointsCalculator.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class DemeritPointsCalculator
|
||||
{
|
||||
private const int SpeedLimit = 65;
|
||||
private const int MaxSpeed = 300;
|
||||
|
||||
public int CalculateDemeritPoints(int speed)
|
||||
{
|
||||
if (speed < 0 || speed > MaxSpeed)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
if (speed <= SpeedLimit) return 0;
|
||||
|
||||
const int kmPerDemeritPoint = 5;
|
||||
var demeritPoints = (speed - SpeedLimit)/kmPerDemeritPoint;
|
||||
|
||||
return demeritPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
TestNinja/TestNinja/Fundamentals/ErrorLogger.cs
Normal file
25
TestNinja/TestNinja/Fundamentals/ErrorLogger.cs
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class ErrorLogger
|
||||
{
|
||||
public string LastError { get; set; }
|
||||
|
||||
public event EventHandler<Guid> ErrorLogged;
|
||||
|
||||
public void Log(string error)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(error))
|
||||
throw new ArgumentNullException();
|
||||
|
||||
LastError = error;
|
||||
|
||||
// Write the log to a storage
|
||||
// ...
|
||||
|
||||
ErrorLogged?.Invoke(this, Guid.NewGuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
19
TestNinja/TestNinja/Fundamentals/FizzBuzz.cs
Normal file
19
TestNinja/TestNinja/Fundamentals/FizzBuzz.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class FizzBuzz
|
||||
{
|
||||
public static string GetOutput(int number)
|
||||
{
|
||||
if ((number % 3 == 0) && (number % 5 == 0))
|
||||
return "FizzBuzz";
|
||||
|
||||
if (number % 3 == 0)
|
||||
return "Fizz";
|
||||
|
||||
if (number % 5 == 0)
|
||||
return "Buzz";
|
||||
|
||||
return number.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
TestNinja/TestNinja/Fundamentals/HtmlFormatter.cs
Normal file
10
TestNinja/TestNinja/Fundamentals/HtmlFormatter.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class HtmlFormatter
|
||||
{
|
||||
public string FormatAsBold(string content)
|
||||
{
|
||||
return $"<strong>{content}</strong>";
|
||||
}
|
||||
}
|
||||
}
|
||||
24
TestNinja/TestNinja/Fundamentals/Math.cs
Normal file
24
TestNinja/TestNinja/Fundamentals/Math.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class Math
|
||||
{
|
||||
public int Add(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public int Max(int a, int b)
|
||||
{
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetOddNumbers(int limit)
|
||||
{
|
||||
for (var i = 0; i <= limit; i++)
|
||||
if (i % 2 != 0)
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
TestNinja/TestNinja/Fundamentals/PhoneNumber.cs
Normal file
38
TestNinja/TestNinja/Fundamentals/PhoneNumber.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class PhoneNumber
|
||||
{
|
||||
public string Area { get; }
|
||||
public string Major { get; }
|
||||
public string Minor { get; }
|
||||
|
||||
private PhoneNumber(string area, string major, string minor)
|
||||
{
|
||||
Area = area;
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
}
|
||||
|
||||
public static PhoneNumber Parse(string number)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(number))
|
||||
throw new ArgumentException("Phone number cannot be blank.");
|
||||
|
||||
if (number.Length != 10)
|
||||
throw new ArgumentException("Phone number should be 10 digits long.");
|
||||
|
||||
var area = number.Substring(0, 3);
|
||||
var major = number.Substring(3, 3);
|
||||
var minor = number.Substring(6);
|
||||
|
||||
return new PhoneNumber(area, major, minor);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format($"({Area}){Major}-{Minor}");
|
||||
}
|
||||
}
|
||||
}
|
||||
29
TestNinja/TestNinja/Fundamentals/PowersOf2.cs
Normal file
29
TestNinja/TestNinja/Fundamentals/PowersOf2.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace TestNinja
|
||||
{
|
||||
public class PowersOf2
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
// Display powers of 2 up to the exponent of 8:
|
||||
foreach (int i in Power(2, 8))
|
||||
{
|
||||
Console.Write("{0} ", i);
|
||||
}
|
||||
}
|
||||
|
||||
public static System.Collections.Generic.IEnumerable<int> Power(int number, int exponent)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
for (int i = 0; i < exponent; i++)
|
||||
{
|
||||
result = result * number;
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Output: 2 4 8 16 32 64 128 256
|
||||
}
|
||||
}
|
||||
18
TestNinja/TestNinja/Fundamentals/Reservation.cs
Normal file
18
TestNinja/TestNinja/Fundamentals/Reservation.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class Reservation
|
||||
{
|
||||
public User MadeBy { get; set; }
|
||||
|
||||
public bool CanBeCancelledBy(User user)
|
||||
{
|
||||
return (user.IsAdmin || MadeBy == user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class User
|
||||
{
|
||||
public bool IsAdmin { get; set; }
|
||||
}
|
||||
}
|
||||
40
TestNinja/TestNinja/Fundamentals/Stack.cs
Normal file
40
TestNinja/TestNinja/Fundamentals/Stack.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TestNinja.Fundamentals
|
||||
{
|
||||
public class Stack<T>
|
||||
{
|
||||
private readonly List<T> _list = new List<T>();
|
||||
|
||||
public int Count => _list.Count;
|
||||
|
||||
public void Push(T obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
_list.Add(obj);
|
||||
}
|
||||
|
||||
public T Pop()
|
||||
{
|
||||
if (_list.Count == 0)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
var result = _list[_list.Count - 1];
|
||||
_list.RemoveAt(_list.Count - 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public T Peek()
|
||||
{
|
||||
if (_list.Count == 0)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
return _list[_list.Count - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
TestNinja/TestNinja/Mocking/.DS_Store
vendored
Normal file
BIN
TestNinja/TestNinja/Mocking/.DS_Store
vendored
Normal file
Binary file not shown.
48
TestNinja/TestNinja/Mocking/BookingHelper.cs
Normal file
48
TestNinja/TestNinja/Mocking/BookingHelper.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public static class BookingHelper
|
||||
{
|
||||
public static string OverlappingBookingsExist(Booking booking)
|
||||
{
|
||||
if (booking.Status == "Cancelled")
|
||||
return string.Empty;
|
||||
|
||||
var unitOfWork = new UnitOfWork();
|
||||
var bookings =
|
||||
unitOfWork.Query<Booking>()
|
||||
.Where(
|
||||
b => b.Id != booking.Id && b.Status != "Cancelled");
|
||||
|
||||
var overlappingBooking =
|
||||
bookings.FirstOrDefault(
|
||||
b =>
|
||||
booking.ArrivalDate >= b.ArrivalDate
|
||||
&& booking.ArrivalDate < b.DepartureDate
|
||||
|| booking.DepartureDate > b.ArrivalDate
|
||||
&& booking.DepartureDate <= b.DepartureDate);
|
||||
|
||||
return overlappingBooking == null ? string.Empty : overlappingBooking.Reference;
|
||||
}
|
||||
}
|
||||
|
||||
public class UnitOfWork
|
||||
{
|
||||
public IQueryable<T> Query<T>()
|
||||
{
|
||||
return new List<T>().AsQueryable();
|
||||
}
|
||||
}
|
||||
|
||||
public class Booking
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public int Id { get; set; }
|
||||
public DateTime ArrivalDate { get; set; }
|
||||
public DateTime DepartureDate { get; set; }
|
||||
public string Reference { get; set; }
|
||||
}
|
||||
}
|
||||
44
TestNinja/TestNinja/Mocking/EmployeeController.cs
Normal file
44
TestNinja/TestNinja/Mocking/EmployeeController.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Data.Entity;
|
||||
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public class EmployeeController
|
||||
{
|
||||
private EmployeeContext _db;
|
||||
|
||||
public EmployeeController()
|
||||
{
|
||||
_db = new EmployeeContext();
|
||||
}
|
||||
|
||||
public ActionResult DeleteEmployee(int id)
|
||||
{
|
||||
var employee = _db.Employees.Find(id);
|
||||
_db.Employees.Remove(employee);
|
||||
_db.SaveChanges();
|
||||
return RedirectToAction("Employees");
|
||||
}
|
||||
|
||||
private ActionResult RedirectToAction(string employees)
|
||||
{
|
||||
return new RedirectResult();
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionResult { }
|
||||
|
||||
public class RedirectResult : ActionResult { }
|
||||
|
||||
public class EmployeeContext
|
||||
{
|
||||
public DbSet<Employee> Employees { get; set; }
|
||||
|
||||
public void SaveChanges()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class Employee
|
||||
{
|
||||
}
|
||||
}
|
||||
165
TestNinja/TestNinja/Mocking/HousekeeperHelper.cs
Normal file
165
TestNinja/TestNinja/Mocking/HousekeeperHelper.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public static class HousekeeperHelper
|
||||
{
|
||||
private static readonly UnitOfWork UnitOfWork = new UnitOfWork();
|
||||
|
||||
public static bool SendStatementEmails(DateTime statementDate)
|
||||
{
|
||||
var housekeepers = UnitOfWork.Query<Housekeeper>();
|
||||
|
||||
foreach (var housekeeper in housekeepers)
|
||||
{
|
||||
if (housekeeper.Email == null)
|
||||
continue;
|
||||
|
||||
var statementFilename = SaveStatement(housekeeper.Oid, housekeeper.FullName, statementDate);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(statementFilename))
|
||||
continue;
|
||||
|
||||
var emailAddress = housekeeper.Email;
|
||||
var emailBody = housekeeper.StatementEmailBody;
|
||||
|
||||
try
|
||||
{
|
||||
EmailFile(emailAddress, emailBody, statementFilename,
|
||||
string.Format("Sandpiper Statement {0:yyyy-MM} {1}", statementDate, housekeeper.FullName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
XtraMessageBox.Show(e.Message, string.Format("Email failure: {0}", emailAddress),
|
||||
MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string SaveStatement(int housekeeperOid, string housekeeperName, DateTime statementDate)
|
||||
{
|
||||
var report = new HousekeeperStatementReport(housekeeperOid, statementDate);
|
||||
|
||||
if (!report.HasData)
|
||||
return string.Empty;
|
||||
|
||||
report.CreateDocument();
|
||||
|
||||
var filename = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
|
||||
string.Format("Sandpiper Statement {0:yyyy-MM} {1}.pdf", statementDate, housekeeperName));
|
||||
|
||||
report.ExportToPdf(filename);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
private static void EmailFile(string emailAddress, string emailBody, string filename, string subject)
|
||||
{
|
||||
var client = new SmtpClient(SystemSettingsHelper.EmailSmtpHost)
|
||||
{
|
||||
Port = SystemSettingsHelper.EmailPort,
|
||||
Credentials =
|
||||
new NetworkCredential(
|
||||
SystemSettingsHelper.EmailUsername,
|
||||
SystemSettingsHelper.EmailPassword)
|
||||
};
|
||||
|
||||
var from = new MailAddress(SystemSettingsHelper.EmailFromEmail, SystemSettingsHelper.EmailFromName,
|
||||
Encoding.UTF8);
|
||||
var to = new MailAddress(emailAddress);
|
||||
|
||||
var message = new MailMessage(from, to)
|
||||
{
|
||||
Subject = subject,
|
||||
SubjectEncoding = Encoding.UTF8,
|
||||
Body = emailBody,
|
||||
BodyEncoding = Encoding.UTF8
|
||||
};
|
||||
|
||||
message.Attachments.Add(new Attachment(filename));
|
||||
client.Send(message);
|
||||
message.Dispose();
|
||||
|
||||
File.Delete(filename);
|
||||
}
|
||||
}
|
||||
|
||||
public enum MessageBoxButtons
|
||||
{
|
||||
OK
|
||||
}
|
||||
|
||||
public class XtraMessageBox
|
||||
{
|
||||
public static void Show(string s, string housekeeperStatements, MessageBoxButtons ok)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class MainForm
|
||||
{
|
||||
public bool HousekeeperStatementsSending { get; set; }
|
||||
}
|
||||
|
||||
public class DateForm
|
||||
{
|
||||
public DateForm(string statementDate, object endOfLastMonth)
|
||||
{
|
||||
}
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public DialogResult ShowDialog()
|
||||
{
|
||||
return DialogResult.Abort;
|
||||
}
|
||||
}
|
||||
|
||||
public enum DialogResult
|
||||
{
|
||||
Abort,
|
||||
OK
|
||||
}
|
||||
|
||||
public class SystemSettingsHelper
|
||||
{
|
||||
public static string EmailSmtpHost { get; set; }
|
||||
public static int EmailPort { get; set; }
|
||||
public static string EmailUsername { get; set; }
|
||||
public static string EmailPassword { get; set; }
|
||||
public static string EmailFromEmail { get; set; }
|
||||
public static string EmailFromName { get; set; }
|
||||
}
|
||||
|
||||
public class Housekeeper
|
||||
{
|
||||
public string Email { get; set; }
|
||||
public int Oid { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string StatementEmailBody { get; set; }
|
||||
}
|
||||
|
||||
public class HousekeeperStatementReport
|
||||
{
|
||||
public HousekeeperStatementReport(int housekeeperOid, DateTime statementDate)
|
||||
{
|
||||
}
|
||||
|
||||
public bool HasData { get; set; }
|
||||
|
||||
public void CreateDocument()
|
||||
{
|
||||
}
|
||||
|
||||
public void ExportToPdf(string filename)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
28
TestNinja/TestNinja/Mocking/InstallerHelper.cs
Normal file
28
TestNinja/TestNinja/Mocking/InstallerHelper.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Net;
|
||||
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public class InstallerHelper
|
||||
{
|
||||
private string _setupDestinationFile;
|
||||
|
||||
public bool DownloadInstaller(string customerName, string installerName)
|
||||
{
|
||||
var client = new WebClient();
|
||||
try
|
||||
{
|
||||
client.DownloadFile(
|
||||
string.Format("http://example.com/{0}/{1}",
|
||||
customerName,
|
||||
installerName),
|
||||
_setupDestinationFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (WebException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
TestNinja/TestNinja/Mocking/OrderService.cs
Normal file
30
TestNinja/TestNinja/Mocking/OrderService.cs
Normal file
@ -0,0 +1,30 @@
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public class OrderService
|
||||
{
|
||||
private readonly IStorage _storage;
|
||||
|
||||
public OrderService(IStorage storage)
|
||||
{
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public int PlaceOrder(Order order)
|
||||
{
|
||||
var orderId = _storage.Store(order);
|
||||
|
||||
// Some other work
|
||||
|
||||
return orderId;
|
||||
}
|
||||
}
|
||||
|
||||
public class Order
|
||||
{
|
||||
}
|
||||
|
||||
public interface IStorage
|
||||
{
|
||||
int Store(object obj);
|
||||
}
|
||||
}
|
||||
20
TestNinja/TestNinja/Mocking/Product.cs
Normal file
20
TestNinja/TestNinja/Mocking/Product.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public float ListPrice { get; set; }
|
||||
|
||||
public float GetPrice(Customer customer)
|
||||
{
|
||||
if (customer.IsGold)
|
||||
return ListPrice * 0.7f;
|
||||
|
||||
return ListPrice;
|
||||
}
|
||||
}
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public bool IsGold { get; set; }
|
||||
}
|
||||
}
|
||||
51
TestNinja/TestNinja/Mocking/VideoService.cs
Normal file
51
TestNinja/TestNinja/Mocking/VideoService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TestNinja.Mocking
|
||||
{
|
||||
public class VideoService
|
||||
{
|
||||
public string ReadVideoTitle()
|
||||
{
|
||||
var str = File.ReadAllText("video.txt");
|
||||
var video = JsonConvert.DeserializeObject<Video>(str);
|
||||
if (video == null)
|
||||
return "Error parsing the video.";
|
||||
return video.Title;
|
||||
}
|
||||
|
||||
public string GetUnprocessedVideosAsCsv()
|
||||
{
|
||||
var videoIds = new List<int>();
|
||||
|
||||
using (var context = new VideoContext())
|
||||
{
|
||||
var videos =
|
||||
(from video in context.Videos
|
||||
where !video.IsProcessed
|
||||
select video).ToList();
|
||||
|
||||
foreach (var v in videos)
|
||||
videoIds.Add(v.Id);
|
||||
|
||||
return String.Join(",", videoIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Video
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public bool IsProcessed { get; set; }
|
||||
}
|
||||
|
||||
public class VideoContext : DbContext
|
||||
{
|
||||
public DbSet<Video> Videos { get; set; }
|
||||
}
|
||||
}
|
||||
36
TestNinja/TestNinja/Properties/AssemblyInfo.cs
Normal file
36
TestNinja/TestNinja/Properties/AssemblyInfo.cs
Normal file
@ -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("TestNinja")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestNinja")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[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("7328740E-4B78-464F-8352-65D887F2145F")]
|
||||
|
||||
// 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")]
|
||||
97
TestNinja/TestNinja/TestNinja.csproj
Normal file
97
TestNinja/TestNinja/TestNinja.csproj
Normal file
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props')" />
|
||||
<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>{7328740E-4B78-464F-8352-65D887F2145F}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TestNinja</RootNamespace>
|
||||
<AssemblyName>TestNinja</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<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' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0-beta1\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0-beta1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Fundamentals\CustomerController.cs" />
|
||||
<Compile Include="Fundamentals\DateHelper.cs" />
|
||||
<Compile Include="Fundamentals\DemeritPointsCalculator.cs" />
|
||||
<Compile Include="Fundamentals\ErrorLogger.cs" />
|
||||
<Compile Include="Fundamentals\FizzBuzz.cs" />
|
||||
<Compile Include="Fundamentals\HtmlFormatter.cs" />
|
||||
<Compile Include="Fundamentals\Math.cs" />
|
||||
<Compile Include="Fundamentals\PhoneNumber.cs" />
|
||||
<Compile Include="Fundamentals\Reservation.cs" />
|
||||
<Compile Include="Fundamentals\Stack.cs" />
|
||||
<Compile Include="Mocking\BookingHelper.cs" />
|
||||
<Compile Include="Mocking\EmployeeController.cs" />
|
||||
<Compile Include="Mocking\InstallerHelper.cs" />
|
||||
<Compile Include="Mocking\OrderService.cs" />
|
||||
<Compile Include="Mocking\Product.cs" />
|
||||
<Compile Include="Mocking\VideoService.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\GildedRose-Refactoring-Kata\csharp\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props'))" />
|
||||
</Target>
|
||||
<!-- 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>
|
||||
7
TestNinja/TestNinja/packages.config
Normal file
7
TestNinja/TestNinja/packages.config
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.2.0-beta1" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
|
||||
<package id="NUnit" version="3.8.1" targetFramework="net45" />
|
||||
<package id="NUnit3TestAdapter" version="3.8.0" targetFramework="net45" />
|
||||
</packages>
|
||||
20
csharp.UnitTests/Properties/AssemblyInfo.cs
Normal file
20
csharp.UnitTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("csharp.UnitTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("csharp.UnitTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("531d0543-af42-46d4-9f07-cb76addcff27")]
|
||||
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
30
csharp.UnitTests/Tests/ApprovalTest.cs
Normal file
30
csharp.UnitTests/Tests/ApprovalTest.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace csharp.UnitTests.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ApprovalTest
|
||||
{
|
||||
[Test]
|
||||
public void ThirtyDays()
|
||||
{
|
||||
var lines = File.ReadAllLines("ThirtyDays.txt");
|
||||
|
||||
StringBuilder fakeoutput = new StringBuilder();
|
||||
Console.SetOut(new StringWriter(fakeoutput));
|
||||
Console.SetIn(new StringReader("a\n"));
|
||||
|
||||
Program.Main(new string[] { });
|
||||
String output = fakeoutput.ToString();
|
||||
|
||||
var outputLines = output.Split('\n');
|
||||
for(var i = 0; i<Math.Min(lines.Length, outputLines.Length); i++)
|
||||
{
|
||||
Assert.AreEqual(lines[i], outputLines[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
187
csharp.UnitTests/Tests/GildedRoseTest.cs
Normal file
187
csharp.UnitTests/Tests/GildedRoseTest.cs
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* REQUIREMENTS
|
||||
*
|
||||
*Pretty simple, right? Well this is where it gets interesting:
|
||||
|
||||
V - Once the sell by date has passed, Quality degrades twice as fast
|
||||
V - The Quality of an item is never negative
|
||||
V - "Aged Brie" actually increases in Quality the older it gets
|
||||
V - The Quality of an item is never more than 50
|
||||
V - "Sulfuras", being a legendary item, never has to be sold or decreases in Quality
|
||||
V - "Backstage passes", like aged brie, increases in Quality as its SellIn value approaches;
|
||||
Quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less but
|
||||
Quality drops to 0 after the concert
|
||||
|
||||
We have recently signed a supplier of conjured items. This requires an update to our system:
|
||||
|
||||
V - "Conjured" items degrade in Quality twice as fast as normal items
|
||||
*
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace csharp.UnitTests.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class GildedRoseTest
|
||||
{
|
||||
[Test]
|
||||
// [MethodName]_[Scenario]_[ExpectedResult]
|
||||
public void UpdateQuality_CreateOneItem_NameIsNotChanged()
|
||||
{
|
||||
// Arrange
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Bread", SellIn = 0, Quality = 0 } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Bread", items[0].Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateQuality_CreateItemWithQualityZero_QualityIsNeverNegative()
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Bread", SellIn = 0, Quality = 0 } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateQuality_SellByDateHasPassed_QualityDegradesTwiceAsFast()
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Bread", SellIn = 0, Quality = 10 } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(8));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(0, 0, 2)]
|
||||
[TestCase(1, 1, 2)]
|
||||
public void UpdateQuality_AgedBrieGetsOlder_AgedBrieIncreasesInQuality(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Aged Brie", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(5, 50, 50)]
|
||||
[TestCase(-5, 50, 50)]
|
||||
[TestCase(-5, 49, 50)]
|
||||
public void UpdateQuality_AgedBrieGetsOlder_AgedBrieIncreasesInQualityMaxUpTo50(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Aged Brie", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(5, 5, 5)]
|
||||
[TestCase(-5, -5, -5)]
|
||||
[TestCase(0, 0, 0)]
|
||||
public void UpdateQuality_SulfurasIsNeverSold_SellInStaysTheSame(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].SellIn, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(5, 5, 5)]
|
||||
[TestCase(-5, -5, -5)]
|
||||
[TestCase(0, 0, 0)]
|
||||
public void UpdateQuality_SulfurasNeverDecreasesInQuality_QualityInStaysTheSame(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(20, 50, 50)]
|
||||
[TestCase(10, 50, 50)]
|
||||
[TestCase(5, 50, 50)]
|
||||
[TestCase(-10, 50, 0)]
|
||||
[TestCase(20, 40, 41)]
|
||||
public void UpdateQuality_BackstagePassesGetsOlder_BackstagePassesIncreasesInQualityMaxUpTo50(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(10, 40, 42)]
|
||||
public void UpdateQuality_BackstagePassesLessThen10SellIn_QualityIncreasesBy2(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(5, 40, 43)]
|
||||
public void UpdateQuality_BackstagePassesLessThen5SellIn_QualityIncreasesBy2(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
|
||||
[TestCase(0, 25, 0)]
|
||||
[TestCase(0, 50, 0)]
|
||||
public void UpdateQuality_BackstagePassesConcertEnds_QualityDropsToZero(int sellIn, int quality, int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(-1, 20, 18)]
|
||||
public void UpdateQuality_ConjuredGetsOlder_ConjuredQualityDegradesTwoTimesFaster(int sellIn, int quality,
|
||||
int expectedResult)
|
||||
{
|
||||
IList<Item> items = new List<Item> { new Item { Name = "Conjured Mana Cake", SellIn = sellIn, Quality = quality } };
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
gildedRose.UpdateQuality();
|
||||
|
||||
Assert.That(items[0].Quality, Is.EqualTo(expectedResult));
|
||||
}
|
||||
}
|
||||
}
|
||||
70
csharp.UnitTests/csharp.UnitTests.csproj
Normal file
70
csharp.UnitTests/csharp.UnitTests.csproj
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\csharp\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\csharp\packages\NUnit.3.11.0\build\NUnit.props')" />
|
||||
<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>{531D0543-AF42-46D4-9F07-CB76ADDCFF27}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>csharp.UnitTests</RootNamespace>
|
||||
<AssemblyName>csharp.UnitTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</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=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\csharp\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Tests\ApprovalTest.cs" />
|
||||
<Compile Include="Tests\GildedRoseTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\csharp\csharp.csproj">
|
||||
<Project>{176C0214-9136-4079-8DAB-11D7420C3881}</Project>
|
||||
<Name>csharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\csharp\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\csharp\packages\NUnit.3.11.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
4
csharp.UnitTests/packages.config
Normal file
4
csharp.UnitTests/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.11.0" targetFramework="net461" />
|
||||
</packages>
|
||||
@ -4,82 +4,83 @@ namespace csharp
|
||||
{
|
||||
public class GildedRose
|
||||
{
|
||||
IList<Item> Items;
|
||||
public GildedRose(IList<Item> Items)
|
||||
private IList<Item> _items;
|
||||
|
||||
public GildedRose(IList<Item> items)
|
||||
{
|
||||
this.Items = Items;
|
||||
_items = items;
|
||||
}
|
||||
|
||||
public void UpdateQuality()
|
||||
{
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
for (var i = 0; i < _items.Count; i++)
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (_items[i].Name != "Aged Brie" && _items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
if (_items[i].Quality > 0)
|
||||
{
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
_items[i].Quality = _items[i].Quality - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
if (_items[i].Quality < 50)
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
|
||||
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (_items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (Items[i].SellIn < 11)
|
||||
if (_items[i].SellIn < 11)
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
if (_items[i].Quality < 50)
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Items[i].SellIn < 6)
|
||||
if (_items[i].SellIn < 6)
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
if (_items[i].Quality < 50)
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].SellIn = Items[i].SellIn - 1;
|
||||
_items[i].SellIn = _items[i].SellIn - 1;
|
||||
}
|
||||
|
||||
if (Items[i].SellIn < 0)
|
||||
if (_items[i].SellIn < 0)
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie")
|
||||
if (_items[i].Name != "Aged Brie")
|
||||
{
|
||||
if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (_items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
if (_items[i].Quality > 0)
|
||||
{
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
_items[i].Quality = _items[i].Quality - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality - Items[i].Quality;
|
||||
_items[i].Quality = _items[i].Quality - _items[i].Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
if (_items[i].Quality < 50)
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name + ", " + this.SellIn + ", " + this.Quality;
|
||||
return Name + ", " + SellIn + ", " + Quality;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,28 @@ namespace csharp
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("OMGHAI!");
|
||||
IList<Item> items = CreateItems();
|
||||
|
||||
IList<Item> Items = new List<Item>{
|
||||
var gildedRose = new GildedRose(items);
|
||||
|
||||
for (var i = 0; i < 31; i++)
|
||||
{
|
||||
Console.WriteLine("-------- day " + i + " --------");
|
||||
Console.WriteLine("name, sellIn, quality");
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
|
||||
Console.WriteLine("");
|
||||
gildedRose.UpdateQuality();
|
||||
}
|
||||
}
|
||||
|
||||
private static IList<Item> CreateItems()
|
||||
{
|
||||
IList<Item> items = new List<Item>{
|
||||
new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
|
||||
new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
|
||||
new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
|
||||
@ -36,21 +56,7 @@ namespace csharp
|
||||
// this conjured item does not work properly yet
|
||||
new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
|
||||
};
|
||||
|
||||
var app = new GildedRose(Items);
|
||||
|
||||
|
||||
for (var i = 0; i < 31; i++)
|
||||
{
|
||||
Console.WriteLine("-------- day " + i + " --------");
|
||||
Console.WriteLine("name, sellIn, quality");
|
||||
for (var j = 0; j < Items.Count; j++)
|
||||
{
|
||||
System.Console.WriteLine(Items[j]);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
app.UpdateQuality();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,12 @@
|
||||
<HintPath>packages\ApprovalUtilities.3.0.13\lib\net45\ApprovalUtilities.Net45.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
@ -61,9 +67,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApprovalTest.cs" />
|
||||
<Compile Include="GildedRose.cs" />
|
||||
<Compile Include="GildedRoseTest.cs" />
|
||||
<Compile Include="Item.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28010.2048
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp", "csharp.csproj", "{176C0214-9136-4079-8DAB-11D7420C3881}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestNinja", "..\..\source-code-starter\TestNinja\TestNinja\TestNinja.csproj", "{7328740E-4B78-464F-8352-65D887F2145F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestNinja.UnitTests", "..\..\source-code-starter\TestNinja\TestNinja.UnitTests\TestNinja.UnitTests.csproj", "{D077AD2C-59BC-41B1-8DBA-99113B1FF8A9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.UnitTests", "..\csharp.UnitTests\csharp.UnitTests.csproj", "{531D0543-AF42-46D4-9F07-CB76ADDCFF27}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,8 +21,23 @@ Global
|
||||
{176C0214-9136-4079-8DAB-11D7420C3881}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{176C0214-9136-4079-8DAB-11D7420C3881}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{176C0214-9136-4079-8DAB-11D7420C3881}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7328740E-4B78-464F-8352-65D887F2145F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D077AD2C-59BC-41B1-8DBA-99113B1FF8A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D077AD2C-59BC-41B1-8DBA-99113B1FF8A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D077AD2C-59BC-41B1-8DBA-99113B1FF8A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D077AD2C-59BC-41B1-8DBA-99113B1FF8A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{531D0543-AF42-46D4-9F07-CB76ADDCFF27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{531D0543-AF42-46D4-9F07-CB76ADDCFF27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{531D0543-AF42-46D4-9F07-CB76ADDCFF27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{531D0543-AF42-46D4-9F07-CB76ADDCFF27}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BF9390A7-B220-4AFE-8AF5-852245DF875F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<packages>
|
||||
<package id="ApprovalTests" version="3.0.13" targetFramework="net452" />
|
||||
<package id="ApprovalUtilities" version="3.0.13" targetFramework="net452" />
|
||||
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net452" />
|
||||
<package id="NUnit" version="3.9.0" targetFramework="net452" />
|
||||
<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net452" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue
Block a user