From 7239471e1f2aaba493b4ff535cddd32993ee91aa Mon Sep 17 00:00:00 2001 From: Edgar Mengel Date: Thu, 21 May 2020 12:43:32 +0200 Subject: [PATCH] Make ready Berlin Clock with Unit tests --- .gitignore | 188 ++++++++++++++++++ BDD/BerlinClockFeatureSteps.cs | 41 ++-- BerlinClock.csproj | 9 +- BerlinClock.sln | 13 +- .../BerlinClockNUnitTest.csproj | 19 ++ .../BerlinClockTimeConverterTests.cs | 174 ++++++++++++++++ .../BerlinClockCharViewFormatTests.cs | 50 +++++ .../Utils/StringHelperTests.cs | 99 +++++++++ Classes/BerlinClockTimeConverter.cs | 121 +++++++++++ .../ViewFormats/BerlinClockCharViewFormat.cs | 63 ++++++ Classes/ITimeConverter.cs | 12 -- Classes/TimeConverter.cs | 15 -- Classes/Utils/StringHelper.cs | 60 ++++++ Interfaces/Clock/BerlinClockModel.cs | 53 +++++ .../ViewFormats/IBerlinClockViewFormat.cs | 15 ++ Interfaces/ITimeConverter.cs | 7 + Readme.md | 1 + 17 files changed, 888 insertions(+), 52 deletions(-) create mode 100644 .gitignore create mode 100644 BerlinClockNUnitTest/BerlinClockNUnitTest.csproj create mode 100644 BerlinClockNUnitTest/BerlinClockTimeConverterTests.cs create mode 100644 BerlinClockNUnitTest/Clock/ViewFormats/BerlinClockCharViewFormatTests.cs create mode 100644 BerlinClockNUnitTest/Utils/StringHelperTests.cs create mode 100644 Classes/BerlinClockTimeConverter.cs create mode 100644 Classes/Clock/ViewFormats/BerlinClockCharViewFormat.cs delete mode 100644 Classes/ITimeConverter.cs delete mode 100644 Classes/TimeConverter.cs create mode 100644 Classes/Utils/StringHelper.cs create mode 100644 Interfaces/Clock/BerlinClockModel.cs create mode 100644 Interfaces/Clock/ViewFormats/IBerlinClockViewFormat.cs create mode 100644 Interfaces/ITimeConverter.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7966e092 --- /dev/null +++ b/.gitignore @@ -0,0 +1,188 @@ +## Ignore Visual Studio and Rider temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates +launchSettings.json + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ +.vs/ +tools +!tools/packages.config + +# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets +!packages/*/build/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# 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 +*.Publish.xml + +# NuGet Packages Directory +packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Rider specific folder +\.idea/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# 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 + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# ========================= +# NUnit Specific +# ========================= + +.~ +*.userprefs +*.StyleCop +*.sdf +GeneratedAssemblyInfo.cs +StyleCop.Cache +local.settings.include +InternalTrace.txt +TestResult.xml +testCaseCollection.xml +deploy +lib +test-results +package +images +MockAssemblyResult.xml +PortabilityAnalysis*.html +project.lock.json +*.project.lock.json +.dotnet +.config/dotnet-tools.json diff --git a/BDD/BerlinClockFeatureSteps.cs b/BDD/BerlinClockFeatureSteps.cs index 4390f3cb..2b852eba 100644 --- a/BDD/BerlinClockFeatureSteps.cs +++ b/BDD/BerlinClockFeatureSteps.cs @@ -1,28 +1,27 @@ -using System; -using TechTalk.SpecFlow; +using BerlinClock.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Linq; +using TechTalk.SpecFlow; namespace BerlinClock { - [Binding] - public class TheBerlinClockSteps - { - private ITimeConverter berlinClock = new TimeConverter(); - private String theTime; + [Binding] + public class TheBerlinClockSteps + { + private ITimeConverter berlinClock = new BerlinClockTimeConverter(); + private string theTime; + + + [When(@"the time is ""(.*)""")] + public void WhenTheTimeIs(string time) + { + this.theTime = time; + } - - [When(@"the time is ""(.*)""")] - public void WhenTheTimeIs(string time) - { - theTime = time; - } - - [Then(@"the clock should look like")] - public void ThenTheClockShouldLookLike(string theExpectedBerlinClockOutput) - { - Assert.AreEqual(berlinClock.convertTime(theTime), theExpectedBerlinClockOutput); - } + [Then(@"the clock should look like")] + public void ThenTheClockShouldLookLike(string theExpectedBerlinClockOutput) + { + Assert.AreEqual(this.berlinClock.ConvertTime(this.theTime), theExpectedBerlinClockOutput); + } - } + } } diff --git a/BerlinClock.csproj b/BerlinClock.csproj index ac8af99d..ad503c7f 100644 --- a/BerlinClock.csproj +++ b/BerlinClock.csproj @@ -50,14 +50,18 @@ + + + + True True BerlinClockFeatureSteps.feature - - + + @@ -70,6 +74,7 @@ +