From ef01430d2565633f425e1d71c27f5174c8400b53 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Mon, 5 Mar 2018 17:21:49 -0600 Subject: [PATCH 01/74] inital commit --- .gitignore | 320 ++++++++++++++++++ .../Accessors.DatabaseAccessors.csproj | 64 ++++ Accessors.DatabaseAccessors/App.config | 17 + .../DatabaseAccessorLoader.cs | 18 + .../FriendAssemblies.cs | 5 + .../Properties/AssemblyInfo.cs | 36 ++ .../TodoItemAccessor.cs | 16 + .../TodoListAccessor.cs | 17 + Accessors.DatabaseAccessors/packages.config | 5 + .../App.config | 17 + .../FriendAssemblies.cs | 5 + .../LazyManagerLoader.cs | 18 + .../ListExploreationManager.cs | 32 ++ ...anagers.LazyCollectionOfAllManagers.csproj | 70 ++++ .../Properties/AssemblyInfo.cs | 36 ++ .../TodoCRUDManager.cs | 42 +++ .../packages.config | 5 + .../Properties/AssemblyInfo.cs | 36 ++ .../Shared.DataContracts.csproj | 50 +++ Shared.DataContracts/TodoItem.cs | 16 + Shared.DataContracts/TodoList.cs | 13 + Shared.DataContracts/User.cs | 16 + Shared.DataContracts/UserAccountStats.cs | 15 + Shared.DatabaseContext/App.config | 17 + Shared.DatabaseContext/DBOs/TodoItemDBO.cs | 25 ++ Shared.DatabaseContext/DBOs/TodoListDBO.cs | 20 ++ Shared.DatabaseContext/DBOs/UserDBO.cs | 20 ++ .../201803052220061_Init.Designer.cs | 29 ++ .../Migrations/201803052220061_Init.cs | 58 ++++ .../Migrations/201803052220061_Init.resx | 126 +++++++ .../Migrations/Configuration.cs | 23 ++ .../Properties/AssemblyInfo.cs | 36 ++ .../Shared.DatabaseContext.csproj | 71 ++++ Shared.DatabaseContext/TodoContext.cs | 21 ++ Shared.DatabaseContext/packages.config | 4 + TestingExemplar.sln | 68 ++++ Tests.AccessorTests/AccessorTestBase.cs | 32 ++ Tests.AccessorTests/App.config | 17 + .../Properties/AssemblyInfo.cs | 20 ++ .../Tests.AccessorTests.csproj | 90 +++++ Tests.AccessorTests/UnitTest1.cs | 14 + Tests.AccessorTests/packages.config | 7 + Tests.DataPrep/App.config | 17 + Tests.DataPrep/DataPrep.cs | 16 + Tests.DataPrep/Properties/AssemblyInfo.cs | 36 ++ Tests.DataPrep/Tests.DataPrep.csproj | 61 ++++ Tests.DataPrep/TodoItemPrep.cs | 12 + Tests.DataPrep/TodoListPrep.cs | 12 + Tests.DataPrep/UserPrep.cs | 12 + Tests.DataPrep/packages.config | 4 + Tests.ManagerTests/App.config | 17 + .../ListExplorationManagerTests.cs | 92 +++++ Tests.ManagerTests/ManagerTestBase.cs | 26 ++ Tests.ManagerTests/Properties/AssemblyInfo.cs | 20 ++ Tests.ManagerTests/Tests.ManagerTests.csproj | 98 ++++++ Tests.ManagerTests/TodoCRUDManagerTests.cs | 86 +++++ Tests.ManagerTests/packages.config | 7 + 57 files changed, 2083 insertions(+) create mode 100644 .gitignore create mode 100644 Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj create mode 100644 Accessors.DatabaseAccessors/App.config create mode 100644 Accessors.DatabaseAccessors/DatabaseAccessorLoader.cs create mode 100644 Accessors.DatabaseAccessors/FriendAssemblies.cs create mode 100644 Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs create mode 100644 Accessors.DatabaseAccessors/TodoItemAccessor.cs create mode 100644 Accessors.DatabaseAccessors/TodoListAccessor.cs create mode 100644 Accessors.DatabaseAccessors/packages.config create mode 100644 Managers.LazyCollectionOfAllManagers/App.config create mode 100644 Managers.LazyCollectionOfAllManagers/FriendAssemblies.cs create mode 100644 Managers.LazyCollectionOfAllManagers/LazyManagerLoader.cs create mode 100644 Managers.LazyCollectionOfAllManagers/ListExploreationManager.cs create mode 100644 Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj create mode 100644 Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs create mode 100644 Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs create mode 100644 Managers.LazyCollectionOfAllManagers/packages.config create mode 100644 Shared.DataContracts/Properties/AssemblyInfo.cs create mode 100644 Shared.DataContracts/Shared.DataContracts.csproj create mode 100644 Shared.DataContracts/TodoItem.cs create mode 100644 Shared.DataContracts/TodoList.cs create mode 100644 Shared.DataContracts/User.cs create mode 100644 Shared.DataContracts/UserAccountStats.cs create mode 100644 Shared.DatabaseContext/App.config create mode 100644 Shared.DatabaseContext/DBOs/TodoItemDBO.cs create mode 100644 Shared.DatabaseContext/DBOs/TodoListDBO.cs create mode 100644 Shared.DatabaseContext/DBOs/UserDBO.cs create mode 100644 Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs create mode 100644 Shared.DatabaseContext/Migrations/201803052220061_Init.cs create mode 100644 Shared.DatabaseContext/Migrations/201803052220061_Init.resx create mode 100644 Shared.DatabaseContext/Migrations/Configuration.cs create mode 100644 Shared.DatabaseContext/Properties/AssemblyInfo.cs create mode 100644 Shared.DatabaseContext/Shared.DatabaseContext.csproj create mode 100644 Shared.DatabaseContext/TodoContext.cs create mode 100644 Shared.DatabaseContext/packages.config create mode 100644 TestingExemplar.sln create mode 100644 Tests.AccessorTests/AccessorTestBase.cs create mode 100644 Tests.AccessorTests/App.config create mode 100644 Tests.AccessorTests/Properties/AssemblyInfo.cs create mode 100644 Tests.AccessorTests/Tests.AccessorTests.csproj create mode 100644 Tests.AccessorTests/UnitTest1.cs create mode 100644 Tests.AccessorTests/packages.config create mode 100644 Tests.DataPrep/App.config create mode 100644 Tests.DataPrep/DataPrep.cs create mode 100644 Tests.DataPrep/Properties/AssemblyInfo.cs create mode 100644 Tests.DataPrep/Tests.DataPrep.csproj create mode 100644 Tests.DataPrep/TodoItemPrep.cs create mode 100644 Tests.DataPrep/TodoListPrep.cs create mode 100644 Tests.DataPrep/UserPrep.cs create mode 100644 Tests.DataPrep/packages.config create mode 100644 Tests.ManagerTests/App.config create mode 100644 Tests.ManagerTests/ListExplorationManagerTests.cs create mode 100644 Tests.ManagerTests/ManagerTestBase.cs create mode 100644 Tests.ManagerTests/Properties/AssemblyInfo.cs create mode 100644 Tests.ManagerTests/Tests.ManagerTests.csproj create mode 100644 Tests.ManagerTests/TodoCRUDManagerTests.cs create mode 100644 Tests.ManagerTests/packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62113a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,320 @@ +## 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 +*.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/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.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/ + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# 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 +.cr/ + +# 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 diff --git a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj new file mode 100644 index 0000000..504cb68 --- /dev/null +++ b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {AF26B020-F939-4353-A41D-F6C0F87D0B81} + Library + Properties + Accessors.DatabaseAccessors + Accessors.DatabaseAccessors + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Accessors.DatabaseAccessors/App.config b/Accessors.DatabaseAccessors/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Accessors.DatabaseAccessors/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Accessors.DatabaseAccessors/DatabaseAccessorLoader.cs b/Accessors.DatabaseAccessors/DatabaseAccessorLoader.cs new file mode 100644 index 0000000..6864d11 --- /dev/null +++ b/Accessors.DatabaseAccessors/DatabaseAccessorLoader.cs @@ -0,0 +1,18 @@ +using Ninject.Modules; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Accessors.DatabaseAccessors +{ + public class DatabaseAccessorLoader : NinjectModule + { + public override void Load() + { + Bind().To(); + Bind().To(); + } + } +} diff --git a/Accessors.DatabaseAccessors/FriendAssemblies.cs b/Accessors.DatabaseAccessors/FriendAssemblies.cs new file mode 100644 index 0000000..2038dbb --- /dev/null +++ b/Accessors.DatabaseAccessors/FriendAssemblies.cs @@ -0,0 +1,5 @@ + +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Tests.AccessorTests")] +namespace Accessors.DatabaseAccessors +{ +} diff --git a/Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs b/Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..72f0383 --- /dev/null +++ b/Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs @@ -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("Accessors.DatabaseAccessors")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Accessors.DatabaseAccessors")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("af26b020-f939-4353-a41d-f6c0f87d0b81")] + +// 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")] diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs new file mode 100644 index 0000000..08246e9 --- /dev/null +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Accessors.DatabaseAccessors +{ + public interface ITodoItemAccessor + { + + } + class TodoItemAccessor: ITodoItemAccessor + { + } +} diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs new file mode 100644 index 0000000..3943f20 --- /dev/null +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Accessors.DatabaseAccessors +{ + public interface ITodoListAccessor + { + + } + + class TodoListAccessor : ITodoListAccessor + { + } +} diff --git a/Accessors.DatabaseAccessors/packages.config b/Accessors.DatabaseAccessors/packages.config new file mode 100644 index 0000000..4400cc5 --- /dev/null +++ b/Accessors.DatabaseAccessors/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/App.config b/Managers.LazyCollectionOfAllManagers/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/FriendAssemblies.cs b/Managers.LazyCollectionOfAllManagers/FriendAssemblies.cs new file mode 100644 index 0000000..2c9812e --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/FriendAssemblies.cs @@ -0,0 +1,5 @@ + +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Tests.ManagerTests")] +namespace Managers.LazyCollectionOfAllManagers +{ +} diff --git a/Managers.LazyCollectionOfAllManagers/LazyManagerLoader.cs b/Managers.LazyCollectionOfAllManagers/LazyManagerLoader.cs new file mode 100644 index 0000000..f35764d --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/LazyManagerLoader.cs @@ -0,0 +1,18 @@ +using Ninject.Modules; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Managers.LazyCollectionOfAllManagers +{ + public class LazyManagerLoader : NinjectModule + { + public override void Load() + { + Bind().To(); + Bind().To(); + } + } +} diff --git a/Managers.LazyCollectionOfAllManagers/ListExploreationManager.cs b/Managers.LazyCollectionOfAllManagers/ListExploreationManager.cs new file mode 100644 index 0000000..c1f4dc3 --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/ListExploreationManager.cs @@ -0,0 +1,32 @@ +using Shared.DataContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Managers.LazyCollectionOfAllManagers +{ + public interface IListExplorationManager + { + UserAccountStats GetUserStats(Guid userId); + + IEnumerable GetUserLists(Guid userId); + + } + + + + internal class ListExplorationManager : IListExplorationManager + { + public IEnumerable GetUserLists(Guid userId) + { + throw new NotImplementedException(); + } + + public UserAccountStats GetUserStats(Guid userId) + { + throw new NotImplementedException(); + } + } +} diff --git a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj new file mode 100644 index 0000000..bfa80f1 --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {20052ECB-4E1D-4F2F-9F06-79111FE381F8} + Library + Properties + Managers.LazyCollectionOfAllManagers + Managers.LazyCollectionOfAllManagers + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + + + + + + + + + + + + + + + + + + + + + + + + + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + Shared.DataContracts + + + + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs b/Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f726028 --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs @@ -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("Managers.LazyCollectionOfAllManagers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Managers.LazyCollectionOfAllManagers")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("20052ecb-4e1d-4f2f-9f06-79111fe381f8")] + +// 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")] diff --git a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs new file mode 100644 index 0000000..2a09558 --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs @@ -0,0 +1,42 @@ +using Shared.DataContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Managers.LazyCollectionOfAllManagers +{ + public interface ITodoCRUDManager + { + void GetTodoList(Guid id); + + IEnumerable GetTodoItems(Guid listId); + + void SaveTodoItem(); + + void SaveTodoList(); + } + internal class TodoCRUDManager : ITodoCRUDManager + { + public IEnumerable GetTodoItems(Guid listId) + { + throw new NotImplementedException(); + } + + public void GetTodoList(Guid id) + { + throw new NotImplementedException(); + } + + public void SaveTodoItem() + { + throw new NotImplementedException(); + } + + public void SaveTodoList() + { + throw new NotImplementedException(); + } + } +} diff --git a/Managers.LazyCollectionOfAllManagers/packages.config b/Managers.LazyCollectionOfAllManagers/packages.config new file mode 100644 index 0000000..4400cc5 --- /dev/null +++ b/Managers.LazyCollectionOfAllManagers/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Shared.DataContracts/Properties/AssemblyInfo.cs b/Shared.DataContracts/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f2ae5e9 --- /dev/null +++ b/Shared.DataContracts/Properties/AssemblyInfo.cs @@ -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("Shared.DataContracts")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Shared.DataContracts")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("49f40a81-dbbc-4904-96e3-e5ef1f7d2a7b")] + +// 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")] diff --git a/Shared.DataContracts/Shared.DataContracts.csproj b/Shared.DataContracts/Shared.DataContracts.csproj new file mode 100644 index 0000000..afdeae2 --- /dev/null +++ b/Shared.DataContracts/Shared.DataContracts.csproj @@ -0,0 +1,50 @@ + + + + + Debug + AnyCPU + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + Library + Properties + Shared.DataContracts + Shared.DataContracts + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shared.DataContracts/TodoItem.cs b/Shared.DataContracts/TodoItem.cs new file mode 100644 index 0000000..a03bd80 --- /dev/null +++ b/Shared.DataContracts/TodoItem.cs @@ -0,0 +1,16 @@ +using System; + +namespace Shared.DataContracts +{ + public class TodoItem + { + public Guid Id { get; set; } + + public string Description { get; set; } + + public bool IsComplete { get; set; } + + public bool IsActive { get; set; } + + } +} diff --git a/Shared.DataContracts/TodoList.cs b/Shared.DataContracts/TodoList.cs new file mode 100644 index 0000000..89b9d93 --- /dev/null +++ b/Shared.DataContracts/TodoList.cs @@ -0,0 +1,13 @@ +using System; + +namespace Shared.DataContracts +{ + public class TodoList + { + public Guid Id { get; set; } + + public Guid UserId { get; set; } + + public string Title { get; set; } + } +} diff --git a/Shared.DataContracts/User.cs b/Shared.DataContracts/User.cs new file mode 100644 index 0000000..1bb3810 --- /dev/null +++ b/Shared.DataContracts/User.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DataContracts +{ + public class User + { + public Guid Id { get; set; } + + public string Name { get; set; } + + } +} diff --git a/Shared.DataContracts/UserAccountStats.cs b/Shared.DataContracts/UserAccountStats.cs new file mode 100644 index 0000000..19458c1 --- /dev/null +++ b/Shared.DataContracts/UserAccountStats.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DataContracts +{ + public class UserAccountStats + { + public int TodoListCount { get; set; } + + public int UncompletedItems { get; set; } + } +} diff --git a/Shared.DatabaseContext/App.config b/Shared.DatabaseContext/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Shared.DatabaseContext/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Shared.DatabaseContext/DBOs/TodoItemDBO.cs b/Shared.DatabaseContext/DBOs/TodoItemDBO.cs new file mode 100644 index 0000000..901e29a --- /dev/null +++ b/Shared.DatabaseContext/DBOs/TodoItemDBO.cs @@ -0,0 +1,25 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Shared.DatabaseContext.DBOs +{ + [Table("TodoItems")] + public class TodoItemDBO + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Guid Id { get; set; } + + public Guid TodoListId { get; set; } + + public string Description { get; set; } + + public bool IsComplete { get; set; } + + public bool IsActive { get; set; } + + [ForeignKey("TodoListId")] + public TodoListDBO TodoList { get; set; } + + } +} diff --git a/Shared.DatabaseContext/DBOs/TodoListDBO.cs b/Shared.DatabaseContext/DBOs/TodoListDBO.cs new file mode 100644 index 0000000..072f5bc --- /dev/null +++ b/Shared.DatabaseContext/DBOs/TodoListDBO.cs @@ -0,0 +1,20 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Shared.DatabaseContext.DBOs +{ + [Table("TodoLists")] + public class TodoListDBO + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Guid Id { get; set; } + + public Guid UserId { get; set; } + + public string Title { get; set; } + + [ForeignKey("UserId")] + public UserDBO User { get; set; } + } +} diff --git a/Shared.DatabaseContext/DBOs/UserDBO.cs b/Shared.DatabaseContext/DBOs/UserDBO.cs new file mode 100644 index 0000000..5fe6327 --- /dev/null +++ b/Shared.DatabaseContext/DBOs/UserDBO.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DatabaseContext.DBOs +{ + [Table("Users")] + public class UserDBO + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Guid Id { get; set; } + + public string Name { get; set; } + + } +} diff --git a/Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs b/Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs new file mode 100644 index 0000000..d03f666 --- /dev/null +++ b/Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs @@ -0,0 +1,29 @@ +// +namespace Shared.DatabaseContext.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] + public sealed partial class Init : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(Init)); + + string IMigrationMetadata.Id + { + get { return "201803052220061_Init"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/Shared.DatabaseContext/Migrations/201803052220061_Init.cs b/Shared.DatabaseContext/Migrations/201803052220061_Init.cs new file mode 100644 index 0000000..667f59a --- /dev/null +++ b/Shared.DatabaseContext/Migrations/201803052220061_Init.cs @@ -0,0 +1,58 @@ +namespace Shared.DatabaseContext.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class Init : DbMigration + { + public override void Up() + { + CreateTable( + "dbo.TodoItems", + c => new + { + Id = c.Guid(nullable: false, identity: true), + TodoListId = c.Guid(nullable: false), + Description = c.String(), + IsComplete = c.Boolean(nullable: false), + IsActive = c.Boolean(nullable: false), + }) + .PrimaryKey(t => t.Id) + .ForeignKey("dbo.TodoLists", t => t.TodoListId, cascadeDelete: true) + .Index(t => t.TodoListId); + + CreateTable( + "dbo.TodoLists", + c => new + { + Id = c.Guid(nullable: false, identity: true), + UserId = c.Guid(nullable: false), + Title = c.String(), + }) + .PrimaryKey(t => t.Id) + .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true) + .Index(t => t.UserId); + + CreateTable( + "dbo.Users", + c => new + { + Id = c.Guid(nullable: false, identity: true), + Name = c.String(), + }) + .PrimaryKey(t => t.Id); + + } + + public override void Down() + { + DropForeignKey("dbo.TodoItems", "TodoListId", "dbo.TodoLists"); + DropForeignKey("dbo.TodoLists", "UserId", "dbo.Users"); + DropIndex("dbo.TodoLists", new[] { "UserId" }); + DropIndex("dbo.TodoItems", new[] { "TodoListId" }); + DropTable("dbo.Users"); + DropTable("dbo.TodoLists"); + DropTable("dbo.TodoItems"); + } + } +} diff --git a/Shared.DatabaseContext/Migrations/201803052220061_Init.resx b/Shared.DatabaseContext/Migrations/201803052220061_Init.resx new file mode 100644 index 0000000..6b563d1 --- /dev/null +++ b/Shared.DatabaseContext/Migrations/201803052220061_Init.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1a3W7bNhS+H7B3EHS1DamVtDddYLdInKQwlsRBnBa7C2jp2CFGkapIBTaGPdku9kh7hR3qz/qjJf/EyIqiQJFQ5MfDcz4eHn7Mv3//0/+48Jn1DKGkgg/sk96xbQF3hUf5fGBHavbmvf3xw48/9C89f2F9yfq90/1wJJcD+0mp4NRxpPsEPpE9n7qhkGKmeq7wHeIJ5+3x8a/OyYkDCGEjlmX17yOuqA/xL/jrUHAXAhURdiM8YDJtxy+TGNW6JT7IgLgwsCdPJASvd0EUmRIJOFTBQtnWGaMErZkAm9kW4VwootDW088SJioUfD4JsIGwh2UA2G9GmIR0Daer7l2Xc/xWL8dZDcyg3Egq4W8IePIu9Y9THb6Vl+3cf+jBS/S0WupVx14c2A/CEyMF/sX52Laq850OWaj7mvzcw1GyV4A4spo7HuVkQU7pf0fWMGIqCmHAIVIhYUfWXTRl1P0Nlg/iD+ADHjFWNB2Nx2+lBmy6C0UAoVrewyxd0MizLac8zqkOzIcVxiTr/BRR/PkW5yZTBjkxCi6ZKBHCJ+AQEgXeHVEKQq4hIHZtbfLKVNpZ11Sq1inXw1yAdEMaJKRIQ6RC3Ka2dUMW18Dn6mlg44+2dUUX4GUtKfhnTnFX4yAVRq1zjeRQ+AEDBdlU50IwIHxjq0fyzFX0eXOcW/JM57H/De60rXtgcQf5RINk4xeJ+bjqeBUK/16wMvfz748TEYWutlCs6fRAwjmospl9Z7W5WrecRtlxy6UQ37dcG+sw54c7brcHqhjsf6MZaa1NNlI6Dfxj0qlM5+K3RiqXOuxEY42wA4XT4d/p28Y9/f+eqWeK8ZmUwqWx1fVclfCtbOol96w28iWGV8iLS8Bo0gDjh3YM7F9qXlgDndG2AJ2TsQx7YlfDP+YXoI8yS59EuiAbEukSr7430UVeuQUZA6GOGWFIUokcpFzV6UW5SwPCWoyvjOtITG1XPkP1ywUEwDWpWkLSZeosZ9anz2epuKvNO32nwK520tXO7XXsMB/iZfLlhe5m5DMe/924/TpIaFrEgYhoClGX6Ys18wEImeRGfQ7hCAgLRuTXy9qRh/slPfVkmnCrhNKYE1AVikvbWqXiJqbWiFnH0a4x4eSUbMHR+70JI8+rlfEF19WNWRUnhW6mAqYazw5HSm58af01ZnQ4QQpIqQeqG7C80I5OqF86mh2xPsl1T3MVh6TEanGIMat1ce8ax2TFRb6BVvqNkwg4mdDjGJSe/g0JAqxzCspP2mJNEtln+GayuRbiJxiOKxskkdzafCas2sgcKl9xarT0ioZIprRgta2h59e6FdOFYetlM1UzQj1s2abMRuifk1GGCruYQuoZNoW5wvX5OkvHBWoDhxpHxzIcYSRsqIiHgkU+N58Z5tHFFF9EWZf6zWgldaQIV/rQHa+ogJTWWGjfBC1TQcpYWWsdqe9UQlY7BGscqdURZdJ1pmSy+/dEyew02o6SxtEvQ8msBC4imMpiM0qqHJQ4nTS9mjAnJ98eQpwVC5uH1zjyZUKbXKmL45OWA4ekdlJWu+Sz5ydm5WTsp6dU+0NJ7dhKutgWuuaZevrImiwlJv04qr3JVzZkFNe76nBDOJ2BVInYYuOp+r7yzvJ63jwcKT3W/eHj4KJRxOnXCGisAM2orpRbRaJNFcvaO0N9ztotZoT3qMXA/jPGOLVGvz+uYI6scYgsOLWOrb/28VzBn0noYh75ySeLn4uA2z1JTKna+TmiHWMrjf8bZFdZUt+KWQnETqwqqfIb8GljifsbjGBRVd6D63ZQjnOJ4cBybqM8sL1evZUwZ66YXlIN/gYV4A3D94JEypW7bbXnXZ8ZDqzo/n8U3Lpy002jjaO2XqVNiumB7U0FBj5JnkYlzijimifKv5omahbpmlTe5knyL00TNEujh5CAKwaX7oodBd9GPbNJ0n5VUu+GxpuzkEHWexE5t34ZxT1c+Ns+TCOSzlcQ+i/9OLil3Zv3GfGZyBJJxaKsS6WkuQFFPNzaZyEWTcRV+NkFKeMH8y+ERdjl0p+CN+LjSAWRwiWDP2WlB3idjNbNH2vWZZv74/heI/exBDST4hJgzM8jyrzc7quGq4gBQme5tE7UsVS6Xpwvc6RbwTsCpe7Lk/MD4I0LweSYT4i+NG1uG27da5gTd5lpCmaQ9kCU3d6/oGQeEl+mGKvx+Cty2PMXH/4DywD0+eIqAAA= + + + dbo + + \ No newline at end of file diff --git a/Shared.DatabaseContext/Migrations/Configuration.cs b/Shared.DatabaseContext/Migrations/Configuration.cs new file mode 100644 index 0000000..001f361 --- /dev/null +++ b/Shared.DatabaseContext/Migrations/Configuration.cs @@ -0,0 +1,23 @@ +namespace Shared.DatabaseContext.Migrations +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Migrations; + using System.Linq; + + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = false; + } + + protected override void Seed(Shared.DatabaseContext.TodoContext context) + { + // This method will be called after migrating to the latest version. + + // You can use the DbSet.AddOrUpdate() helper extension method + // to avoid creating duplicate seed data. + } + } +} diff --git a/Shared.DatabaseContext/Properties/AssemblyInfo.cs b/Shared.DatabaseContext/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f501ccb --- /dev/null +++ b/Shared.DatabaseContext/Properties/AssemblyInfo.cs @@ -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("Shared.DatabaseContext")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Shared.DatabaseContext")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("6886bd35-1655-456b-a4c2-6b57bd557254")] + +// 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")] diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj new file mode 100644 index 0000000..05a1190 --- /dev/null +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {6886BD35-1655-456B-A4C2-6B57BD557254} + Library + Properties + Shared.DatabaseContext + Shared.DatabaseContext + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + 201803052220061_Init.cs + + + + + + + + + + + + + + + 201803052220061_Init.cs + + + + \ No newline at end of file diff --git a/Shared.DatabaseContext/TodoContext.cs b/Shared.DatabaseContext/TodoContext.cs new file mode 100644 index 0000000..43789a6 --- /dev/null +++ b/Shared.DatabaseContext/TodoContext.cs @@ -0,0 +1,21 @@ +using Shared.DatabaseContext.DBOs; +using System; +using System.Collections.Generic; +using System.Data.Entity; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DatabaseContext +{ + public class TodoContext : DbContext + { + public DbSet Users { get; set; } + public DbSet TodoItems { get; set; } + public DbSet TodoLists { get; set; } + + public TodoContext() + { + } + } +} diff --git a/Shared.DatabaseContext/packages.config b/Shared.DatabaseContext/packages.config new file mode 100644 index 0000000..b3daf0d --- /dev/null +++ b/Shared.DatabaseContext/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln new file mode 100644 index 0000000..f5f17d9 --- /dev/null +++ b/TestingExemplar.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2027 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managers.LazyCollectionOfAllManagers", "Managers.LazyCollectionOfAllManagers\Managers.LazyCollectionOfAllManagers.csproj", "{20052ECB-4E1D-4F2F-9F06-79111FE381F8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DataContracts", "Shared.DataContracts\Shared.DataContracts.csproj", "{49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DatabaseContext", "Shared.DatabaseContext\Shared.DatabaseContext.csproj", "{6886BD35-1655-456B-A4C2-6B57BD557254}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.DataPrep", "Tests.DataPrep\Tests.DataPrep.csproj", "{458ED4A8-E0F2-4089-94CB-20B0EFDD4B46}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.ManagerTests", "Tests.ManagerTests\Tests.ManagerTests.csproj", "{7D0BA0FB-FA51-4964-9E41-7D03BFF47A94}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.AccessorTests", "Tests.AccessorTests\Tests.AccessorTests.csproj", "{802F9C0A-9FC5-444B-BD3B-AED8B6F148A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accessors.DatabaseAccessors", "Accessors.DatabaseAccessors\Accessors.DatabaseAccessors.csproj", "{AF26B020-F939-4353-A41D-F6C0F87D0B81}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3B08858C-6FD1-47E7-824C-0B3F1D234455}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Release|Any CPU.Build.0 = Release|Any CPU + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Release|Any CPU.Build.0 = Release|Any CPU + {6886BD35-1655-456B-A4C2-6B57BD557254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6886BD35-1655-456B-A4C2-6B57BD557254}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6886BD35-1655-456B-A4C2-6B57BD557254}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6886BD35-1655-456B-A4C2-6B57BD557254}.Release|Any CPU.Build.0 = Release|Any CPU + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46}.Release|Any CPU.Build.0 = Release|Any CPU + {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94}.Release|Any CPU.Build.0 = Release|Any CPU + {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8}.Release|Any CPU.Build.0 = Release|Any CPU + {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} + {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} + {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} + EndGlobalSection +EndGlobal diff --git a/Tests.AccessorTests/AccessorTestBase.cs b/Tests.AccessorTests/AccessorTestBase.cs new file mode 100644 index 0000000..6850d88 --- /dev/null +++ b/Tests.AccessorTests/AccessorTestBase.cs @@ -0,0 +1,32 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Shared.DatabaseContext; +using System.Transactions; +using Tests.DataPrep; + +namespace Tests.AccessorTests +{ + public abstract class AccessorTestBase + { + protected TodoDataPrep dataPrep = new TodoDataPrep(true); + + protected TransactionScope _transactionScope; + [TestInitialize] + public virtual void TestInitialize() + { + TodoContext database = new TodoContext(); + database.Database.CreateIfNotExists(); + // transactionScope causes db changes to be rolled back at end of test + _transactionScope = new TransactionScope(); + + OnInitialize(); + } + + public abstract void OnInitialize(); + + [TestCleanup] + public virtual void TestCleanup() + { + _transactionScope.Dispose(); + } + } +} diff --git a/Tests.AccessorTests/App.config b/Tests.AccessorTests/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Tests.AccessorTests/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.AccessorTests/Properties/AssemblyInfo.cs b/Tests.AccessorTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1d7654d --- /dev/null +++ b/Tests.AccessorTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tests.AccessorTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Tests.AccessorTests")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("802f9c0a-9fc5-444b-bd3b-aed8b6f148a8")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj new file mode 100644 index 0000000..4770cb4 --- /dev/null +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -0,0 +1,90 @@ + + + + + Debug + AnyCPU + {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} + Library + Properties + Tests.AccessorTests + Tests.AccessorTests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll + + + + + + + + + + + + + + {6886BD35-1655-456B-A4C2-6B57BD557254} + Shared.DatabaseContext + + + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} + Tests.DataPrep + + + + + + + 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}. + + + + + + \ No newline at end of file diff --git a/Tests.AccessorTests/UnitTest1.cs b/Tests.AccessorTests/UnitTest1.cs new file mode 100644 index 0000000..7023462 --- /dev/null +++ b/Tests.AccessorTests/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Tests.AccessorTests +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + } + } +} diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config new file mode 100644 index 0000000..dea6e36 --- /dev/null +++ b/Tests.AccessorTests/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Tests.DataPrep/App.config b/Tests.DataPrep/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Tests.DataPrep/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.DataPrep/DataPrep.cs b/Tests.DataPrep/DataPrep.cs new file mode 100644 index 0000000..c7b07bd --- /dev/null +++ b/Tests.DataPrep/DataPrep.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tests.DataPrep +{ + public class TodoDataPrep + { + public TodoDataPrep(bool shouldPersistData) + { + + } + } +} diff --git a/Tests.DataPrep/Properties/AssemblyInfo.cs b/Tests.DataPrep/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..20cb72c --- /dev/null +++ b/Tests.DataPrep/Properties/AssemblyInfo.cs @@ -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("Tests.DataPrep")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Tests.DataPrep")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("458ed4a8-e0f2-4089-94cb-20b0efdd4b46")] + +// 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")] diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj new file mode 100644 index 0000000..fdb0e45 --- /dev/null +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} + Library + Properties + Tests.DataPrep + Tests.DataPrep + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs new file mode 100644 index 0000000..bea0699 --- /dev/null +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tests.DataPrep +{ + class TodoItemPrep + { + } +} diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs new file mode 100644 index 0000000..735e07a --- /dev/null +++ b/Tests.DataPrep/TodoListPrep.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tests.DataPrep +{ + class TodoListPrep + { + } +} diff --git a/Tests.DataPrep/UserPrep.cs b/Tests.DataPrep/UserPrep.cs new file mode 100644 index 0000000..b03872c --- /dev/null +++ b/Tests.DataPrep/UserPrep.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tests.DataPrep +{ + public class UserPrep + { + } +} diff --git a/Tests.DataPrep/packages.config b/Tests.DataPrep/packages.config new file mode 100644 index 0000000..b3daf0d --- /dev/null +++ b/Tests.DataPrep/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Tests.ManagerTests/App.config b/Tests.ManagerTests/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Tests.ManagerTests/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.ManagerTests/ListExplorationManagerTests.cs b/Tests.ManagerTests/ListExplorationManagerTests.cs new file mode 100644 index 0000000..6644d3c --- /dev/null +++ b/Tests.ManagerTests/ListExplorationManagerTests.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using Managers.LazyCollectionOfAllManagers; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Shared.DataContracts; +using Telerik.JustMock.AutoMock; + +namespace Tests.ManagerTests +{ + [TestClass] + public class ListExplorationManagerTests : ManagerTestBase + { + MockingContainer mockContainer; + ListExplorationManager manager; + + public override void OnInitialize() + { + MockingContainer mockContainer = new MockingContainer(); + ListExplorationManager manager = mockContainer.Instance; + } + + public override void OnCleanup() + { + } + + //[TestMethod] + //public void GetUserStats_UglyAndLong() + //{ + // //Create User + // UserDBO user = new UserDBO() + // { + // Id = Guid.NewGuid(), + // Name = "Bob", + // }; + + + // //Create Todo lists + + // //TODO: turn this into dataprep.CreateTodoListsWithItems + // List expectedLists = new List(); + // int expectedListCount = 5; + // for (int i = 0; i < expectedListCount; i++) + // { + // TodoListDBO expectedList = new TodoListDBO() { + // Id = Guid.NewGuid(), + // UserId = user.Id, + // Title = Guid.NewGuid().ToString(), + // }; + // } + + // //Create items, complete and incomplete + // foreach (TodoList expectedList in expectedLists) + // { + + // } + + // UserAccountStats stats = manager.GetUserStats(user.Id); + + // Assert.AreEqual(expectedListCount, stats.TodoListCount); + + + //} + + [TestMethod] + public void GetUserStats_Final() + { + //Create User + + //Create Todo lists + + //Create items, complete and incomplete + + + + } + + [TestMethod] + public void GetUserStats_Integration() + { + //Create User + + //Create Todo lists + + //Create items, complete and incomplete + + + + } + + + } +} diff --git a/Tests.ManagerTests/ManagerTestBase.cs b/Tests.ManagerTests/ManagerTestBase.cs new file mode 100644 index 0000000..17d4c5d --- /dev/null +++ b/Tests.ManagerTests/ManagerTestBase.cs @@ -0,0 +1,26 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Tests.DataPrep; + +namespace Tests.ManagerTests +{ + public abstract class ManagerTestBase + { + protected TodoDataPrep dataPrep = new TodoDataPrep(false); + + public abstract void OnInitialize(); + [TestInitialize] + public virtual void TestInitialize() + { + OnInitialize(); + } + + + public abstract void OnCleanup(); + [TestCleanup] + public virtual void TestCleanup() + { + OnCleanup(); + } + + } +} diff --git a/Tests.ManagerTests/Properties/AssemblyInfo.cs b/Tests.ManagerTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9453ec3 --- /dev/null +++ b/Tests.ManagerTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tests.ManagerTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Tests.ManagerTests")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("7d0ba0fb-fa51-4964-9e41-7d03bff47a94")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj new file mode 100644 index 0000000..813ea0f --- /dev/null +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -0,0 +1,98 @@ + + + + + Debug + AnyCPU + {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} + Library + Properties + Tests.ManagerTests + Tests.ManagerTests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll + + + + + + + + + + + + + + + {20052ECB-4E1D-4F2F-9F06-79111FE381F8} + Managers.LazyCollectionOfAllManagers + + + {6886bd35-1655-456b-a4c2-6b57bd557254} + Shared.DatabaseContext + + + {49f40a81-dbbc-4904-96e3-e5ef1f7d2a7b} + Shared.DataContracts + + + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} + Tests.DataPrep + + + + + + + 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}. + + + + + + \ No newline at end of file diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs new file mode 100644 index 0000000..4be5f7e --- /dev/null +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Managers.LazyCollectionOfAllManagers; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Shared.DatabaseContext; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; +using Telerik.JustMock.AutoMock; + +namespace Tests.ManagerTests +{ + [TestClass] + public class TodoCRUDManagerTests : ManagerTestBase + { + TodoCRUDManager manager; + MockingContainer mockContainer = new MockingContainer(); + + public override void OnCleanup() + { + } + + public override void OnInitialize() + { + manager = mockContainer.Instance; + } + + [TestMethod] + public void GetTodoItems_Ugly() + { + // arrange + using (TodoContext db = new TodoContext()) + { + UserDBO user = new UserDBO() + { + Name = "Bob", + }; + db.Users.Add(user); + db.SaveChanges(); + + TodoListDBO expectedList = new TodoListDBO() + { + UserId = user.Id, + Title = Guid.NewGuid().ToString(), + }; + db.TodoLists.Add(expectedList); + db.SaveChanges(); + + List expectedItemList = new List(); + int expectedTodoItemCount = 5; + for (int i = 0; i < expectedTodoItemCount; i++) + { + TodoItemDBO expectedItem = new TodoItemDBO() + { + TodoListId = expectedList.Id, + Description = Guid.NewGuid().ToString(), + IsActive = true, + IsComplete = false, + }; + expectedItemList.Add(expectedItem); + } + db.TodoItems.AddRange(expectedItemList); + db.SaveChanges(); + + + + // act + IEnumerable actualItemList = manager.GetTodoItems(expectedList.Id); + + //assert + + Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); + foreach (TodoItem actualTodo in actualItemList) + { + TodoItemDBO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); + Assert.AreEqual(expectedTodo.Description, actualTodo.Description); + Assert.AreEqual(expectedTodo.IsActive, actualTodo.IsActive); + Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); + } + } + + } + + + } +} diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config new file mode 100644 index 0000000..dea6e36 --- /dev/null +++ b/Tests.ManagerTests/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From e8084d1032189ff15afa785d213091c4dacf47cc Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Mon, 5 Mar 2018 17:29:23 -0600 Subject: [PATCH 02/74] Create README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c79f03 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# TestingPatterns + +This project is to record and share patterns and libraries that make testing +- easier +- more resilient +- more powerful +- more descriptive + +As a result, it also demonstrates many other patterns and libraries that enable good development practices. + +This project is very much overkill for a Todo list. However, the overkill is to demonstrate the patterns in a way that can easily be transfered to a large project From ae6bb958d8a6c92ecf1f39a29ab2d2961b4390c9 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 5 Mar 2018 21:05:58 -0600 Subject: [PATCH 03/74] Update read me and resolve build errors --- README.md | 14 +++++++++++++ Tests.DataPrep/DataPrep.cs | 2 +- Tests.ManagerTests/TodoCRUDManagerTests.cs | 23 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c79f03..3994a97 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,17 @@ This project is to record and share patterns and libraries that make testing As a result, it also demonstrates many other patterns and libraries that enable good development practices. This project is very much overkill for a Todo list. However, the overkill is to demonstrate the patterns in a way that can easily be transfered to a large project + +Patterns +- Dependency Injection +- DataPrep (centralized test data generators) +- ConfigWrappers //pending +- Inconclusive tests to mark untested code // pending + +Libraries +- JustMock (test dependency generator) + - alternatives: Moq, MSFakes, RhinoMocks +- DeepEqual +- Bogus + - alternatives: AutoFixture +- .NET Transactions TransactionScope diff --git a/Tests.DataPrep/DataPrep.cs b/Tests.DataPrep/DataPrep.cs index c7b07bd..ad47a21 100644 --- a/Tests.DataPrep/DataPrep.cs +++ b/Tests.DataPrep/DataPrep.cs @@ -10,7 +10,7 @@ public class TodoDataPrep { public TodoDataPrep(bool shouldPersistData) { - + } } } diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 4be5f7e..d7acac4 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -81,6 +81,29 @@ public void GetTodoItems_Ugly() } + [TestMethod] + public void GetTodoItems_Final() + { + // arrange + + + + //// act + //IEnumerable actualItemList = manager.GetTodoItems(expectedList.Id); + + ////assert + + //Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); + //foreach (TodoItem actualTodo in actualItemList) + //{ + // TodoItemDBO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); + // Assert.AreEqual(expectedTodo.Description, actualTodo.Description); + // Assert.AreEqual(expectedTodo.IsActive, actualTodo.IsActive); + // Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); + //} + + + } } } From f174cf33c81102a14f265c33c68900efaf6619a6 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Mon, 5 Mar 2018 21:48:42 -0600 Subject: [PATCH 04/74] stub enough dataprep to get screenshots --- .../Tests.AccessorTests.csproj | 3 ++ Tests.AccessorTests/packages.config | 1 + Tests.DataPrep/DataPrep.cs | 19 +++++++- Tests.DataPrep/TestDataPersistance.cs | 44 +++++++++++++++++++ Tests.DataPrep/Tests.DataPrep.csproj | 14 ++++++ Tests.DataPrep/TodoItemPrep.cs | 27 +++++++++++- Tests.DataPrep/TodoListPrep.cs | 17 ++++++- Tests.DataPrep/UserPrep.cs | 19 +++++++- Tests.DataPrep/packages.config | 1 + Tests.ManagerTests/Tests.ManagerTests.csproj | 3 ++ Tests.ManagerTests/TodoCRUDManagerTests.cs | 30 ++++++------- Tests.ManagerTests/packages.config | 1 + 12 files changed, 156 insertions(+), 23 deletions(-) create mode 100644 Tests.DataPrep/TestDataPersistance.cs diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index 4770cb4..d02eb5f 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -38,6 +38,9 @@ 4 + + ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config index dea6e36..7f049fa 100644 --- a/Tests.AccessorTests/packages.config +++ b/Tests.AccessorTests/packages.config @@ -1,5 +1,6 @@  + diff --git a/Tests.DataPrep/DataPrep.cs b/Tests.DataPrep/DataPrep.cs index ad47a21..a88d612 100644 --- a/Tests.DataPrep/DataPrep.cs +++ b/Tests.DataPrep/DataPrep.cs @@ -8,9 +8,26 @@ namespace Tests.DataPrep { public class TodoDataPrep { + ITestDataAccessor dataPersistance; + + public UserPrep Users { get; set; } + public TodoListPrep TodoLists { get; set; } + public TodoItemPrep TodoItems { get; set; } + public TodoDataPrep(bool shouldPersistData) { - + if (shouldPersistData) + { + dataPersistance = new ApplicationDbTestDataAccessor(); + } + else + { + dataPersistance = new NoPersistanceTestDataAccessor(); + } + + Users = new UserPrep(dataPersistance); + TodoLists = new TodoListPrep(dataPersistance, Users); + TodoItems = new TodoItemPrep(dataPersistance, TodoLists); } } } diff --git a/Tests.DataPrep/TestDataPersistance.cs b/Tests.DataPrep/TestDataPersistance.cs new file mode 100644 index 0000000..6b7c065 --- /dev/null +++ b/Tests.DataPrep/TestDataPersistance.cs @@ -0,0 +1,44 @@ +using Shared.DatabaseContext; + +namespace Tests.DataPrep +{ + public interface ITestDataAccessor + { + + // should probably make this more constrained to just expected data model types, + // but that would require refactoring all data models to implement an interface, which i'm not confident the agilx code can handle + T Create(T entity) where T : class; + } + + + class ApplicationDbTestDataAccessor : ITestDataAccessor + { + + public T Create(T entity) where T : class + { + + using (TodoContext db = new TodoContext()) + { + + db.Set().Add(entity); + db.SaveChanges(); + + return entity; + } + + + } + + } + + class NoPersistanceTestDataAccessor : ITestDataAccessor + { + public T Create(T entity) where T : class + { + // do I need to set an Id? If so, i'll need a base class or interface for db objects + + return entity; + } + } + +} diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index fdb0e45..4e22d5f 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -30,6 +30,9 @@ 4 + + ..\packages\Bogus.22.0.5\lib\net40\Bogus.dll + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll @@ -48,6 +51,7 @@ + @@ -57,5 +61,15 @@ + + + {6886BD35-1655-456B-A4C2-6B57BD557254} + Shared.DatabaseContext + + + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + Shared.DataContracts + + \ No newline at end of file diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index bea0699..b2c1584 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -1,4 +1,5 @@ -using System; +using Shared.DataContracts; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,29 @@ namespace Tests.DataPrep { - class TodoItemPrep + public class TodoItemPrep { + ITestDataAccessor dataAccessor; + TodoListPrep todoListPrep; + public TodoItemPrep(ITestDataAccessor dataAccessor, TodoListPrep todoListPrep) + { + this.dataAccessor = dataAccessor; + this.todoListPrep = todoListPrep; + } + + public TodoItem Create() + { + throw new NotImplementedException(); + } + + public TodoItem Create(TodoItem todoItem) + { + throw new NotImplementedException(); + } + + public IEnumerable CreateManyForList(int count, TodoList todoList) + { + throw new NotImplementedException(); + } } } diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index 735e07a..69548a5 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -1,4 +1,5 @@ -using System; +using Shared.DataContracts; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,19 @@ namespace Tests.DataPrep { - class TodoListPrep + public class TodoListPrep { + ITestDataAccessor dataAccessor; + UserPrep userPrep; + public TodoListPrep(ITestDataAccessor dataAccessor, UserPrep userPrep) + { + this.dataAccessor = dataAccessor; + this.userPrep = userPrep; + } + + public TodoList Create() + { + throw new NotImplementedException(); + } } } diff --git a/Tests.DataPrep/UserPrep.cs b/Tests.DataPrep/UserPrep.cs index b03872c..f21986f 100644 --- a/Tests.DataPrep/UserPrep.cs +++ b/Tests.DataPrep/UserPrep.cs @@ -1,4 +1,5 @@ -using System; +using Shared.DataContracts; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,5 +9,21 @@ namespace Tests.DataPrep { public class UserPrep { + ITestDataAccessor dataAccessor; + public UserPrep(ITestDataAccessor dataAccessor) + { + this.dataAccessor = dataAccessor; + } + + public User Create() + { + //User user = new User() + //{ + // Id = , + // Name =, + //}; + throw new NotImplementedException(); + } + } } diff --git a/Tests.DataPrep/packages.config b/Tests.DataPrep/packages.config index b3daf0d..6fa70bb 100644 --- a/Tests.DataPrep/packages.config +++ b/Tests.DataPrep/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 813ea0f..f505de8 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -38,6 +38,9 @@ 4 + + ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index d7acac4..ffe3311 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using DeepEqual.Syntax; using Managers.LazyCollectionOfAllManagers; using Microsoft.VisualStudio.TestTools.UnitTesting; using Shared.DatabaseContext; @@ -77,6 +78,11 @@ public void GetTodoItems_Ugly() Assert.AreEqual(expectedTodo.IsActive, actualTodo.IsActive); Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); } + + db.TodoItems.RemoveRange(expectedItemList); + db.TodoLists.Remove(expectedList); + db.Users.Remove(user); + db.SaveChanges(); } } @@ -85,25 +91,15 @@ public void GetTodoItems_Ugly() public void GetTodoItems_Final() { // arrange - - - - - //// act - //IEnumerable actualItemList = manager.GetTodoItems(expectedList.Id); - - ////assert + TodoList todoList = dataPrep.TodoLists.Create(); + int expectedItemCount = 5; + IEnumerable expectedItemList = dataPrep.TodoItems.CreateManyForList(expectedItemCount, todoList); - //Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); - //foreach (TodoItem actualTodo in actualItemList) - //{ - // TodoItemDBO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); - // Assert.AreEqual(expectedTodo.Description, actualTodo.Description); - // Assert.AreEqual(expectedTodo.IsActive, actualTodo.IsActive); - // Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); - //} - + // act + IEnumerable actualItemList = manager.GetTodoItems(todoList.Id); + //assert + expectedItemList.ShouldDeepEqual(actualItemList); } } } diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index dea6e36..7f049fa 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -1,5 +1,6 @@  + From 4112f97e73157866c1b0806970cc5fb22e007ced Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Tue, 6 Mar 2018 12:02:55 -0600 Subject: [PATCH 05/74] first functioning tests with dataprep --- .../Accessors.DatabaseAccessors.csproj | 14 ++ .../TodoItemAccessor.cs | 20 ++- Accessors.DatabaseAccessors/packages.config | 1 + ...anagers.LazyCollectionOfAllManagers.csproj | 4 + .../TodoCRUDManager.cs | 12 +- README.md | 6 +- Shared.DataContracts/TodoItem.cs | 2 + .../DBOs/DatabaseObjectBase.cs | 15 +++ Shared.DatabaseContext/DBOs/MapperBase.cs | 40 ++++++ Shared.DatabaseContext/DBOs/TodoItemDBO.cs | 13 +- Shared.DatabaseContext/DBOs/TodoListDBO.cs | 11 +- Shared.DatabaseContext/DBOs/UserDBO.cs | 12 +- ...201803061729594_AddActiveFlags.Designer.cs | 29 ++++ .../201803061729594_AddActiveFlags.cs | 20 +++ .../201803061729594_AddActiveFlags.resx | 126 ++++++++++++++++++ .../Shared.DatabaseContext.csproj | 19 +++ Shared.DatabaseContext/packages.config | 1 + .../Tests.AccessorTests.csproj | 10 +- Tests.AccessorTests/TodoItemAccessorTests.cs | 97 ++++++++++++++ Tests.AccessorTests/UnitTest1.cs | 14 -- Tests.DataPrep/Tests.DataPrep.csproj | 4 + Tests.DataPrep/TodoItemPrep.cs | 40 +++++- Tests.DataPrep/TodoListPrep.cs | 29 +++- Tests.DataPrep/UserPrep.cs | 31 ++++- Tests.DataPrep/packages.config | 1 + Tests.ManagerTests/TodoCRUDManagerTests.cs | 76 +---------- 26 files changed, 529 insertions(+), 118 deletions(-) create mode 100644 Shared.DatabaseContext/DBOs/DatabaseObjectBase.cs create mode 100644 Shared.DatabaseContext/DBOs/MapperBase.cs create mode 100644 Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs create mode 100644 Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs create mode 100644 Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx create mode 100644 Tests.AccessorTests/TodoItemAccessorTests.cs delete mode 100644 Tests.AccessorTests/UnitTest1.cs diff --git a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj index 504cb68..7965408 100644 --- a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj +++ b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj @@ -30,6 +30,9 @@ 4 + + ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll @@ -42,6 +45,7 @@ + @@ -60,5 +64,15 @@ + + + {6886BD35-1655-456B-A4C2-6B57BD557254} + Shared.DatabaseContext + + + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + Shared.DataContracts + + \ No newline at end of file diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index 08246e9..60583df 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -1,4 +1,7 @@ -using System; +using Shared.DatabaseContext; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,9 +11,20 @@ namespace Accessors.DatabaseAccessors { public interface ITodoItemAccessor { - + IEnumerable GetTodoItemsForList(Guid listId); } - class TodoItemAccessor: ITodoItemAccessor + class TodoItemAccessor : ITodoItemAccessor { + TodoItem_Mapper mapper = new TodoItem_Mapper(); + public IEnumerable GetTodoItemsForList(Guid listId) + { + IEnumerable todoItemList; + using (TodoContext db = new TodoContext()) + { + IEnumerable todoItemModelList = db.TodoItems.Where(ti => ti.TodoListId == listId && ti.IsActive).ToList(); + todoItemList = mapper.ModelListToContractList(todoItemModelList); + } + return todoItemList; + } } } diff --git a/Accessors.DatabaseAccessors/packages.config b/Accessors.DatabaseAccessors/packages.config index 4400cc5..8b7b658 100644 --- a/Accessors.DatabaseAccessors/packages.config +++ b/Accessors.DatabaseAccessors/packages.config @@ -1,5 +1,6 @@  + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj index bfa80f1..cf6747f 100644 --- a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj +++ b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj @@ -61,6 +61,10 @@ + + {AF26B020-F939-4353-A41D-F6C0F87D0B81} + Accessors.DatabaseAccessors + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} Shared.DataContracts diff --git a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs index 2a09558..9d20da6 100644 --- a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs +++ b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs @@ -1,4 +1,5 @@ -using Shared.DataContracts; +using Accessors.DatabaseAccessors; +using Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; @@ -19,6 +20,15 @@ public interface ITodoCRUDManager } internal class TodoCRUDManager : ITodoCRUDManager { + ITodoListAccessor todoListAccessor; + ITodoItemAccessor todoItemAccessor; + public TodoCRUDManager(ITodoListAccessor todoListAccessor, ITodoItemAccessor todoItemAccessor) + { + this.todoListAccessor = todoListAccessor; + this.todoItemAccessor = todoItemAccessor; + } + + public IEnumerable GetTodoItems(Guid listId) { throw new NotImplementedException(); diff --git a/README.md b/README.md index 3994a97..a8c6515 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ Patterns - Inconclusive tests to mark untested code // pending Libraries -- JustMock (test dependency generator) +- JustMock (test dependency generator; https://www.telerik.com/products/mocking.aspx) - alternatives: Moq, MSFakes, RhinoMocks -- DeepEqual -- Bogus +- DeepEqual (https://github.com/jamesfoster/DeepEqual) +- Bogus (https://github.com/bchavez/Bogus) - alternatives: AutoFixture - .NET Transactions TransactionScope diff --git a/Shared.DataContracts/TodoItem.cs b/Shared.DataContracts/TodoItem.cs index a03bd80..0219739 100644 --- a/Shared.DataContracts/TodoItem.cs +++ b/Shared.DataContracts/TodoItem.cs @@ -6,6 +6,8 @@ public class TodoItem { public Guid Id { get; set; } + public Guid TodoListId { get; set; } + public string Description { get; set; } public bool IsComplete { get; set; } diff --git a/Shared.DatabaseContext/DBOs/DatabaseObjectBase.cs b/Shared.DatabaseContext/DBOs/DatabaseObjectBase.cs new file mode 100644 index 0000000..5cc100c --- /dev/null +++ b/Shared.DatabaseContext/DBOs/DatabaseObjectBase.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DatabaseContext.DBOs +{ + public interface DatabaseObjectBase + { + Guid Id { get; set; } + + bool IsActive { get; set; } + } +} diff --git a/Shared.DatabaseContext/DBOs/MapperBase.cs b/Shared.DatabaseContext/DBOs/MapperBase.cs new file mode 100644 index 0000000..63010d1 --- /dev/null +++ b/Shared.DatabaseContext/DBOs/MapperBase.cs @@ -0,0 +1,40 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DatabaseContext.DBOs +{ + public class MapperBase + { + IMapper map; + protected MapperConfiguration config; + public MapperBase() + { + config = new MapperConfiguration(cfg => + { + cfg.CreateMap(); + cfg.CreateMap(); + }); + + map = config.CreateMapper(); + } + + public virtual ContractType ModelToContract(ModelType dbo) + { + return map.Map(dbo); + } + + public virtual ModelType ContractToModel(ContractType contract) + { + return map.Map(contract); + } + + public virtual IEnumerable ModelListToContractList(IEnumerable dboList) + { + return dboList.Select(dbo => ModelToContract(dbo)); + } + } +} diff --git a/Shared.DatabaseContext/DBOs/TodoItemDBO.cs b/Shared.DatabaseContext/DBOs/TodoItemDBO.cs index 901e29a..80cd4e8 100644 --- a/Shared.DatabaseContext/DBOs/TodoItemDBO.cs +++ b/Shared.DatabaseContext/DBOs/TodoItemDBO.cs @@ -1,11 +1,13 @@ -using System; +using AutoMapper; +using Shared.DataContracts; +using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Shared.DatabaseContext.DBOs { [Table("TodoItems")] - public class TodoItemDBO + public class TodoItemDBO : DatabaseObjectBase { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } @@ -22,4 +24,11 @@ public class TodoItemDBO public TodoListDBO TodoList { get; set; } } + + public class TodoItem_Mapper : MapperBase + { + public TodoItem_Mapper() + { + } + } } diff --git a/Shared.DatabaseContext/DBOs/TodoListDBO.cs b/Shared.DatabaseContext/DBOs/TodoListDBO.cs index 072f5bc..0a5573f 100644 --- a/Shared.DatabaseContext/DBOs/TodoListDBO.cs +++ b/Shared.DatabaseContext/DBOs/TodoListDBO.cs @@ -1,11 +1,12 @@ -using System; +using Shared.DataContracts; +using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Shared.DatabaseContext.DBOs { [Table("TodoLists")] - public class TodoListDBO + public class TodoListDBO : DatabaseObjectBase { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } @@ -16,5 +17,11 @@ public class TodoListDBO [ForeignKey("UserId")] public UserDBO User { get; set; } + public bool IsActive { get; set; } + } + + public class TodoList_Mapper : MapperBase + { + } } diff --git a/Shared.DatabaseContext/DBOs/UserDBO.cs b/Shared.DatabaseContext/DBOs/UserDBO.cs index 5fe6327..6609e77 100644 --- a/Shared.DatabaseContext/DBOs/UserDBO.cs +++ b/Shared.DatabaseContext/DBOs/UserDBO.cs @@ -1,4 +1,5 @@ -using System; +using Shared.DataContracts; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -9,12 +10,19 @@ namespace Shared.DatabaseContext.DBOs { [Table("Users")] - public class UserDBO + public class UserDBO : DatabaseObjectBase { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } public string Name { get; set; } + public bool IsActive { get; set; } + + } + + public class User_Mapper : MapperBase + { + } } diff --git a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs new file mode 100644 index 0000000..ea1f75f --- /dev/null +++ b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs @@ -0,0 +1,29 @@ +// +namespace Shared.DatabaseContext.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] + public sealed partial class AddActiveFlags : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(AddActiveFlags)); + + string IMigrationMetadata.Id + { + get { return "201803061729594_AddActiveFlags"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs new file mode 100644 index 0000000..867b90e --- /dev/null +++ b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs @@ -0,0 +1,20 @@ +namespace Shared.DatabaseContext.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class AddActiveFlags : DbMigration + { + public override void Up() + { + AddColumn("dbo.TodoLists", "IsActive", c => c.Boolean(nullable: false)); + AddColumn("dbo.Users", "IsActive", c => c.Boolean(nullable: false)); + } + + public override void Down() + { + DropColumn("dbo.Users", "IsActive"); + DropColumn("dbo.TodoLists", "IsActive"); + } + } +} diff --git a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx new file mode 100644 index 0000000..b195d5c --- /dev/null +++ b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1a227jNhB9L9B/EPTUFlkryb60gb2LxEkWRpM4iLOLvgW0NHaIUqRWpAIbRb+sD/2k/kKHulk3WrKdGNlgESCwKfJwODwzHB36v3/+7X9c+Mx6glBSwQf2Ue/QtoC7wqN8PrAjNXv3q/3xw48/9C88f2F9yfq91/1wJJcD+1Gp4MRxpPsIPpE9n7qhkGKmeq7wHeIJ5/jw8Dfn6MgBhLARy7L6dxFX1If4C34dCu5CoCLCroUHTKbt+GQSo1o3xAcZEBcG9uSRhOD1zokiUyIBhypYKNs6ZZSgNRNgM9sinAtFFNp68lnCRIWCzycBNhB2vwwA+80Ik5Cu4WTVvetyDo/1cpzVwAzKjaQS/oaAR+9T/zjV4Vt52c79hx68QE+rpV517MWBfS88MVLgn5+Nbas638mQhbqvyc89HCV7BYgDq7njQU4W5JT+O7CGEVNRCAMOkQoJO7Buoymj7u+wvBd/Ah/wiLGi6Wg8Pis1YNNtKAII1fIOZumCRp5tOeVxTnVgPqwwJlnnp4ji5xucm0wZ5MQouGSiRAifgENIFHi3RCkIuYaA2LW1yStTaWddUalap1wPcw7SDWmQkCLdIhVimNrWNVlcAZ+rx4GNH23rki7Ay1pS8M+cYlTjIBVGrXON5FD4AQMF2VRnQjAgfGOrR/LUVfRpc5wb8kTnsf8N7rStO2BxB/lIgyTwi8R8WHW8DIV/J1iZ+/nzh4mIQldbKNZ0uifhHFTZzL6zCq7WkNMoO4ZcCvE95NpYhzk/3DHc7qlisIdAe+7w0Es3hkZKoIekUzksis8aQ6LUYadw0Ag7hEI6/HsYtLFL/3+lFDZx5VRK4dJ49fXcmfC2bM0F96w2EicOqAQBugJZQQPkAdoxsH+pLXQNdEb/AnRO6jLskV2l0Zifgz5aLe03XSAOiXSJV3c0usgrtyDzINR7TxiSXSKXKVd1mlLu0oCwFuMr4zoSXNuVz1B9cg4BcE3Oli3pMnWWw+vT57NU3NXmnb5TYFc76Wp1xDp2mIuKMvnywnsz8hnLkW7cfh0kNC1iT0Q0bVGX6Ys1/B4ImeRGfZ7hCAgLRuSvu7WjE+MlPT1lmrirhNKYE1AVikvbWqXiJqbWiFnH0a4x4eSUbMHR8d6EkefVyviC6+rGrIqcQjdTIVTdzw5HSm58af01ZnQ4QQpIqQeqAVheaEcn1F+Cmh2xPsl1T3MVh6TEanGIMat1ce8ax2TFRR5AKz3JSQSlTHhyDMpT/5oEAdZLBSUqbbEmiQw1fDfZXJvxEwzHlQ0STW5tPhNWf2QOlac4NVp6SUMkU1r42tbQ82vdiunCEHrZTNWMUN+2LCizEfpzMspQqRdTSD3DpjCXuD5fZ+m40G3gUOPoWBYkjIQNlfVQsMjn5jPDPLqY4oso61K/Ga2k1hThSg+64xUVmdIaC+2boGU1exkra60j9Z3KltUOwRpHanVEmXSdKZlE/zNRMjuNtqOkcfTLUDIrgYsIprLYjJIqGSVOJ01vkDDJGfoMZMnKjs2JYhz5MiRJXvKL45OWb3Zza6d3tUs+e36KV07rfnpytl8m1Y7SpIttoYueqKeP0clS4kEU86M3+cqGjOJ6Vx2uCaczkCoRkuzjw6Pjyl3U67kXcqT0WPfLob0LYhGnXyOgsbo1o7p6bxXANlV1a3cx9Tlrb1YjfLdbDOy/YowTa/THwwrmwBqHyIIT69D6+zmudPgTCV3MSD/5ZPFzEXC7a5spVTtf2bRjbHUP8gbZVb522IpZCcROrCrdXOzIpxdjQuMh+TZYUFTdX4n7d1DVc/llz1J3o3SyvZa/lWhprgFfUil/g+r4htv3gkTKVc1tdfldr2D2rHZ/O+p2XdXqpl/Hu7ZewU6K+oHtTQVufJI9jSqlUeA2T5Q/NU3ULGA2KeDNk+RPmiZolo33IY9XDC69/XYUwxu13ia5/1XJ4Bsab85CBsnzRaTu+ksxxnDhd5iYRiSdryD0rzI5uKXozfuM+ExkiaRiUdalUs1cgyIehvZpiIUXcRU+dkHK+EcJXwiLsMuFPwVvxMeRCiKFSwZ/yko/ctDJaN38sZ5ftrk/jt+v5HMsAc2kuAQY87OIMi+3+7KhEjNA6CyX1pp6L5WuOefLHOlG8I5Aqfvy5HwP+OaHYHLMJ0TXjJvbhqF7BXPiLjNtwwzSvhFlt/fPKZmHxJcpxmo8fkUOe/7iw/9H+xqejiwAAA== + + + dbo + + \ No newline at end of file diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index 05a1190..0baaac8 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -30,6 +30,9 @@ 4 + + ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll @@ -39,6 +42,7 @@ + @@ -47,10 +51,16 @@ + + 201803052220061_Init.cs + + + 201803061729594_AddActiveFlags.cs + @@ -66,6 +76,15 @@ 201803052220061_Init.cs + + 201803061729594_AddActiveFlags.cs + + + + + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + Shared.DataContracts + \ No newline at end of file diff --git a/Shared.DatabaseContext/packages.config b/Shared.DatabaseContext/packages.config index b3daf0d..01429a7 100644 --- a/Shared.DatabaseContext/packages.config +++ b/Shared.DatabaseContext/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index d02eb5f..bd60dae 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -63,7 +63,7 @@ - + @@ -71,10 +71,18 @@ + + {AF26B020-F939-4353-A41D-F6C0F87D0B81} + Accessors.DatabaseAccessors + {6886BD35-1655-456B-A4C2-6B57BD557254} Shared.DatabaseContext + + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + Shared.DataContracts + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} Tests.DataPrep diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs new file mode 100644 index 0000000..db28056 --- /dev/null +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Accessors.DatabaseAccessors; +using DeepEqual.Syntax; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Shared.DatabaseContext; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; + +namespace Tests.AccessorTests +{ + [TestClass] + public class TodoItemAccessorTests : AccessorTestBase + { + TodoItemAccessor accessor; + public override void OnInitialize() + { + accessor = new TodoItemAccessor(); + } + + [TestMethod] + public void GetTodoItems_Ugly() + { + + // arrange + using (TodoContext db = new TodoContext()) + { + UserDBO user = new UserDBO() + { + Name = "Bob", + }; + db.Users.Add(user); + db.SaveChanges(); + + TodoListDBO expectedList = new TodoListDBO() + { + UserId = user.Id, + Title = Guid.NewGuid().ToString(), + }; + db.TodoLists.Add(expectedList); + db.SaveChanges(); + + List expectedItemList = new List(); + int expectedTodoItemCount = 5; + for (int i = 0; i < expectedTodoItemCount; i++) + { + TodoItemDBO expectedItem = new TodoItemDBO() + { + TodoListId = expectedList.Id, + Description = Guid.NewGuid().ToString(), + IsActive = true, + IsComplete = false, + }; + expectedItemList.Add(expectedItem); + } + db.TodoItems.AddRange(expectedItemList); + db.SaveChanges(); + + // act + IEnumerable actualItemList = accessor.GetTodoItemsForList(expectedList.Id); + + //assert + Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); + foreach (TodoItem actualTodo in actualItemList) + { + TodoItemDBO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); + Assert.AreEqual(expectedTodo.TodoListId, actualTodo.TodoListId); + Assert.AreEqual(expectedTodo.Description, actualTodo.Description); + Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); + } + + db.TodoItems.RemoveRange(expectedItemList); + db.TodoLists.Remove(expectedList); + db.Users.Remove(user); + db.SaveChanges(); + } + + } + + [TestMethod] + public void GetTodoItems_Final() + { + // arrange + TodoList todoList = dataPrep.TodoLists.Create(); + int expectedItemCount = 5; + IEnumerable expectedItemList = dataPrep.TodoItems.CreateManyForList(expectedItemCount, todoList); + + // act + IEnumerable actualItemList = accessor.GetTodoItemsForList(todoList.Id); + + //assert + expectedItemList.ShouldDeepEqual(actualItemList); + } + + } +} diff --git a/Tests.AccessorTests/UnitTest1.cs b/Tests.AccessorTests/UnitTest1.cs deleted file mode 100644 index 7023462..0000000 --- a/Tests.AccessorTests/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Tests.AccessorTests -{ - [TestClass] - public class UnitTest1 - { - [TestMethod] - public void TestMethod1() - { - } - } -} diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index 4e22d5f..0e1e429 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -30,6 +30,9 @@ 4 + + ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + ..\packages\Bogus.22.0.5\lib\net40\Bogus.dll @@ -42,6 +45,7 @@ + diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index b2c1584..17f333b 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -1,4 +1,5 @@ -using Shared.DataContracts; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; @@ -11,25 +12,54 @@ public class TodoItemPrep { ITestDataAccessor dataAccessor; TodoListPrep todoListPrep; + + Bogus.Faker random = new Bogus.Faker(); + public TodoItemPrep(ITestDataAccessor dataAccessor, TodoListPrep todoListPrep) { this.dataAccessor = dataAccessor; this.todoListPrep = todoListPrep; } - public TodoItem Create() + public TodoItem Create(TodoList todoList = null) { - throw new NotImplementedException(); + + TodoList sanitizedTodoList = todoList ?? todoListPrep.Create(); + TodoItem todoItem = new TodoItem() + { + TodoListId = sanitizedTodoList.Id, + Description = random.Lorem.Sentence(), + IsComplete = random.PickRandom(true, false), + IsActive = true + }; + + TodoItem savedItem = Create(todoItem); + + return savedItem; } public TodoItem Create(TodoItem todoItem) { - throw new NotImplementedException(); + TodoItem_Mapper mapper = new TodoItem_Mapper(); + TodoItemDBO model = mapper.ContractToModel(todoItem); + + TodoItemDBO savedModel = dataAccessor.Create(model); + TodoItem savedContract = mapper.ModelToContract(savedModel); + + return savedContract; } public IEnumerable CreateManyForList(int count, TodoList todoList) { - throw new NotImplementedException(); + List itemList = new List(); + for (int i = 0; i < count; i++) + { + TodoItem item = Create(todoList); + itemList.Add(item); + + } + + return itemList; } } } diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index 69548a5..29bdb50 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -1,4 +1,5 @@ -using Shared.DataContracts; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,8 @@ namespace Tests.DataPrep { public class TodoListPrep { + Bogus.Faker random = new Bogus.Faker(); + ITestDataAccessor dataAccessor; UserPrep userPrep; public TodoListPrep(ITestDataAccessor dataAccessor, UserPrep userPrep) @@ -17,9 +20,29 @@ public TodoListPrep(ITestDataAccessor dataAccessor, UserPrep userPrep) this.userPrep = userPrep; } - public TodoList Create() + public TodoList Create(User user = null) + { + User sanitizedUser = user ?? userPrep.Create(); + TodoList todoList = new TodoList() + { + UserId = sanitizedUser.Id, + Title = random.Lorem.Sentence(), + }; + + TodoList savedList = Create(todoList); + + return savedList; + } + + public TodoList Create(TodoList todoList) { - throw new NotImplementedException(); + TodoList_Mapper mapper = new TodoList_Mapper(); + TodoListDBO model = mapper.ContractToModel(todoList); + + TodoListDBO savedModel = dataAccessor.Create(model); + TodoList savedContract = mapper.ModelToContract(savedModel); + + return savedContract; } } } diff --git a/Tests.DataPrep/UserPrep.cs b/Tests.DataPrep/UserPrep.cs index f21986f..1b414bb 100644 --- a/Tests.DataPrep/UserPrep.cs +++ b/Tests.DataPrep/UserPrep.cs @@ -1,4 +1,5 @@ -using Shared.DataContracts; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; @@ -7,8 +8,11 @@ namespace Tests.DataPrep { + public class UserPrep { + Bogus.Faker random = new Bogus.Faker(); + ITestDataAccessor dataAccessor; public UserPrep(ITestDataAccessor dataAccessor) { @@ -17,12 +21,25 @@ public UserPrep(ITestDataAccessor dataAccessor) public User Create() { - //User user = new User() - //{ - // Id = , - // Name =, - //}; - throw new NotImplementedException(); + User user = new User() + { + Name = random.Name.FullName(), + }; + User savedUser = Create(user); + + return savedUser; + } + + public User Create(User user) + { + // NOTE/TODO: feels like there should be a good way to encapsulate this so most data prep classes don't have to write it + User_Mapper mapper = new User_Mapper(); + UserDBO model = mapper.ContractToModel(user); + + UserDBO savedModel = dataAccessor.Create(model); + User savedContract = mapper.ModelToContract(savedModel); + + return savedContract; } } diff --git a/Tests.DataPrep/packages.config b/Tests.DataPrep/packages.config index 6fa70bb..e2d5f5b 100644 --- a/Tests.DataPrep/packages.config +++ b/Tests.DataPrep/packages.config @@ -1,5 +1,6 @@  + \ No newline at end of file diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index ffe3311..4df0a7d 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -26,80 +26,6 @@ public override void OnInitialize() manager = mockContainer.Instance; } - [TestMethod] - public void GetTodoItems_Ugly() - { - // arrange - using (TodoContext db = new TodoContext()) - { - UserDBO user = new UserDBO() - { - Name = "Bob", - }; - db.Users.Add(user); - db.SaveChanges(); - - TodoListDBO expectedList = new TodoListDBO() - { - UserId = user.Id, - Title = Guid.NewGuid().ToString(), - }; - db.TodoLists.Add(expectedList); - db.SaveChanges(); - - List expectedItemList = new List(); - int expectedTodoItemCount = 5; - for (int i = 0; i < expectedTodoItemCount; i++) - { - TodoItemDBO expectedItem = new TodoItemDBO() - { - TodoListId = expectedList.Id, - Description = Guid.NewGuid().ToString(), - IsActive = true, - IsComplete = false, - }; - expectedItemList.Add(expectedItem); - } - db.TodoItems.AddRange(expectedItemList); - db.SaveChanges(); - - - - // act - IEnumerable actualItemList = manager.GetTodoItems(expectedList.Id); - - //assert - - Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); - foreach (TodoItem actualTodo in actualItemList) - { - TodoItemDBO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); - Assert.AreEqual(expectedTodo.Description, actualTodo.Description); - Assert.AreEqual(expectedTodo.IsActive, actualTodo.IsActive); - Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); - } - - db.TodoItems.RemoveRange(expectedItemList); - db.TodoLists.Remove(expectedList); - db.Users.Remove(user); - db.SaveChanges(); - } - - } - - [TestMethod] - public void GetTodoItems_Final() - { - // arrange - TodoList todoList = dataPrep.TodoLists.Create(); - int expectedItemCount = 5; - IEnumerable expectedItemList = dataPrep.TodoItems.CreateManyForList(expectedItemCount, todoList); - - // act - IEnumerable actualItemList = manager.GetTodoItems(todoList.Id); - - //assert - expectedItemList.ShouldDeepEqual(actualItemList); - } + } } From d0ab65b87d5bed11eb962593da9cce81713677a9 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Tue, 6 Mar 2018 12:09:43 -0600 Subject: [PATCH 06/74] handle isActive more centrally and without need for presence on data contract --- Shared.DataContracts/TodoItem.cs | 2 -- Tests.DataPrep/TodoItemPrep.cs | 5 +++-- Tests.DataPrep/TodoListPrep.cs | 3 ++- Tests.DataPrep/UserPrep.cs | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Shared.DataContracts/TodoItem.cs b/Shared.DataContracts/TodoItem.cs index 0219739..2bcf134 100644 --- a/Shared.DataContracts/TodoItem.cs +++ b/Shared.DataContracts/TodoItem.cs @@ -12,7 +12,5 @@ public class TodoItem public bool IsComplete { get; set; } - public bool IsActive { get; set; } - } } diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index 17f333b..b462d62 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -30,7 +30,6 @@ public TodoItem Create(TodoList todoList = null) TodoListId = sanitizedTodoList.Id, Description = random.Lorem.Sentence(), IsComplete = random.PickRandom(true, false), - IsActive = true }; TodoItem savedItem = Create(todoItem); @@ -38,10 +37,12 @@ public TodoItem Create(TodoList todoList = null) return savedItem; } - public TodoItem Create(TodoItem todoItem) + public TodoItem Create(TodoItem todoItem, bool isActive = true) { TodoItem_Mapper mapper = new TodoItem_Mapper(); TodoItemDBO model = mapper.ContractToModel(todoItem); + // handle active state here so I can create inactive items, but leave active flags off of data contracts + model.IsActive = isActive; TodoItemDBO savedModel = dataAccessor.Create(model); TodoItem savedContract = mapper.ModelToContract(savedModel); diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index 29bdb50..b4b9099 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -34,10 +34,11 @@ public TodoList Create(User user = null) return savedList; } - public TodoList Create(TodoList todoList) + public TodoList Create(TodoList todoList, bool isActive = true) { TodoList_Mapper mapper = new TodoList_Mapper(); TodoListDBO model = mapper.ContractToModel(todoList); + model.IsActive = isActive; TodoListDBO savedModel = dataAccessor.Create(model); TodoList savedContract = mapper.ModelToContract(savedModel); diff --git a/Tests.DataPrep/UserPrep.cs b/Tests.DataPrep/UserPrep.cs index 1b414bb..504540e 100644 --- a/Tests.DataPrep/UserPrep.cs +++ b/Tests.DataPrep/UserPrep.cs @@ -30,11 +30,12 @@ public User Create() return savedUser; } - public User Create(User user) + public User Create(User user, bool isActive = true) { // NOTE/TODO: feels like there should be a good way to encapsulate this so most data prep classes don't have to write it User_Mapper mapper = new User_Mapper(); UserDBO model = mapper.ContractToModel(user); + model.IsActive = isActive; UserDBO savedModel = dataAccessor.Create(model); User savedContract = mapper.ModelToContract(savedModel); From 14b090c3d8771debe93c650eb8c2f4f7a23a7211 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 7 Mar 2018 09:21:48 -0600 Subject: [PATCH 07/74] Add a manager test and more clear place to edit db connectionstring --- .../TodoCRUDManager.cs | 2 +- Shared.DatabaseContext/TodoContext.cs | 2 +- TestingExemplar.sln | 5 +++++ Tests.AccessorTests/App.config | 4 ++++ Tests.ManagerTests/Tests.ManagerTests.csproj | 4 ++++ Tests.ManagerTests/TodoCRUDManagerTests.cs | 19 ++++++++++++++++++- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs index 9d20da6..33486b2 100644 --- a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs +++ b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs @@ -31,7 +31,7 @@ public TodoCRUDManager(ITodoListAccessor todoListAccessor, ITodoItemAccessor tod public IEnumerable GetTodoItems(Guid listId) { - throw new NotImplementedException(); + return todoItemAccessor.GetTodoItemsForList(listId); } public void GetTodoList(Guid id) diff --git a/Shared.DatabaseContext/TodoContext.cs b/Shared.DatabaseContext/TodoContext.cs index 43789a6..5910e01 100644 --- a/Shared.DatabaseContext/TodoContext.cs +++ b/Shared.DatabaseContext/TodoContext.cs @@ -14,7 +14,7 @@ public class TodoContext : DbContext public DbSet TodoItems { get; set; } public DbSet TodoLists { get; set; } - public TodoContext() + public TodoContext() : base("TodoDb") { } } diff --git a/TestingExemplar.sln b/TestingExemplar.sln index f5f17d9..4f87f1c 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -19,6 +19,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accessors.DatabaseAccessors EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3B08858C-6FD1-47E7-824C-0B3F1D234455}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Tests.AccessorTests/App.config b/Tests.AccessorTests/App.config index 7e1d79c..7c4b11d 100644 --- a/Tests.AccessorTests/App.config +++ b/Tests.AccessorTests/App.config @@ -4,6 +4,10 @@
+ + + + diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index f505de8..822e29b 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -71,6 +71,10 @@ + + {AF26B020-F939-4353-A41D-F6C0F87D0B81} + Accessors.DatabaseAccessors + {20052ECB-4E1D-4F2F-9F06-79111FE381F8} Managers.LazyCollectionOfAllManagers diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 4df0a7d..153de11 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Accessors.DatabaseAccessors; using DeepEqual.Syntax; using Managers.LazyCollectionOfAllManagers; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -26,6 +27,22 @@ public override void OnInitialize() manager = mockContainer.Instance; } - + [TestMethod] + public void GetTodoItems() + { + + // arrange + TodoList todoList = dataPrep.TodoLists.Create(); + int expectedItemCount = 5; + IEnumerable expectedItemList = dataPrep.TodoItems.CreateManyForList(expectedItemCount, todoList); + + mockContainer.Arrange(accessor => accessor.GetTodoItemsForList(todoList.Id)).Returns(expectedItemList); + + // act + IEnumerable actualItemList = manager.GetTodoItems(todoList.Id); + + //assert + expectedItemList.ShouldDeepEqual(actualItemList); + } } } From 6ec118e947b8aff2ea554a2ac45141d2078f6e78 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Thu, 8 Mar 2018 11:07:20 -0600 Subject: [PATCH 08/74] Add solution folders for organization --- TestingExemplar.sln | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/TestingExemplar.sln b/TestingExemplar.sln index 4f87f1c..a1cdb71 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -24,6 +24,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.Managers", "2.Managers", "{01383730-F2FD-4900-B91C-4784EDA64DF6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4.Accessors", "4.Accessors", "{CA030337-D04B-4393-9869-897FA379EC1B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "5.Shared", "5.Shared", "{E1966F97-64AF-4CA1-9CDB-DA841C9491B9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,9 +69,13 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {20052ECB-4E1D-4F2F-9F06-79111FE381F8} = {01383730-F2FD-4900-B91C-4784EDA64DF6} + {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} + {6886BD35-1655-456B-A4C2-6B57BD557254} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} + {AF26B020-F939-4353-A41D-F6C0F87D0B81} = {CA030337-D04B-4393-9869-897FA379EC1B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} From 76cd273f5d938f63d4e5c0fde862bf4d8cea580d Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Thu, 8 Mar 2018 12:27:38 -0600 Subject: [PATCH 09/74] Add an example of intergration/unit test reuse --- .../DependencyInjectionLoader.cs | 27 ++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++++++ .../Shared.DependencyInjectionKernel.csproj | 63 +++++++++++++++++++ .../packages.config | 4 ++ TestingExemplar.sln | 9 ++- Tests.ManagerTests/Tests.ManagerTests.csproj | 8 +++ .../TodoCRUDManagerIntegrationTests.cs | 47 ++++++++++++++ Tests.ManagerTests/TodoCRUDManagerTests.cs | 14 ++++- Tests.ManagerTests/packages.config | 1 + 9 files changed, 207 insertions(+), 2 deletions(-) create mode 100644 Shared.DependencyInjectionKernel/DependencyInjectionLoader.cs create mode 100644 Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs create mode 100644 Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj create mode 100644 Shared.DependencyInjectionKernel/packages.config create mode 100644 Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs diff --git a/Shared.DependencyInjectionKernel/DependencyInjectionLoader.cs b/Shared.DependencyInjectionKernel/DependencyInjectionLoader.cs new file mode 100644 index 0000000..ca586c9 --- /dev/null +++ b/Shared.DependencyInjectionKernel/DependencyInjectionLoader.cs @@ -0,0 +1,27 @@ +using Accessors.DatabaseAccessors; +using Managers.LazyCollectionOfAllManagers; +using Ninject; +using Ninject.Modules; +using System.Collections.Generic; + +namespace Shared.DependencyInjectionKernel +{ + public static class DependencyInjectionLoader + { + // NOTE: This class centrallizes dependency injection configuration and removes the need to directly + // reference dependency projects. You can still instantiate a subset of dependencies if needed, but this + // centrallizes the usual concern of wanting all the full stack. + // This is only useful if you have multiple clients. In this case, our integration test are all effectively clients. + + public static INinjectModule[] Modules = new INinjectModule[] + { + new LazyManagerLoader(), + new DatabaseAccessorLoader(), + }; + public static IKernel BuildKernel() + { + IKernel kernel = new StandardKernel(Modules); + return kernel; + } + } +} diff --git a/Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs b/Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d9cff75 --- /dev/null +++ b/Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs @@ -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("Shared.DependencyInjectionKernel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Shared.DependencyInjectionKernel")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("5f633149-4c66-4d34-98ab-28ee4662b442")] + +// 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")] diff --git a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj new file mode 100644 index 0000000..4471edd --- /dev/null +++ b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {5F633149-4C66-4D34-98AB-28EE4662B442} + Library + Properties + Shared.DependencyInjectionKernel + Shared.DependencyInjectionKernel + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + + + + + + + + + + + + + + + + + + + + {af26b020-f939-4353-a41d-f6c0f87d0b81} + Accessors.DatabaseAccessors + + + {20052ecb-4e1d-4f2f-9f06-79111fe381f8} + Managers.LazyCollectionOfAllManagers + + + + \ No newline at end of file diff --git a/Shared.DependencyInjectionKernel/packages.config b/Shared.DependencyInjectionKernel/packages.config new file mode 100644 index 0000000..8e2c684 --- /dev/null +++ b/Shared.DependencyInjectionKernel/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index a1cdb71..405bbcd 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -19,7 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accessors.DatabaseAccessors EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3B08858C-6FD1-47E7-824C-0B3F1D234455}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Solution Items", "0.Solution Items", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" ProjectSection(SolutionItems) = preProject README.md = README.md EndProjectSection @@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4.Accessors", "4.Accessors" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "5.Shared", "5.Shared", "{E1966F97-64AF-4CA1-9CDB-DA841C9491B9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionKernel", "Shared.DependencyInjectionKernel\Shared.DependencyInjectionKernel.csproj", "{5F633149-4C66-4D34-98AB-28EE4662B442}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -64,6 +66,10 @@ Global {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Release|Any CPU.Build.0 = Release|Any CPU + {5F633149-4C66-4D34-98AB-28EE4662B442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F633149-4C66-4D34-98AB-28EE4662B442}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F633149-4C66-4D34-98AB-28EE4662B442}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F633149-4C66-4D34-98AB-28EE4662B442}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -76,6 +82,7 @@ Global {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {AF26B020-F939-4353-A41D-F6C0F87D0B81} = {CA030337-D04B-4393-9869-897FA379EC1B} + {5F633149-4C66-4D34-98AB-28EE4662B442} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 822e29b..61cf66f 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -53,6 +53,9 @@ ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + @@ -64,6 +67,7 @@ + @@ -87,6 +91,10 @@ {49f40a81-dbbc-4904-96e3-e5ef1f7d2a7b} Shared.DataContracts + + {5F633149-4C66-4D34-98AB-28EE4662B442} + Shared.DependencyInjectionKernel + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} Tests.DataPrep diff --git a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs new file mode 100644 index 0000000..3d29124 --- /dev/null +++ b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs @@ -0,0 +1,47 @@ +using Accessors.DatabaseAccessors; +using Managers.LazyCollectionOfAllManagers; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Ninject; +using Shared.DependencyInjectionKernel; +using System; +using System.Collections.Generic; +using System.Linq; +using Telerik.JustMock.AutoMock.Ninject; +using Tests.DataPrep; + +namespace Tests.ManagerTests +{ + [TestClass] + public class TodoCRUDManagerIntegrationTests + { + //NOTE: Reuse of integration tests can also be done with inheritance + //However, it causes duplicate names and, if you want to keep your + //implementations private, it requires c# 7.2 for the private protected access modifier + + TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); + TodoDataPrep dataPrep; + TodoCRUDManager manager; + + [TestInitialize] + public void OnClassInit() + { + // Implicit self binding allows us to get a concrete class with fulfilled dependencies + // https://github.com/ninject/ninject/wiki/dependency-injection-with-ninject + Ninject.IKernel kernel = DependencyInjectionLoader.BuildKernel(); + manager = kernel.Get(); + + dataPrep = new TodoDataPrep(true); + + unitTests = new TodoCRUDManagerTests(manager, dataPrep); + } + + [TestMethod] + public void GetTodoItems_Integration() + { + // Want to test this is going to the DB? Try debugging and stepping through + // or setting dataprep persistance to false + unitTests.GetTodoItems(); + } + + } +} diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 153de11..384fc35 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -9,6 +9,7 @@ using Shared.DatabaseContext.DBOs; using Shared.DataContracts; using Telerik.JustMock.AutoMock; +using Tests.DataPrep; namespace Tests.ManagerTests { @@ -18,13 +19,24 @@ public class TodoCRUDManagerTests : ManagerTestBase TodoCRUDManager manager; MockingContainer mockContainer = new MockingContainer(); + public TodoCRUDManagerTests() { } + internal TodoCRUDManagerTests(TodoCRUDManager manager = null, TodoDataPrep dataPrep = null) + { + // this constructor allows for integration test reuse + this.manager = manager; + this.dataPrep = dataPrep ?? base.dataPrep; + } + public override void OnCleanup() { } public override void OnInitialize() { - manager = mockContainer.Instance; + if(manager == null) + { + manager = mockContainer.Instance; + } } [TestMethod] diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index 7f049fa..a3fb3cf 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -5,4 +5,5 @@ + \ No newline at end of file From 5f72e20f5622a5901e21f190b18e2ab7a924d8a6 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Thu, 8 Mar 2018 12:39:26 -0600 Subject: [PATCH 10/74] change up the integration reuse paradigm to prevent errors through constructor --- .../TodoCRUDManagerIntegrationTests.cs | 16 +++--------- Tests.ManagerTests/TodoCRUDManagerTests.cs | 26 +++++++++++++------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs index 3d29124..e8f2c1f 100644 --- a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs @@ -17,22 +17,14 @@ public class TodoCRUDManagerIntegrationTests //NOTE: Reuse of integration tests can also be done with inheritance //However, it causes duplicate names and, if you want to keep your //implementations private, it requires c# 7.2 for the private protected access modifier + // Though, I do suppose that you could pass in integration boolean TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); - TodoDataPrep dataPrep; - TodoCRUDManager manager; [TestInitialize] - public void OnClassInit() - { - // Implicit self binding allows us to get a concrete class with fulfilled dependencies - // https://github.com/ninject/ninject/wiki/dependency-injection-with-ninject - Ninject.IKernel kernel = DependencyInjectionLoader.BuildKernel(); - manager = kernel.Get(); - - dataPrep = new TodoDataPrep(true); - - unitTests = new TodoCRUDManagerTests(manager, dataPrep); + public void OnInit() + { + unitTests = new TodoCRUDManagerTests(true); } [TestMethod] diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 384fc35..2d44249 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -5,9 +5,11 @@ using DeepEqual.Syntax; using Managers.LazyCollectionOfAllManagers; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Ninject; using Shared.DatabaseContext; using Shared.DatabaseContext.DBOs; using Shared.DataContracts; +using Shared.DependencyInjectionKernel; using Telerik.JustMock.AutoMock; using Tests.DataPrep; @@ -19,12 +21,23 @@ public class TodoCRUDManagerTests : ManagerTestBase TodoCRUDManager manager; MockingContainer mockContainer = new MockingContainer(); - public TodoCRUDManagerTests() { } - internal TodoCRUDManagerTests(TodoCRUDManager manager = null, TodoDataPrep dataPrep = null) + public TodoCRUDManagerTests() : this(false) { } + public TodoCRUDManagerTests(bool isIntegration = false) { // this constructor allows for integration test reuse - this.manager = manager; - this.dataPrep = dataPrep ?? base.dataPrep; + if (isIntegration) + { + // Implicit self binding allows us to get a concrete class with fulfilled dependencies + // https://github.com/ninject/ninject/wiki/dependency-injection-with-ninject + Ninject.IKernel kernel = DependencyInjectionLoader.BuildKernel(); + manager = kernel.Get(); + dataPrep = new TodoDataPrep(true); + } + else + { + manager = mockContainer.Instance; + // dataPrep non-persistant by default in base class + } } public override void OnCleanup() @@ -33,10 +46,7 @@ public override void OnCleanup() public override void OnInitialize() { - if(manager == null) - { - manager = mockContainer.Instance; - } + } [TestMethod] From 92545e71c64f47f52bc202c7e758488f74f00940 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Thu, 8 Mar 2018 12:44:59 -0600 Subject: [PATCH 11/74] add inheritance example and improve notes on consequences --- .../TodoCRUDManagerIntegrationTests.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs index e8f2c1f..1cc0868 100644 --- a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs @@ -14,10 +14,9 @@ namespace Tests.ManagerTests [TestClass] public class TodoCRUDManagerIntegrationTests { - //NOTE: Reuse of integration tests can also be done with inheritance - //However, it causes duplicate names and, if you want to keep your - //implementations private, it requires c# 7.2 for the private protected access modifier - // Though, I do suppose that you could pass in integration boolean + // NOTE: Reuse of integration tests can also be done with inheritance + // However, it causes duplicate names and both integration and + // unit runs will be directed to the inherited class, making it unclear which test is which TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); @@ -36,4 +35,17 @@ public void GetTodoItems_Integration() } } + + [TestClass] + public class TodoCRUDManagerIntegrationWithInheritanceTests : TodoCRUDManagerTests + { + //NOTE: This does not allow you to create distinct names for clarity and both integration and + // unit runs will be directed to the inherited class, making it unclear which test is which + + public TodoCRUDManagerIntegrationWithInheritanceTests(): base(true) + { + } + + } + } From 575bad6504d01f8a70490771eb0c695820e939b1 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Thu, 8 Mar 2018 17:47:24 -0600 Subject: [PATCH 12/74] fill in accessor interface methods necessary to write managers --- .../TodoItemAccessor.cs | 15 ++++++ .../TodoListAccessor.cs | 28 ++++++++++- ...onManager.cs => ListExplorationManager.cs} | 0 Shared.DataContracts/DataConstants.cs | 13 ++++++ Shared.DataContracts/SaveResult.cs | 46 +++++++++++++++++++ .../TodoCRUDManagerIntegrationTests.cs | 7 +++ 6 files changed, 108 insertions(+), 1 deletion(-) rename Managers.LazyCollectionOfAllManagers/{ListExploreationManager.cs => ListExplorationManager.cs} (100%) create mode 100644 Shared.DataContracts/DataConstants.cs create mode 100644 Shared.DataContracts/SaveResult.cs diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index 60583df..654b6bc 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -12,10 +12,20 @@ namespace Accessors.DatabaseAccessors public interface ITodoItemAccessor { IEnumerable GetTodoItemsForList(Guid listId); + + SaveResult SaveTodoItem(TodoItem todoItem); + + DeleteResult DeleteTodoItem(Guid id); } class TodoItemAccessor : ITodoItemAccessor { TodoItem_Mapper mapper = new TodoItem_Mapper(); + + public DeleteResult DeleteTodoItem(Guid id) + { + throw new NotImplementedException(); + } + public IEnumerable GetTodoItemsForList(Guid listId) { IEnumerable todoItemList; @@ -26,5 +36,10 @@ public IEnumerable GetTodoItemsForList(Guid listId) } return todoItemList; } + + public SaveResult SaveTodoItem(TodoItem todoItem) + { + throw new NotImplementedException(); + } } } diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs index 3943f20..9a3ec5e 100644 --- a/Accessors.DatabaseAccessors/TodoListAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -1,4 +1,5 @@ -using System; +using Shared.DataContracts; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,10 +9,35 @@ namespace Accessors.DatabaseAccessors { public interface ITodoListAccessor { + TodoList GetTodoList(Guid id); + IEnumerable GetTodoListsForUser(Guid userId); + + SaveResult SaveTodoList(TodoList todoList); + + DeleteResult DeleteTodoList(Guid id); } class TodoListAccessor : ITodoListAccessor { + public DeleteResult DeleteTodoList(Guid id) + { + throw new NotImplementedException(); + } + + public TodoList GetTodoList(Guid id) + { + throw new NotImplementedException(); + } + + public IEnumerable GetTodoListsForUser(Guid userId) + { + throw new NotImplementedException(); + } + + public SaveResult SaveTodoList(TodoList todoList) + { + throw new NotImplementedException(); + } } } diff --git a/Managers.LazyCollectionOfAllManagers/ListExploreationManager.cs b/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs similarity index 100% rename from Managers.LazyCollectionOfAllManagers/ListExploreationManager.cs rename to Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs diff --git a/Shared.DataContracts/DataConstants.cs b/Shared.DataContracts/DataConstants.cs new file mode 100644 index 0000000..bb37079 --- /dev/null +++ b/Shared.DataContracts/DataConstants.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DataContracts +{ + public static class DataConstants + { + public static Guid DefaultId = Guid.Empty; + } +} diff --git a/Shared.DataContracts/SaveResult.cs b/Shared.DataContracts/SaveResult.cs new file mode 100644 index 0000000..bca6d46 --- /dev/null +++ b/Shared.DataContracts/SaveResult.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DataContracts +{ + public class SaveResult + { + public SaveResult(T result) + { + this.Result = result; + this.Success = true; + } + + public SaveResult(params string[] errors) + { + Errors = errors; + this.Success = false; + } + + public bool Success { get; set; } + + public T Result { get; set; } + + public IEnumerable Errors { get; set; } + + } + + public class DeleteResult + { + public DeleteResult(params string[] errors) + { + this.Success = errors.Count() == 0; + + this.Errors = errors; + } + + + public bool Success { get; set; } + + public IEnumerable Errors { get; set; } + + } +} diff --git a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs index 1cc0868..349fdb9 100644 --- a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs @@ -18,6 +18,13 @@ public class TodoCRUDManagerIntegrationTests // However, it causes duplicate names and both integration and // unit runs will be directed to the inherited class, making it unclear which test is which + // The downside of this method is that it requires manual maintenance + // Could explore the possibility of reflecting over a class's methods and raising an exception + // that highlights the failed method with a reason + + // Another alternative would be looking at generating a code file at build time with a plugin + // It would be a pretty simple plugin with simple emitted code + TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); [TestInitialize] From 6d85aeefbb51f267db4d06f1a9c2b2c64e3106dc Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Thu, 8 Mar 2018 18:30:39 -0600 Subject: [PATCH 13/74] fill out todoCRUD manager functions --- ...anagers.LazyCollectionOfAllManagers.csproj | 2 +- .../TodoCRUDManager.cs | 23 ++++--- .../Shared.DataContracts.csproj | 2 + .../ListExplorationManagerTests.cs | 62 +------------------ .../TodoCRUDManagerIntegrationTests.cs | 6 +- 5 files changed, 24 insertions(+), 71 deletions(-) diff --git a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj index cf6747f..2ed9e43 100644 --- a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj +++ b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj @@ -51,7 +51,7 @@ - + diff --git a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs index 33486b2..56700d9 100644 --- a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs +++ b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs @@ -10,13 +10,13 @@ namespace Managers.LazyCollectionOfAllManagers { public interface ITodoCRUDManager { - void GetTodoList(Guid id); + TodoList GetTodoList(Guid id); IEnumerable GetTodoItems(Guid listId); - void SaveTodoItem(); + SaveResult SaveTodoItem(TodoItem todoItem); - void SaveTodoList(); + SaveResult SaveTodoList(TodoList todoList); } internal class TodoCRUDManager : ITodoCRUDManager { @@ -28,25 +28,30 @@ public TodoCRUDManager(ITodoListAccessor todoListAccessor, ITodoItemAccessor tod this.todoItemAccessor = todoItemAccessor; } + // + // NOTE: These methods are currently all pass throughs because of the simple structure + // However, it is still worth having the manager to organize the functionality needed + // for this 'flow' in the application + // public IEnumerable GetTodoItems(Guid listId) { return todoItemAccessor.GetTodoItemsForList(listId); } - public void GetTodoList(Guid id) + public TodoList GetTodoList(Guid id) { - throw new NotImplementedException(); + return todoListAccessor.GetTodoList(id); } - public void SaveTodoItem() + public SaveResult SaveTodoItem(TodoItem todoItem) { - throw new NotImplementedException(); + return todoItemAccessor.SaveTodoItem(todoItem); } - public void SaveTodoList() + public SaveResult SaveTodoList(TodoList todoList) { - throw new NotImplementedException(); + return todoListAccessor.SaveTodoList(todoList); } } } diff --git a/Shared.DataContracts/Shared.DataContracts.csproj b/Shared.DataContracts/Shared.DataContracts.csproj index afdeae2..3a9f7f8 100644 --- a/Shared.DataContracts/Shared.DataContracts.csproj +++ b/Shared.DataContracts/Shared.DataContracts.csproj @@ -40,7 +40,9 @@ + + diff --git a/Tests.ManagerTests/ListExplorationManagerTests.cs b/Tests.ManagerTests/ListExplorationManagerTests.cs index 6644d3c..efd49f1 100644 --- a/Tests.ManagerTests/ListExplorationManagerTests.cs +++ b/Tests.ManagerTests/ListExplorationManagerTests.cs @@ -23,68 +23,12 @@ public override void OnCleanup() { } - //[TestMethod] - //public void GetUserStats_UglyAndLong() - //{ - // //Create User - // UserDBO user = new UserDBO() - // { - // Id = Guid.NewGuid(), - // Name = "Bob", - // }; - - - // //Create Todo lists - - // //TODO: turn this into dataprep.CreateTodoListsWithItems - // List expectedLists = new List(); - // int expectedListCount = 5; - // for (int i = 0; i < expectedListCount; i++) - // { - // TodoListDBO expectedList = new TodoListDBO() { - // Id = Guid.NewGuid(), - // UserId = user.Id, - // Title = Guid.NewGuid().ToString(), - // }; - // } - - // //Create items, complete and incomplete - // foreach (TodoList expectedList in expectedLists) - // { - - // } - - // UserAccountStats stats = manager.GetUserStats(user.Id); - - // Assert.AreEqual(expectedListCount, stats.TodoListCount); - - - //} - - [TestMethod] - public void GetUserStats_Final() - { - //Create User - - //Create Todo lists - - //Create items, complete and incomplete - - - - } + [TestMethod] - public void GetUserStats_Integration() + public void GetUserStats() { - //Create User - - //Create Todo lists - - //Create items, complete and incomplete - - - + Assert.Inconclusive("Untested: untested as an example of code marking"); } diff --git a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs index 349fdb9..f3c1256 100644 --- a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs @@ -19,11 +19,13 @@ public class TodoCRUDManagerIntegrationTests // unit runs will be directed to the inherited class, making it unclear which test is which // The downside of this method is that it requires manual maintenance - // Could explore the possibility of reflecting over a class's methods and raising an exception + // Alt 1: Could explore the possibility of reflecting over a class's methods and raising an exception // that highlights the failed method with a reason - // Another alternative would be looking at generating a code file at build time with a plugin + // Alt 2: Another alternative would be looking at generating a code file at build time with a plugin // It would be a pretty simple plugin with simple emitted code + + // Alt 3: try extending TestMethod or TestClass to run tests twice TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); From 6920837a4ea3f216e3dfc41b26b2aafd8173317a Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 15:14:04 -0500 Subject: [PATCH 14/74] Basic attribute allowing test name prefixes based on subject type --- README.md | 2 + .../Properties/AssemblyInfo.cs | 36 ++++++ .../Test.NUnitExtensions.csproj | 53 +++++++++ Test.NUnitExtensions/TestFixture_Prefixed.cs | 53 +++++++++ Test.NUnitExtensions/packages.config | 4 + TestingExemplar.sln | 7 ++ Tests.AccessorTests/AccessorTestBase.cs | 5 +- .../Tests.AccessorTests.csproj | 7 ++ Tests.AccessorTests/TodoItemAccessorTests.cs | 9 +- Tests.AccessorTests/packages.config | 1 + Tests.DataPrep/TodoItemPrep.cs | 4 +- .../MSTest_IntegrationReuseExample.cs | 112 ++++++++++++++++++ Tests.ManagerTests/ManagerTestBase.cs | 7 +- Tests.ManagerTests/README_IntegrationReuse.md | 48 ++++++++ Tests.ManagerTests/Tests.ManagerTests.csproj | 12 +- .../TodoCRUDManagerIntegrationTests.cs | 60 ---------- Tests.ManagerTests/TodoCRUDManagerTests.cs | 16 ++- Tests.ManagerTests/packages.config | 2 + 18 files changed, 362 insertions(+), 76 deletions(-) create mode 100644 Test.NUnitExtensions/Properties/AssemblyInfo.cs create mode 100644 Test.NUnitExtensions/Test.NUnitExtensions.csproj create mode 100644 Test.NUnitExtensions/TestFixture_Prefixed.cs create mode 100644 Test.NUnitExtensions/packages.config create mode 100644 Tests.ManagerTests/MSTest_IntegrationReuseExample.cs create mode 100644 Tests.ManagerTests/README_IntegrationReuse.md delete mode 100644 Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs diff --git a/README.md b/README.md index a8c6515..19ba6be 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,13 @@ Patterns - DataPrep (centralized test data generators) - ConfigWrappers //pending - Inconclusive tests to mark untested code // pending +- Test name modification for test runner (display extra info without manually adding it to each test name) Libraries - JustMock (test dependency generator; https://www.telerik.com/products/mocking.aspx) - alternatives: Moq, MSFakes, RhinoMocks - DeepEqual (https://github.com/jamesfoster/DeepEqual) + - alternatives: NUnit.DeepObjectCompare (https://github.com/PolarbearDK/NUnit.DeepObjectCompare) - Bogus (https://github.com/bchavez/Bogus) - alternatives: AutoFixture - .NET Transactions TransactionScope diff --git a/Test.NUnitExtensions/Properties/AssemblyInfo.cs b/Test.NUnitExtensions/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..448a990 --- /dev/null +++ b/Test.NUnitExtensions/Properties/AssemblyInfo.cs @@ -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("Test.NUnitExtensions")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Test.NUnitExtensions")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("3ac5c65a-6f68-479c-a078-3d2e573111bb")] + +// 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")] diff --git a/Test.NUnitExtensions/Test.NUnitExtensions.csproj b/Test.NUnitExtensions/Test.NUnitExtensions.csproj new file mode 100644 index 0000000..762d724 --- /dev/null +++ b/Test.NUnitExtensions/Test.NUnitExtensions.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {3AC5C65A-6F68-479C-A078-3D2E573111BB} + Library + Properties + Test.NUnitExtensions + Test.NUnitExtensions + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test.NUnitExtensions/TestFixture_Prefixed.cs b/Test.NUnitExtensions/TestFixture_Prefixed.cs new file mode 100644 index 0000000..d6e762d --- /dev/null +++ b/Test.NUnitExtensions/TestFixture_Prefixed.cs @@ -0,0 +1,53 @@ +using NUnit.Framework; +using NUnit.Framework.Interfaces; +using NUnit.Framework.Internal; +using NUnit.Framework.Internal.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Test.NUnitExtensions +{ + public class TestFixture_PrefixedAttribute : NUnitAttribute, IFixtureBuilder + { + string _prefix; + + public TestFixture_PrefixedAttribute(Type subjectType) + { + _prefix = subjectType.Name; + } + + public TestFixture_PrefixedAttribute(string prefix) + { + this._prefix = prefix; + } + + public IEnumerable BuildFrom(ITypeInfo typeInfo) + { + NUnitTestFixtureBuilder b = new NUnitTestFixtureBuilder(); + TestSuite testSuite = b.BuildFrom(typeInfo); + foreach (NUnit.Framework.Internal.Test t in testSuite.Tests) + { + t.Name = $"{_prefix}_{t.Name}"; + } + yield return testSuite; + } + } + + //public class Test_MethodPrefixAttribute : NUnitAttribute, ISimpleTestBuilder + //{ + + + + // // this actually works to change the test name, but it would have to be on every test + // TestMethod ISimpleTestBuilder.BuildFrom(IMethodInfo method, NUnit.Framework.Internal.Test suite) + // { + // TestMethod testMethod = new TestMethod(method, suite); + // testMethod.Name = $"{testMethod.ClassName}_{testMethod.MethodName}"; + + // return testMethod; + // } + //} +} diff --git a/Test.NUnitExtensions/packages.config b/Test.NUnitExtensions/packages.config new file mode 100644 index 0000000..b93fa21 --- /dev/null +++ b/Test.NUnitExtensions/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index 405bbcd..65f6118 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -32,6 +32,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "5.Shared", "5.Shared", "{E1 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionKernel", "Shared.DependencyInjectionKernel\Shared.DependencyInjectionKernel.csproj", "{5F633149-4C66-4D34-98AB-28EE4662B442}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.NUnitExtensions", "Test.NUnitExtensions\Test.NUnitExtensions.csproj", "{3AC5C65A-6F68-479C-A078-3D2E573111BB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -70,6 +72,10 @@ Global {5F633149-4C66-4D34-98AB-28EE4662B442}.Debug|Any CPU.Build.0 = Debug|Any CPU {5F633149-4C66-4D34-98AB-28EE4662B442}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F633149-4C66-4D34-98AB-28EE4662B442}.Release|Any CPU.Build.0 = Release|Any CPU + {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -83,6 +89,7 @@ Global {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {AF26B020-F939-4353-A41D-F6C0F87D0B81} = {CA030337-D04B-4393-9869-897FA379EC1B} {5F633149-4C66-4D34-98AB-28EE4662B442} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} + {3AC5C65A-6F68-479C-A078-3D2E573111BB} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} diff --git a/Tests.AccessorTests/AccessorTestBase.cs b/Tests.AccessorTests/AccessorTestBase.cs index 6850d88..8aeeb4a 100644 --- a/Tests.AccessorTests/AccessorTestBase.cs +++ b/Tests.AccessorTests/AccessorTestBase.cs @@ -1,4 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Shared.DatabaseContext; using System.Transactions; using Tests.DataPrep; @@ -10,7 +11,7 @@ public abstract class AccessorTestBase protected TodoDataPrep dataPrep = new TodoDataPrep(true); protected TransactionScope _transactionScope; - [TestInitialize] + [SetUp] public virtual void TestInitialize() { TodoContext database = new TodoContext(); @@ -23,7 +24,7 @@ public virtual void TestInitialize() public abstract void OnInitialize(); - [TestCleanup] + [TearDown] public virtual void TestCleanup() { _transactionScope.Dispose(); diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index bd60dae..48cdde7 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -53,6 +53,9 @@ ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + @@ -83,6 +86,10 @@ {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} Shared.DataContracts + + {3AC5C65A-6F68-479C-A078-3D2E573111BB} + Test.NUnitExtensions + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} Tests.DataPrep diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs index db28056..f998aa0 100644 --- a/Tests.AccessorTests/TodoItemAccessorTests.cs +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -3,14 +3,15 @@ using System.Linq; using Accessors.DatabaseAccessors; using DeepEqual.Syntax; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Shared.DatabaseContext; using Shared.DatabaseContext.DBOs; using Shared.DataContracts; +using Test.NUnitExtensions; namespace Tests.AccessorTests { - [TestClass] + [TestFixture_Prefixed(typeof(TodoItemAccessor))] public class TodoItemAccessorTests : AccessorTestBase { TodoItemAccessor accessor; @@ -19,7 +20,7 @@ public override void OnInitialize() accessor = new TodoItemAccessor(); } - [TestMethod] + [Test] public void GetTodoItems_Ugly() { @@ -78,7 +79,7 @@ public void GetTodoItems_Ugly() } - [TestMethod] + [Test] public void GetTodoItems_Final() { // arrange diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config index 7f049fa..5336859 100644 --- a/Tests.AccessorTests/packages.config +++ b/Tests.AccessorTests/packages.config @@ -5,4 +5,5 @@ + \ No newline at end of file diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index b462d62..4f1cc51 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -21,7 +21,7 @@ public TodoItemPrep(ITestDataAccessor dataAccessor, TodoListPrep todoListPrep) this.todoListPrep = todoListPrep; } - public TodoItem Create(TodoList todoList = null) + public TodoItem Create(TodoList todoList = null, bool? isComplete = null) { TodoList sanitizedTodoList = todoList ?? todoListPrep.Create(); @@ -29,7 +29,7 @@ public TodoItem Create(TodoList todoList = null) { TodoListId = sanitizedTodoList.Id, Description = random.Lorem.Sentence(), - IsComplete = random.PickRandom(true, false), + IsComplete = isComplete ?? random.PickRandom(true, false), }; TodoItem savedItem = Create(todoItem); diff --git a/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs b/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs new file mode 100644 index 0000000..d587efd --- /dev/null +++ b/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs @@ -0,0 +1,112 @@ +using Accessors.DatabaseAccessors; +using DeepEqual.Syntax; +using Managers.LazyCollectionOfAllManagers; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Ninject; +using Shared.DataContracts; +using Shared.DependencyInjectionKernel; +using System; +using System.Collections.Generic; +using System.Linq; +using Telerik.JustMock.AutoMock; +using Telerik.JustMock.AutoMock.Ninject; +using Tests.DataPrep; + +namespace Tests.ManagerTests +{ + [TestClass] + public class MSTest_UnitTest + { + TodoCRUDManager manager; + TodoDataPrep dataPrep; + MockingContainer mockContainer = new MockingContainer(); + + public MSTest_UnitTest() : this(false) { } + public MSTest_UnitTest(bool isIntegration = false) + { + // this constructor allows for integration test reuse + if (isIntegration) + { + // Implicit self binding allows us to get a concrete class with fulfilled dependencies + // https://github.com/ninject/ninject/wiki/dependency-injection-with-ninject + Ninject.IKernel kernel = DependencyInjectionLoader.BuildKernel(); + manager = kernel.Get(); + dataPrep = new TodoDataPrep(true); + } + else + { + manager = mockContainer.Instance; + dataPrep = new TodoDataPrep(false); + } + } + + [TestMethod] + public void MSTest_GetTodoItems() + { + + // arrange + TodoList todoList = dataPrep.TodoLists.Create(); + int expectedItemCount = 5; + IEnumerable expectedItemList = dataPrep.TodoItems.CreateManyForList(expectedItemCount, todoList); + + mockContainer.Arrange(accessor => accessor.GetTodoItemsForList(todoList.Id)).Returns(expectedItemList); + + // act + IEnumerable actualItemList = manager.GetTodoItems(todoList.Id); + + //assert + expectedItemList.ShouldDeepEqual(actualItemList); + } + } + + [TestClass] + public class MSTest_IntegrationReuse + { + // NOTE: Reuse of integration tests can also be done with inheritance + // However, it causes duplicate names and both integration and + // unit runs will be directed to the inherited class, making it unclear which test is which + + // The downside of this method is that it requires manual maintenance + // Alt 1: Could explore the possibility of reflecting over a class's methods and raising an exception + // that highlights the failed method with a reason + + // Alt 2: Another alternative would be looking at generating a code file at build time with a plugin + // It would be a pretty simple plugin with simple emitted code + + // Alt 3: try extending TestMethod or TestClass to run tests twice + + // Conclusion: use NUnit for simpler and more powerful test extension + + TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); + + [TestInitialize] + public void OnInit() + { + unitTests = new TodoCRUDManagerTests(true); + } + + [TestMethod] + public void MSTest_GetTodoItems_Integration() + { + // Want to test this is going to the DB? Try debugging and stepping through + // or setting dataprep persistance to false + unitTests.GetTodoItems(); + } + + } + + [TestClass] + public class MSTest_IntegrationReuse_Inherited : MSTest_UnitTest + { + //NOTE: This does not allow you to create distinct names for clarity and both integration and + // unit runs will be directed to the inherited class, making it unclear which test is which + + // Use NUnit for simpler and more powerful test extension + + public MSTest_IntegrationReuse_Inherited() : base(true) + { + } + + } + +} diff --git a/Tests.ManagerTests/ManagerTestBase.cs b/Tests.ManagerTests/ManagerTestBase.cs index 17d4c5d..8d593b9 100644 --- a/Tests.ManagerTests/ManagerTestBase.cs +++ b/Tests.ManagerTests/ManagerTestBase.cs @@ -1,4 +1,5 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +//using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Tests.DataPrep; namespace Tests.ManagerTests @@ -8,7 +9,7 @@ public abstract class ManagerTestBase protected TodoDataPrep dataPrep = new TodoDataPrep(false); public abstract void OnInitialize(); - [TestInitialize] + [SetUp] public virtual void TestInitialize() { OnInitialize(); @@ -16,7 +17,7 @@ public virtual void TestInitialize() public abstract void OnCleanup(); - [TestCleanup] + [TearDown] public virtual void TestCleanup() { OnCleanup(); diff --git a/Tests.ManagerTests/README_IntegrationReuse.md b/Tests.ManagerTests/README_IntegrationReuse.md new file mode 100644 index 0000000..dc86472 --- /dev/null +++ b/Tests.ManagerTests/README_IntegrationReuse.md @@ -0,0 +1,48 @@ +# Integration Reuse WhiteDoc (discovery process) + +TL;DR; Discovered that NUnit is much more powerful than MSTest + +I started out using MSTest. Integration tests could be reused in several ways + +1. Creating a second class, instantiating the unit test class with a full DI configuration and dataprep set to persist. +Then create a test method that calls into each method on the unit test class you want to reuse +- Pros: clear names and differentiation in the test runner. Can pick and choose methods to reuse. +- cons: lots of manual maintenence +2. Inherit from the original test class, modifying the constructor to specify integration mode +-Pros: No additional changes when test names are added/removed/renamed +-Cons: it causes duplicate names and both integration and unit runs will be directed to the inherited class, making it unclear which test is which + +3. Reflecting over a class's methods and raising an exception that highlights the failed method with a reason + - Cons: still collapses test runs in test explorer. Reflection is slow + +4. Generating a code file at build time with a plugin. It would be a pretty simple plugin with simple emitted code +- Cons: have to write and run additional code as well as install an extension + +5. Try extending TestMethod or TestClass to run tests twice + +Alternative #5 led me to explore extensibility in MSTest. In short, it is kinda limited and does not let you set the test name. +How to extend MSTest here +- https://blogs.msdn.microsoft.com/devops/2017/07/18/extending-mstest-v2/ +- https://github.com/Microsoft/testfx-docs/blob/master/RFCs/003-Customize-Running-Tests.md + +However, NUnit can handle runs with different parameters out of the box. It has much more powerful functionality and extensibility. + +NOTE: you can run MSTest and NUnit side by side, which makes it very easy to transition progressively + +The question is now how to generate differentiated names in the test runner with NUnit. +- https://www.red-gate.com/simple-talk/dotnet/net-tools/testing-times-ahead-extending-nunit/ +- https://github.com/nunit/docs/wiki/Custom-Attributes +- https://github.com/nunit/docs/wiki/Writing-Engine-Extensions +- Could probably use TestCase attributes to define integration/not on each method. A bit verbose, non-semantic, and extra init work +- NOTE: Changing the test name with something like IApplyToTest is not changing the name in the test runner +- NOTE: NUnit supports test name string formatting https://stackoverflow.com/questions/26374265/access-nunit-test-name-within-testcasesource + +- Conclusion: The rules for name generation are not very clear in NUnit. + However, I have verified that you can sucessfully overwrite the name in either + the test builder or the fixture builder. + It is not entirely clear how to extend these types while maintaining behavior + because you cannot override when you inherit from the default attributes. Instead, + the logic is available through internal builders and type constructors. + + +BONUS: Interesting thread on using NUnit tests to augment documentation https://stackoverflow.com/questions/8727684/how-can-i-generate-documentation-from-nunit-tests \ No newline at end of file diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 61cf66f..8a18c1f 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -1,5 +1,6 @@  + Debug @@ -56,6 +57,9 @@ ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + @@ -67,12 +71,13 @@ - + + @@ -95,6 +100,10 @@ {5F633149-4C66-4D34-98AB-28EE4662B442} Shared.DependencyInjectionKernel + + {3AC5C65A-6F68-479C-A078-3D2E573111BB} + Test.NUnitExtensions + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} Tests.DataPrep @@ -108,6 +117,7 @@ + \ No newline at end of file diff --git a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs b/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs deleted file mode 100644 index f3c1256..0000000 --- a/Tests.ManagerTests/TodoCRUDManagerIntegrationTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Accessors.DatabaseAccessors; -using Managers.LazyCollectionOfAllManagers; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Ninject; -using Shared.DependencyInjectionKernel; -using System; -using System.Collections.Generic; -using System.Linq; -using Telerik.JustMock.AutoMock.Ninject; -using Tests.DataPrep; - -namespace Tests.ManagerTests -{ - [TestClass] - public class TodoCRUDManagerIntegrationTests - { - // NOTE: Reuse of integration tests can also be done with inheritance - // However, it causes duplicate names and both integration and - // unit runs will be directed to the inherited class, making it unclear which test is which - - // The downside of this method is that it requires manual maintenance - // Alt 1: Could explore the possibility of reflecting over a class's methods and raising an exception - // that highlights the failed method with a reason - - // Alt 2: Another alternative would be looking at generating a code file at build time with a plugin - // It would be a pretty simple plugin with simple emitted code - - // Alt 3: try extending TestMethod or TestClass to run tests twice - - TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); - - [TestInitialize] - public void OnInit() - { - unitTests = new TodoCRUDManagerTests(true); - } - - [TestMethod] - public void GetTodoItems_Integration() - { - // Want to test this is going to the DB? Try debugging and stepping through - // or setting dataprep persistance to false - unitTests.GetTodoItems(); - } - - } - - [TestClass] - public class TodoCRUDManagerIntegrationWithInheritanceTests : TodoCRUDManagerTests - { - //NOTE: This does not allow you to create distinct names for clarity and both integration and - // unit runs will be directed to the inherited class, making it unclear which test is which - - public TodoCRUDManagerIntegrationWithInheritanceTests(): base(true) - { - } - - } - -} diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 2d44249..fcca981 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -4,18 +4,20 @@ using Accessors.DatabaseAccessors; using DeepEqual.Syntax; using Managers.LazyCollectionOfAllManagers; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Ninject; +using NUnit.Framework; using Shared.DatabaseContext; using Shared.DatabaseContext.DBOs; using Shared.DataContracts; using Shared.DependencyInjectionKernel; using Telerik.JustMock.AutoMock; +using Test.NUnitExtensions; using Tests.DataPrep; namespace Tests.ManagerTests { - [TestClass] + + [TestFixture_Prefixed(typeof(TodoCRUDManager))] public class TodoCRUDManagerTests : ManagerTestBase { TodoCRUDManager manager; @@ -49,10 +51,15 @@ public override void OnInitialize() } - [TestMethod] - public void GetTodoItems() + private static IEnumerable TestData() { + yield return new TestCaseData().SetName("yo dog"); + } + //[TestCaseSource("TestData")] + [Test] + public void GetTodoItems() + { // arrange TodoList todoList = dataPrep.TodoLists.Create(); int expectedItemCount = 5; @@ -67,4 +74,5 @@ public void GetTodoItems() expectedItemList.ShouldDeepEqual(actualItemList); } } + } diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index a3fb3cf..ad69891 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -6,4 +6,6 @@ + + \ No newline at end of file From a380164a6a49328889b04ebb0e0b28af35ca02c6 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 16:13:26 -0500 Subject: [PATCH 15/74] Restore ability to run test fixture with arguments and pre-pend to name --- Test.NUnitExtensions/TestFixture_Prefixed.cs | 8 ++++---- Tests.ManagerTests/TodoCRUDManagerTests.cs | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Test.NUnitExtensions/TestFixture_Prefixed.cs b/Test.NUnitExtensions/TestFixture_Prefixed.cs index d6e762d..fa72fa7 100644 --- a/Test.NUnitExtensions/TestFixture_Prefixed.cs +++ b/Test.NUnitExtensions/TestFixture_Prefixed.cs @@ -10,16 +10,16 @@ namespace Test.NUnitExtensions { - public class TestFixture_PrefixedAttribute : NUnitAttribute, IFixtureBuilder + public class TestFixture_PrefixedAttribute : TestFixtureAttribute, IFixtureBuilder { string _prefix; - public TestFixture_PrefixedAttribute(Type subjectType) + public TestFixture_PrefixedAttribute(Type subjectType, params object[] arguments) : base(arguments) { _prefix = subjectType.Name; } - public TestFixture_PrefixedAttribute(string prefix) + public TestFixture_PrefixedAttribute(string prefix, params object[] arguments) : base(arguments) { this._prefix = prefix; } @@ -27,7 +27,7 @@ public TestFixture_PrefixedAttribute(string prefix) public IEnumerable BuildFrom(ITypeInfo typeInfo) { NUnitTestFixtureBuilder b = new NUnitTestFixtureBuilder(); - TestSuite testSuite = b.BuildFrom(typeInfo); + TestSuite testSuite = b.BuildFrom(typeInfo, this); foreach (NUnit.Framework.Internal.Test t in testSuite.Tests) { t.Name = $"{_prefix}_{t.Name}"; diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index fcca981..8a564aa 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -16,8 +16,8 @@ namespace Tests.ManagerTests { - - [TestFixture_Prefixed(typeof(TodoCRUDManager))] + [TestFixture_Prefixed(typeof(TodoCRUDManager), false)] + [TestFixture_Prefixed(typeof(TodoCRUDManager), true)] public class TodoCRUDManagerTests : ManagerTestBase { TodoCRUDManager manager; @@ -55,8 +55,7 @@ private static IEnumerable TestData() { yield return new TestCaseData().SetName("yo dog"); } - - //[TestCaseSource("TestData")] + [Test] public void GetTodoItems() { From bbb91e2d003a6b1375579923bea7ae90af0f30a8 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 20:51:17 -0500 Subject: [PATCH 16/74] Fix mistaken cross reference between MS_Test class and NUnit tests --- Test.NUnitExtensions/TestFixture_Prefixed.cs | 4 ++++ Tests.ManagerTests/MSTest_IntegrationReuseExample.cs | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Test.NUnitExtensions/TestFixture_Prefixed.cs b/Test.NUnitExtensions/TestFixture_Prefixed.cs index fa72fa7..8192d23 100644 --- a/Test.NUnitExtensions/TestFixture_Prefixed.cs +++ b/Test.NUnitExtensions/TestFixture_Prefixed.cs @@ -26,6 +26,10 @@ public TestFixture_PrefixedAttribute(string prefix, params object[] arguments) : public IEnumerable BuildFrom(ITypeInfo typeInfo) { + // TODO: the name set here will still get overridden by a test case. Figure out how to + // build on top of the test case name instead + // This possibly implies that cases are built after the fixture methods run + // https://groups.google.com/forum/#!topic/nunit-discuss/PT0NQaL7AMg NUnitTestFixtureBuilder b = new NUnitTestFixtureBuilder(); TestSuite testSuite = b.BuildFrom(typeInfo, this); foreach (NUnit.Framework.Internal.Test t in testSuite.Tests) diff --git a/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs b/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs index d587efd..1136ea0 100644 --- a/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs +++ b/Tests.ManagerTests/MSTest_IntegrationReuseExample.cs @@ -77,12 +77,12 @@ public class MSTest_IntegrationReuse // Conclusion: use NUnit for simpler and more powerful test extension - TodoCRUDManagerTests unitTests = new TodoCRUDManagerTests(); + MSTest_UnitTest unitTests = new MSTest_UnitTest(); [TestInitialize] public void OnInit() { - unitTests = new TodoCRUDManagerTests(true); + unitTests = new MSTest_UnitTest(true); } [TestMethod] @@ -90,7 +90,7 @@ public void MSTest_GetTodoItems_Integration() { // Want to test this is going to the DB? Try debugging and stepping through // or setting dataprep persistance to false - unitTests.GetTodoItems(); + unitTests.MSTest_GetTodoItems(); } } From d17623486813e5e74d626112d1b6e66743e70e50 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 20:54:16 -0500 Subject: [PATCH 17/74] remove the now unused test case data --- Tests.ManagerTests/TodoCRUDManagerTests.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 8a564aa..e53a4a6 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -50,11 +50,6 @@ public override void OnInitialize() { } - - private static IEnumerable TestData() - { - yield return new TestCaseData().SetName("yo dog"); - } [Test] public void GetTodoItems() From 183fd5a6a0a45806a52db04a0da440b8b644c434 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 21:16:25 -0500 Subject: [PATCH 18/74] basic manager tests for TodoCrudManager --- Tests.DataPrep/DataPrep.cs | 4 +- Tests.ManagerTests/TodoCRUDManagerTests.cs | 53 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Tests.DataPrep/DataPrep.cs b/Tests.DataPrep/DataPrep.cs index a88d612..f2edaca 100644 --- a/Tests.DataPrep/DataPrep.cs +++ b/Tests.DataPrep/DataPrep.cs @@ -1,4 +1,5 @@ -using System; +using Bogus; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,6 +10,7 @@ namespace Tests.DataPrep public class TodoDataPrep { ITestDataAccessor dataPersistance; + public UserPrep Users { get; set; } public TodoListPrep TodoLists { get; set; } diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index e53a4a6..179b87b 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -10,6 +10,7 @@ using Shared.DatabaseContext.DBOs; using Shared.DataContracts; using Shared.DependencyInjectionKernel; +using Telerik.JustMock; using Telerik.JustMock.AutoMock; using Test.NUnitExtensions; using Tests.DataPrep; @@ -67,6 +68,58 @@ public void GetTodoItems() //assert expectedItemList.ShouldDeepEqual(actualItemList); } + + [Test] + public void GetTodoList() + { + // arrange + TodoList expectedTodoList = dataPrep.TodoLists.Create(); + + mockContainer.Arrange(accessor => accessor.GetTodoList(expectedTodoList.Id)).Returns(expectedTodoList); + + // act + TodoList actualTodoList = manager.GetTodoList(expectedTodoList.Id); + + //assert + expectedTodoList.ShouldDeepEqual(actualTodoList); + } + + [Test] + public void SaveTodoItem() + { + // arrange + TodoItem expectedTodoItem = dataPrep.TodoItems.Create(); + + expectedTodoItem.Description = Guid.NewGuid().ToString(); + + mockContainer.Arrange(accessor => accessor.SaveTodoItem(expectedTodoItem)).Returns(new SaveResult(expectedTodoItem)); + + // act + SaveResult todoItemResult = manager.SaveTodoItem(expectedTodoItem); + TodoItem actualTodoItem = todoItemResult.Result; + + //assert + Assert.IsTrue(todoItemResult.Success); + // because we mutated the expected object, the changed property is as expected on the original object too + expectedTodoItem.ShouldDeepEqual(actualTodoItem); + } + + [Test] + public void SaveTodoList() + { + // arrange + TodoList expectedTodoList = dataPrep.TodoLists.Create(); + expectedTodoList.Title = Guid.NewGuid().ToString(); + + mockContainer.Arrange(accessor => accessor.SaveTodoList(Arg.IsAny())).Returns(new SaveResult(expectedTodoList)); + + // act + SaveResult todoListResult = manager.SaveTodoList(expectedTodoList); + + //assert + Assert.IsTrue(todoListResult.Success); + expectedTodoList.ShouldDeepEqual(todoListResult.Result); + } } } From f73bf0d271753e427972ed955a8dc03be94f33c3 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 21:25:56 -0500 Subject: [PATCH 19/74] Implement basic TodoItemAccessor functions --- .../TodoItemAccessor.cs | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index 654b6bc..d56a0e6 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -3,6 +3,7 @@ using Shared.DataContracts; using System; using System.Collections.Generic; +using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -23,7 +24,17 @@ class TodoItemAccessor : ITodoItemAccessor public DeleteResult DeleteTodoItem(Guid id) { - throw new NotImplementedException(); + using (TodoContext db = new TodoContext()) + { + TodoItemDBO todoItemModel = db.TodoItems.FirstOrDefault(ti => ti.Id == id); + todoItemModel.IsActive = false; + + db.SaveChanges(); + + DeleteResult deleteResult = new DeleteResult(); + + return deleteResult; + } } public IEnumerable GetTodoItemsForList(Guid listId) @@ -39,7 +50,26 @@ public IEnumerable GetTodoItemsForList(Guid listId) public SaveResult SaveTodoItem(TodoItem todoItem) { - throw new NotImplementedException(); + using (TodoContext db = new TodoContext()) + { + TodoItemDBO dbModel = mapper.ContractToModel(todoItem); + + if(todoItem.Id == DataConstants.DefaultId) + { + db.TodoItems.Add(dbModel); + } + else + { + db.TodoItems.Attach(dbModel); + db.Entry(dbModel).State = EntityState.Modified; + } + db.SaveChanges(); + + TodoItem savedTodoItem = mapper.ModelToContract(dbModel); + + SaveResult saveResult = new SaveResult(savedTodoItem); + return saveResult; + } } } } From 5e2196bbce5205763dcb40d9242dd8692e3bd462 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 21:40:20 -0500 Subject: [PATCH 20/74] Finish Marking ListExplorationManager as an example of --- .../ListExplorationManagerTests.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Tests.ManagerTests/ListExplorationManagerTests.cs b/Tests.ManagerTests/ListExplorationManagerTests.cs index efd49f1..2b2f090 100644 --- a/Tests.ManagerTests/ListExplorationManagerTests.cs +++ b/Tests.ManagerTests/ListExplorationManagerTests.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; using Managers.LazyCollectionOfAllManagers; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Shared.DataContracts; using Telerik.JustMock.AutoMock; namespace Tests.ManagerTests { - [TestClass] + [TestFixture] public class ListExplorationManagerTests : ManagerTestBase { MockingContainer mockContainer; @@ -25,12 +25,20 @@ public override void OnCleanup() - [TestMethod] + [Test] public void GetUserStats() { - Assert.Inconclusive("Untested: untested as an example of code marking"); + Assert.Inconclusive("Untested: untested as an example of code marking. These markers are usually reserved for legacy code or unverifiable external dependencies"); + User user = dataPrep.Users.Create(); + manager.GetUserStats(user.Id); } - + [Test] + public void GetUserLists() + { + Assert.Inconclusive("Untested: untested as an example of code marking. These markers are usually reserved for legacy code or unverifiable external dependencies"); + User user = dataPrep.Users.Create(); + manager.GetUserLists(user.Id); + } } } From 3fbee71dec51c9c19c6ccc2904670bbcc22281fb Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 21:58:40 -0500 Subject: [PATCH 21/74] fill in test for todoItemAccessor --- Tests.AccessorTests/TodoItemAccessorTests.cs | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs index f998aa0..24fd4f0 100644 --- a/Tests.AccessorTests/TodoItemAccessorTests.cs +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -94,5 +94,59 @@ public void GetTodoItems_Final() expectedItemList.ShouldDeepEqual(actualItemList); } + [Test] + public void SaveTodoItem_Update() + { + // arrange + TodoItem expectedTodoItem = dataPrep.TodoItems.Create(); + expectedTodoItem.Description = Guid.NewGuid().ToString(); + + // act + SaveResult saveResult = accessor.SaveTodoItem(expectedTodoItem); + TodoItem actualTodoItem = saveResult.Result; + + //assert + Assert.IsTrue(saveResult.Success); + expectedTodoItem.ShouldDeepEqual(actualTodoItem); + } + + [Test] + public void SaveTodoItem_Create() + { + // arrange + TodoList parentList = dataPrep.TodoLists.Create(); + TodoItem expectedTodoItem = new TodoItem() + { + TodoListId = parentList.Id, + Description = Guid.NewGuid().ToString(), + IsComplete = false, + }; + + // act + SaveResult saveResult = accessor.SaveTodoItem(expectedTodoItem); + TodoItem actualTodoItem = saveResult.Result; + + //assert + Assert.IsTrue(saveResult.Success); + Assert.IsNotNull(actualTodoItem.Id); + expectedTodoItem.WithDeepEqual(actualTodoItem).IgnoreSourceProperty((ti) =>ti.Id); + } + + [Test] + public void DeleteTodoItem() + { + // arrange + TodoItem expectedTodoItem = dataPrep.TodoItems.Create(); + + // act + DeleteResult deleteResult = accessor.DeleteTodoItem(expectedTodoItem.Id); + + //assert + Assert.IsTrue(deleteResult.Success); + + IEnumerable retrievableItemList = accessor.GetTodoItemsForList(expectedTodoItem.TodoListId); + Assert.IsNull(retrievableItemList.FirstOrDefault(ti => ti.Id == expectedTodoItem.Id)); + } + } } From fb137dae49a48baeebe1d4e961e9f7af95c5606e Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 22:19:59 -0500 Subject: [PATCH 22/74] Fill in basic TodoListAccessor methods and add transaction scope to manager test base to account for integration mode --- .../TodoListAccessor.cs | 59 +++++++++++++++++-- .../Tests.AccessorTests.csproj | 1 + Tests.AccessorTests/TodoListAccessorTests.cs | 25 ++++++++ Tests.ManagerTests/ManagerTestBase.cs | 9 +++ Tests.ManagerTests/Tests.ManagerTests.csproj | 1 + 5 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 Tests.AccessorTests/TodoListAccessorTests.cs diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs index 9a3ec5e..8d3a56f 100644 --- a/Accessors.DatabaseAccessors/TodoListAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -1,6 +1,9 @@ -using Shared.DataContracts; +using Shared.DatabaseContext; +using Shared.DatabaseContext.DBOs; +using Shared.DataContracts; using System; using System.Collections.Generic; +using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -20,24 +23,70 @@ public interface ITodoListAccessor class TodoListAccessor : ITodoListAccessor { + TodoList_Mapper mapper = new TodoList_Mapper(); + public DeleteResult DeleteTodoList(Guid id) { - throw new NotImplementedException(); + using (TodoContext db = new TodoContext()) + { + TodoListDBO todoListModel = db.TodoLists.FirstOrDefault(ti => ti.Id == id); + todoListModel.IsActive = false; + + db.SaveChanges(); + + DeleteResult deleteResult = new DeleteResult(); + + return deleteResult; + } } public TodoList GetTodoList(Guid id) { - throw new NotImplementedException(); + using (TodoContext db = new TodoContext()) + { + TodoListDBO listModel = db.TodoLists.FirstOrDefault(tl => tl.Id == id && tl.IsActive); + + TodoList listContract = mapper.ModelToContract(listModel); + + return listContract; + } } public IEnumerable GetTodoListsForUser(Guid userId) { - throw new NotImplementedException(); + IEnumerable todoListContracts; + using (TodoContext db = new TodoContext()) + { + IEnumerable listModelList = db.TodoLists.Where(tl => tl.UserId == userId && tl.IsActive).ToList(); + + todoListContracts = mapper.ModelListToContractList(listModelList); + } + + return todoListContracts; } public SaveResult SaveTodoList(TodoList todoList) { - throw new NotImplementedException(); + using (TodoContext db = new TodoContext()) + { + TodoListDBO dbModel = mapper.ContractToModel(todoList); + + if (todoList.Id == DataConstants.DefaultId) + { + db.TodoLists.Add(dbModel); + } + else + { + db.TodoLists.Attach(dbModel); + db.Entry(dbModel).State = EntityState.Modified; + } + db.SaveChanges(); + + TodoList savedTodoItem = mapper.ModelToContract(dbModel); + + SaveResult saveResult = new SaveResult(savedTodoItem); + return saveResult; + } } } } diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index 48cdde7..d06df71 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -68,6 +68,7 @@ + diff --git a/Tests.AccessorTests/TodoListAccessorTests.cs b/Tests.AccessorTests/TodoListAccessorTests.cs new file mode 100644 index 0000000..aabbb82 --- /dev/null +++ b/Tests.AccessorTests/TodoListAccessorTests.cs @@ -0,0 +1,25 @@ +using Accessors.DatabaseAccessors; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Test.NUnitExtensions; + +namespace Tests.AccessorTests +{ + [TestFixture_Prefixed(typeof(TodoListAccessor))] + public class TodoListAccessorTests : AccessorTestBase + { + TodoListAccessor accessor; + public override void OnInitialize() + { + accessor = new TodoListAccessor(); + } + + [Test] + public void GetTodoList() + { + + } + } +} diff --git a/Tests.ManagerTests/ManagerTestBase.cs b/Tests.ManagerTests/ManagerTestBase.cs index 8d593b9..3cec9c3 100644 --- a/Tests.ManagerTests/ManagerTestBase.cs +++ b/Tests.ManagerTests/ManagerTestBase.cs @@ -1,5 +1,7 @@ //using Microsoft.VisualStudio.TestTools.UnitTesting; using NUnit.Framework; +using Shared.DatabaseContext; +using System.Transactions; using Tests.DataPrep; namespace Tests.ManagerTests @@ -7,11 +9,17 @@ namespace Tests.ManagerTests public abstract class ManagerTestBase { protected TodoDataPrep dataPrep = new TodoDataPrep(false); + TransactionScope _transactionScope; public abstract void OnInitialize(); [SetUp] public virtual void TestInitialize() { + TodoContext database = new TodoContext(); + database.Database.CreateIfNotExists(); + // transactionScope causes db changes to be rolled back at end of test + _transactionScope = new TransactionScope(); + OnInitialize(); } @@ -21,6 +29,7 @@ public virtual void TestInitialize() public virtual void TestCleanup() { OnCleanup(); + _transactionScope.Dispose(); } } diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 8a18c1f..c28a9d9 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -63,6 +63,7 @@ + ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll From 510a5c65c971a39d4eaeff2e16441247bdb2d54c Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 22:23:06 -0500 Subject: [PATCH 23/74] Prefix the ListExplorationManager tests --- Tests.ManagerTests/ListExplorationManagerTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests.ManagerTests/ListExplorationManagerTests.cs b/Tests.ManagerTests/ListExplorationManagerTests.cs index 2b2f090..9e12e99 100644 --- a/Tests.ManagerTests/ListExplorationManagerTests.cs +++ b/Tests.ManagerTests/ListExplorationManagerTests.cs @@ -4,10 +4,11 @@ using NUnit.Framework; using Shared.DataContracts; using Telerik.JustMock.AutoMock; +using Test.NUnitExtensions; namespace Tests.ManagerTests { - [TestFixture] + [TestFixture_Prefixed(typeof(ListExplorationManager))] public class ListExplorationManagerTests : ManagerTestBase { MockingContainer mockContainer; From 058cc54a8ad073eed01f7ef71a8cd60e81c9462f Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Sun, 11 Mar 2018 22:39:48 -0500 Subject: [PATCH 24/74] Unit tests for TodoListAccessor --- Tests.AccessorTests/TodoListAccessorTests.cs | 62 ++++++++++++++++++++ Tests.DataPrep/TodoListPrep.cs | 12 ++++ 2 files changed, 74 insertions(+) diff --git a/Tests.AccessorTests/TodoListAccessorTests.cs b/Tests.AccessorTests/TodoListAccessorTests.cs index aabbb82..c769584 100644 --- a/Tests.AccessorTests/TodoListAccessorTests.cs +++ b/Tests.AccessorTests/TodoListAccessorTests.cs @@ -1,5 +1,7 @@ using Accessors.DatabaseAccessors; +using DeepEqual.Syntax; using NUnit.Framework; +using Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; @@ -19,7 +21,67 @@ public override void OnInitialize() [Test] public void GetTodoList() { + TodoList expectedTodoList = dataPrep.TodoLists.Create(); + TodoList actualTodoList = accessor.GetTodoList(expectedTodoList.Id); + + expectedTodoList.ShouldDeepEqual(actualTodoList); + } + + [Test] + public void GetTodoListsForUser() + { + User user = dataPrep.Users.Create(); + IEnumerable expectedTodoListList = dataPrep.TodoLists.CreateManyForUser(5, user); + + IEnumerable actualTodoListList = accessor.GetTodoListsForUser(user.Id); + + expectedTodoListList.ShouldDeepEqual(actualTodoListList); + } + + [Test] + public void SaveTodoList_Update() + { + TodoList expectedTodoList = dataPrep.TodoLists.Create(); + expectedTodoList.Title = Guid.NewGuid().ToString(); + + SaveResult saveResult = accessor.SaveTodoList(expectedTodoList); + TodoList actualTodoList = saveResult.Result; + + Assert.IsTrue(saveResult.Success); + expectedTodoList.ShouldDeepEqual(actualTodoList); + } + + [Test] + public void SaveTodoList_Create() + { + User user = dataPrep.Users.Create(); + TodoList newTodoList = new TodoList() + { + UserId = user.Id, + Title = Guid.NewGuid().ToString(), + }; + + SaveResult saveResult = accessor.SaveTodoList(newTodoList); + TodoList actualTodoList = saveResult.Result; + + Assert.IsNotNull(actualTodoList.Id); + newTodoList.WithDeepEqual(actualTodoList).IgnoreSourceProperty(tl => tl.Id); + } + + [Test] + public void DeleteTodoList() + { + TodoList expectedTodoList = dataPrep.TodoLists.Create(); + + // act + DeleteResult deleteResult = accessor.DeleteTodoList(expectedTodoList.Id); + + //assert + Assert.IsTrue(deleteResult.Success); + + TodoList retrievableTodoList = accessor.GetTodoList(expectedTodoList.Id); + Assert.IsNull(retrievableTodoList); } } } diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index b4b9099..37550d6 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -45,5 +45,17 @@ public TodoList Create(TodoList todoList, bool isActive = true) return savedContract; } + + public IEnumerable CreateManyForUser(int count, User user) + { + List todoLists = new List(); + for (int i = 0; i < count; i++) + { + TodoList todoList = Create(user); + todoLists.Add(todoList); + } + + return todoLists; + } } } From 7a5a01b8164e1c17dd74d5c6918f05fbd81b761c Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 16:09:31 -0500 Subject: [PATCH 25/74] Add a variety of readme files and write basic data contract readme --- .../ListExplorationManager.cs | 1 + README.md | 7 +++-- Shared.DataContracts/README_DataContracts.md | 27 +++++++++++++++++++ .../DBOs/README_DatabaseObjects.md | 1 + .../README_DependencyInjectionKernel.md | 1 + Test.NUnitExtensions/README_TestPrefixes.md | 1 + ...md => README_IntegrationReuse_WhiteDoc.md} | 3 +++ Tests.ManagerTests/TodoCRUDManagerTests.cs | 1 + 8 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Shared.DataContracts/README_DataContracts.md create mode 100644 Shared.DatabaseContext/DBOs/README_DatabaseObjects.md create mode 100644 Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md create mode 100644 Test.NUnitExtensions/README_TestPrefixes.md rename Tests.ManagerTests/{README_IntegrationReuse.md => README_IntegrationReuse_WhiteDoc.md} (92%) diff --git a/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs b/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs index c1f4dc3..25c35d6 100644 --- a/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs +++ b/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs @@ -19,6 +19,7 @@ public interface IListExplorationManager internal class ListExplorationManager : IListExplorationManager { + public IEnumerable GetUserLists(Guid userId) { throw new NotImplementedException(); diff --git a/README.md b/README.md index 19ba6be..a286859 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,15 @@ As a result, it also demonstrates many other patterns and libraries that enable This project is very much overkill for a Todo list. However, the overkill is to demonstrate the patterns in a way that can easily be transfered to a large project -Patterns +Testing Patterns - Dependency Injection - DataPrep (centralized test data generators) - ConfigWrappers //pending - Inconclusive tests to mark untested code // pending - Test name modification for test runner (display extra info without manually adding it to each test name) +- Unit/Integration test reuse -Libraries +Testing Libraries - JustMock (test dependency generator; https://www.telerik.com/products/mocking.aspx) - alternatives: Moq, MSFakes, RhinoMocks - DeepEqual (https://github.com/jamesfoster/DeepEqual) @@ -25,3 +26,5 @@ Libraries - Bogus (https://github.com/bchavez/Bogus) - alternatives: AutoFixture - .NET Transactions TransactionScope +- NUnit + - alternatives: MSTest diff --git a/Shared.DataContracts/README_DataContracts.md b/Shared.DataContracts/README_DataContracts.md new file mode 100644 index 0000000..ad0dca8 --- /dev/null +++ b/Shared.DataContracts/README_DataContracts.md @@ -0,0 +1,27 @@ +#Data Contracts + +Data contracts are the data forms agreed on between services. +In other words, they: + - Represent the data required to complete a flow in the application + - are the only non-value types that should be available in multiple projects + - are the only non-value types returned from an interface + - + + Data contracts should + - be as flat as possible (very rarely contain non-value types) + - Contain only the data needed for the situation, split contracts if you have un-needed data + - Be named semantically / so that it is clear what purpose they fulfill + - Do not contain state or logic. This is both a matter of concurrency (thread safety) and conceptual clarity. + + + This +- improves iteroperability (because services use the same types) +- limits the scope of computation-specific and project-specific types by disallowing them as a return type +- Limits ability to couple services through data, because the contracts are designed for an application flow, + not to particular pieces of code. Being flat and minimal also reduces the possibility for unintended use or + broken expectations +- Disallowing state and logic, besides enabling thread-safe operations, decouples data from actions. This helps allows us to + operate on the data in many valid ways without mixing unrelated logic. It also keeps you from distributing manager-style code, which leads to unexpected actions + For example, you are passed an object configured to save to the db, but you want to save it to a nosql) because the orchestrating context is always responsible for, + well... orchestrating +- Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) \ No newline at end of file diff --git a/Shared.DatabaseContext/DBOs/README_DatabaseObjects.md b/Shared.DatabaseContext/DBOs/README_DatabaseObjects.md new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Shared.DatabaseContext/DBOs/README_DatabaseObjects.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md b/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Test.NUnitExtensions/README_TestPrefixes.md b/Test.NUnitExtensions/README_TestPrefixes.md new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Test.NUnitExtensions/README_TestPrefixes.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Tests.ManagerTests/README_IntegrationReuse.md b/Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md similarity index 92% rename from Tests.ManagerTests/README_IntegrationReuse.md rename to Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md index dc86472..ce7746d 100644 --- a/Tests.ManagerTests/README_IntegrationReuse.md +++ b/Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md @@ -43,6 +43,9 @@ The question is now how to generate differentiated names in the test runner with It is not entirely clear how to extend these types while maintaining behavior because you cannot override when you inherit from the default attributes. Instead, the logic is available through internal builders and type constructors. + However, you can also inherit from the default attribute and 'hide' the base class's method + by creating one of the same signature. This breaks liscov substitution, but it + allows you to reuse the property logic of the base attibutes BONUS: Interesting thread on using NUnit tests to augment documentation https://stackoverflow.com/questions/8727684/how-can-i-generate-documentation-from-nunit-tests \ No newline at end of file diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 179b87b..4ab5e29 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -17,6 +17,7 @@ namespace Tests.ManagerTests { + //NOTE: test fixture arguments break code lens support, submitted issue #485 https://github.com/nunit/nunit3-vs-adapter/issues/485 [TestFixture_Prefixed(typeof(TodoCRUDManager), false)] [TestFixture_Prefixed(typeof(TodoCRUDManager), true)] public class TodoCRUDManagerTests : ManagerTestBase From 1008e30732ffa78a290550ed21ce3ab9362fd167 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 16:29:46 -0500 Subject: [PATCH 26/74] Rename the DBOs to DTOs for datasource generality and write DTO readme --- .../TodoItemAccessor.cs | 6 +++--- .../TodoListAccessor.cs | 8 ++++---- Shared.DataContracts/README_DataContracts.md | 19 ++++++++++++------- .../Shared.DataContracts.csproj | 3 +++ .../DBOs/README_DatabaseObjects.md | 1 - .../{DBOs => DTOs}/DatabaseObjectBase.cs | 0 .../{DBOs => DTOs}/MapperBase.cs | 0 .../DTOs/README_DataTransferObjects.md | 12 ++++++++++++ .../TodoItemDBO.cs => DTOs/TodoItemDTO.cs} | 6 +++--- .../TodoListDBO.cs => DTOs/TodoListDTO.cs} | 6 +++--- .../{DBOs/UserDBO.cs => DTOs/UserDTO.cs} | 4 ++-- .../Shared.DatabaseContext.csproj | 1 + Shared.DatabaseContext/TodoContext.cs | 6 +++--- .../Shared.DependencyInjectionKernel.csproj | 1 + .../Test.NUnitExtensions.csproj | 1 + TestingExemplar.sln | 2 +- Tests.AccessorTests/TodoItemAccessorTests.cs | 10 +++++----- Tests.DataPrep/TodoItemPrep.cs | 4 ++-- Tests.DataPrep/TodoListPrep.cs | 4 ++-- Tests.DataPrep/UserPrep.cs | 4 ++-- Tests.ManagerTests/Tests.ManagerTests.csproj | 2 +- 21 files changed, 61 insertions(+), 39 deletions(-) delete mode 100644 Shared.DatabaseContext/DBOs/README_DatabaseObjects.md rename Shared.DatabaseContext/{DBOs => DTOs}/DatabaseObjectBase.cs (100%) rename Shared.DatabaseContext/{DBOs => DTOs}/MapperBase.cs (100%) create mode 100644 Shared.DatabaseContext/DTOs/README_DataTransferObjects.md rename Shared.DatabaseContext/{DBOs/TodoItemDBO.cs => DTOs/TodoItemDTO.cs} (86%) rename Shared.DatabaseContext/{DBOs/TodoListDBO.cs => DTOs/TodoListDTO.cs} (85%) rename Shared.DatabaseContext/{DBOs/UserDBO.cs => DTOs/UserDTO.cs} (83%) diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index d56a0e6..7796ac2 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -26,7 +26,7 @@ public DeleteResult DeleteTodoItem(Guid id) { using (TodoContext db = new TodoContext()) { - TodoItemDBO todoItemModel = db.TodoItems.FirstOrDefault(ti => ti.Id == id); + TodoItemDTO todoItemModel = db.TodoItems.FirstOrDefault(ti => ti.Id == id); todoItemModel.IsActive = false; db.SaveChanges(); @@ -42,7 +42,7 @@ public IEnumerable GetTodoItemsForList(Guid listId) IEnumerable todoItemList; using (TodoContext db = new TodoContext()) { - IEnumerable todoItemModelList = db.TodoItems.Where(ti => ti.TodoListId == listId && ti.IsActive).ToList(); + IEnumerable todoItemModelList = db.TodoItems.Where(ti => ti.TodoListId == listId && ti.IsActive).ToList(); todoItemList = mapper.ModelListToContractList(todoItemModelList); } return todoItemList; @@ -52,7 +52,7 @@ public SaveResult SaveTodoItem(TodoItem todoItem) { using (TodoContext db = new TodoContext()) { - TodoItemDBO dbModel = mapper.ContractToModel(todoItem); + TodoItemDTO dbModel = mapper.ContractToModel(todoItem); if(todoItem.Id == DataConstants.DefaultId) { diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs index 8d3a56f..1bfdf19 100644 --- a/Accessors.DatabaseAccessors/TodoListAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -29,7 +29,7 @@ public DeleteResult DeleteTodoList(Guid id) { using (TodoContext db = new TodoContext()) { - TodoListDBO todoListModel = db.TodoLists.FirstOrDefault(ti => ti.Id == id); + TodoListDTO todoListModel = db.TodoLists.FirstOrDefault(ti => ti.Id == id); todoListModel.IsActive = false; db.SaveChanges(); @@ -44,7 +44,7 @@ public TodoList GetTodoList(Guid id) { using (TodoContext db = new TodoContext()) { - TodoListDBO listModel = db.TodoLists.FirstOrDefault(tl => tl.Id == id && tl.IsActive); + TodoListDTO listModel = db.TodoLists.FirstOrDefault(tl => tl.Id == id && tl.IsActive); TodoList listContract = mapper.ModelToContract(listModel); @@ -57,7 +57,7 @@ public IEnumerable GetTodoListsForUser(Guid userId) IEnumerable todoListContracts; using (TodoContext db = new TodoContext()) { - IEnumerable listModelList = db.TodoLists.Where(tl => tl.UserId == userId && tl.IsActive).ToList(); + IEnumerable listModelList = db.TodoLists.Where(tl => tl.UserId == userId && tl.IsActive).ToList(); todoListContracts = mapper.ModelListToContractList(listModelList); } @@ -69,7 +69,7 @@ public SaveResult SaveTodoList(TodoList todoList) { using (TodoContext db = new TodoContext()) { - TodoListDBO dbModel = mapper.ContractToModel(todoList); + TodoListDTO dbModel = mapper.ContractToModel(todoList); if (todoList.Id == DataConstants.DefaultId) { diff --git a/Shared.DataContracts/README_DataContracts.md b/Shared.DataContracts/README_DataContracts.md index ad0dca8..0b6e893 100644 --- a/Shared.DataContracts/README_DataContracts.md +++ b/Shared.DataContracts/README_DataContracts.md @@ -2,26 +2,31 @@ Data contracts are the data forms agreed on between services. In other words, they: - - Represent the data required to complete a flow in the application + - Represent the data shared by a flow in the application - are the only non-value types that should be available in multiple projects - are the only non-value types returned from an interface - - Data contracts should - be as flat as possible (very rarely contain non-value types) - Contain only the data needed for the situation, split contracts if you have un-needed data - Be named semantically / so that it is clear what purpose they fulfill - Do not contain state or logic. This is both a matter of concurrency (thread safety) and conceptual clarity. - + - Represent a useful collection of values, not necessarily the database This - improves iteroperability (because services use the same types) - limits the scope of computation-specific and project-specific types by disallowing them as a return type +- When separated from Database Objects, allows you to shape your program without concern for the database structure - Limits ability to couple services through data, because the contracts are designed for an application flow, not to particular pieces of code. Being flat and minimal also reduces the possibility for unintended use or broken expectations - Disallowing state and logic, besides enabling thread-safe operations, decouples data from actions. This helps allows us to - operate on the data in many valid ways without mixing unrelated logic. It also keeps you from distributing manager-style code, which leads to unexpected actions - For example, you are passed an object configured to save to the db, but you want to save it to a nosql) because the orchestrating context is always responsible for, - well... orchestrating -- Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) \ No newline at end of file + operate on the data in many valid ways without mixing unrelated logic. It also keeps you from distributing manager-style code, which leads to unexpected actions. + For example, you are passed an object configured to save to the db, but you want to save it to a nosql. However, you either don't know where that object is going to save + or you have to have every interested portion of code check where that object is configured to save and mutate it to fit the current need. + With separated actions and data, there can be no such confusion because the orchestrating context is always responsible for, + well..., orchestrating. +- Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) + + +#Result Types (i.e. SaveResult/DeleteResult) \ No newline at end of file diff --git a/Shared.DataContracts/Shared.DataContracts.csproj b/Shared.DataContracts/Shared.DataContracts.csproj index 3a9f7f8..9b569c8 100644 --- a/Shared.DataContracts/Shared.DataContracts.csproj +++ b/Shared.DataContracts/Shared.DataContracts.csproj @@ -48,5 +48,8 @@ + + + \ No newline at end of file diff --git a/Shared.DatabaseContext/DBOs/README_DatabaseObjects.md b/Shared.DatabaseContext/DBOs/README_DatabaseObjects.md deleted file mode 100644 index 5f28270..0000000 --- a/Shared.DatabaseContext/DBOs/README_DatabaseObjects.md +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Shared.DatabaseContext/DBOs/DatabaseObjectBase.cs b/Shared.DatabaseContext/DTOs/DatabaseObjectBase.cs similarity index 100% rename from Shared.DatabaseContext/DBOs/DatabaseObjectBase.cs rename to Shared.DatabaseContext/DTOs/DatabaseObjectBase.cs diff --git a/Shared.DatabaseContext/DBOs/MapperBase.cs b/Shared.DatabaseContext/DTOs/MapperBase.cs similarity index 100% rename from Shared.DatabaseContext/DBOs/MapperBase.cs rename to Shared.DatabaseContext/DTOs/MapperBase.cs diff --git a/Shared.DatabaseContext/DTOs/README_DataTransferObjects.md b/Shared.DatabaseContext/DTOs/README_DataTransferObjects.md new file mode 100644 index 0000000..6ea69da --- /dev/null +++ b/Shared.DatabaseContext/DTOs/README_DataTransferObjects.md @@ -0,0 +1,12 @@ +#Data Transfer Objects + +At first blush, these may seem the same as data contracts. However, data transfer objects reflect expected results +of data source queries. They allow us to encode knowledge about our data stucture for consumption in our code. +DataContracts on the other hand, should have no ties to the data structure. + +Handing off from DTOs to DataContracts allows only our accessors to contain knowledge of the datasource, while the +rest of the application is un-impacted by database changes. This makes it much easier to make data schema changes +without causing bugs. As long as the accessors map to the data contracts, no changes outside the accessor are needed. + +Adding this additional set of models can make for a lot of boring object mapping work. Fortunately, there are libraries +like AutoMapper that automate that work, making database-isolation the clear winner of the design concerns. \ No newline at end of file diff --git a/Shared.DatabaseContext/DBOs/TodoItemDBO.cs b/Shared.DatabaseContext/DTOs/TodoItemDTO.cs similarity index 86% rename from Shared.DatabaseContext/DBOs/TodoItemDBO.cs rename to Shared.DatabaseContext/DTOs/TodoItemDTO.cs index 80cd4e8..df000c8 100644 --- a/Shared.DatabaseContext/DBOs/TodoItemDBO.cs +++ b/Shared.DatabaseContext/DTOs/TodoItemDTO.cs @@ -7,7 +7,7 @@ namespace Shared.DatabaseContext.DBOs { [Table("TodoItems")] - public class TodoItemDBO : DatabaseObjectBase + public class TodoItemDTO : DatabaseObjectBase { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } @@ -21,11 +21,11 @@ public class TodoItemDBO : DatabaseObjectBase public bool IsActive { get; set; } [ForeignKey("TodoListId")] - public TodoListDBO TodoList { get; set; } + public TodoListDTO TodoList { get; set; } } - public class TodoItem_Mapper : MapperBase + public class TodoItem_Mapper : MapperBase { public TodoItem_Mapper() { diff --git a/Shared.DatabaseContext/DBOs/TodoListDBO.cs b/Shared.DatabaseContext/DTOs/TodoListDTO.cs similarity index 85% rename from Shared.DatabaseContext/DBOs/TodoListDBO.cs rename to Shared.DatabaseContext/DTOs/TodoListDTO.cs index 0a5573f..1c96c60 100644 --- a/Shared.DatabaseContext/DBOs/TodoListDBO.cs +++ b/Shared.DatabaseContext/DTOs/TodoListDTO.cs @@ -6,7 +6,7 @@ namespace Shared.DatabaseContext.DBOs { [Table("TodoLists")] - public class TodoListDBO : DatabaseObjectBase + public class TodoListDTO : DatabaseObjectBase { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } @@ -16,11 +16,11 @@ public class TodoListDBO : DatabaseObjectBase public string Title { get; set; } [ForeignKey("UserId")] - public UserDBO User { get; set; } + public UserDTO User { get; set; } public bool IsActive { get; set; } } - public class TodoList_Mapper : MapperBase + public class TodoList_Mapper : MapperBase { } diff --git a/Shared.DatabaseContext/DBOs/UserDBO.cs b/Shared.DatabaseContext/DTOs/UserDTO.cs similarity index 83% rename from Shared.DatabaseContext/DBOs/UserDBO.cs rename to Shared.DatabaseContext/DTOs/UserDTO.cs index 6609e77..c175705 100644 --- a/Shared.DatabaseContext/DBOs/UserDBO.cs +++ b/Shared.DatabaseContext/DTOs/UserDTO.cs @@ -10,7 +10,7 @@ namespace Shared.DatabaseContext.DBOs { [Table("Users")] - public class UserDBO : DatabaseObjectBase + public class UserDTO : DatabaseObjectBase { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } @@ -21,7 +21,7 @@ public class UserDBO : DatabaseObjectBase } - public class User_Mapper : MapperBase + public class User_Mapper : MapperBase { } diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index 0baaac8..6d68f84 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -70,6 +70,7 @@ + diff --git a/Shared.DatabaseContext/TodoContext.cs b/Shared.DatabaseContext/TodoContext.cs index 5910e01..572e959 100644 --- a/Shared.DatabaseContext/TodoContext.cs +++ b/Shared.DatabaseContext/TodoContext.cs @@ -10,9 +10,9 @@ namespace Shared.DatabaseContext { public class TodoContext : DbContext { - public DbSet Users { get; set; } - public DbSet TodoItems { get; set; } - public DbSet TodoLists { get; set; } + public DbSet Users { get; set; } + public DbSet TodoItems { get; set; } + public DbSet TodoLists { get; set; } public TodoContext() : base("TodoDb") { diff --git a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj index 4471edd..2c08351 100644 --- a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj +++ b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj @@ -48,6 +48,7 @@ + diff --git a/Test.NUnitExtensions/Test.NUnitExtensions.csproj b/Test.NUnitExtensions/Test.NUnitExtensions.csproj index 762d724..4a5e8f0 100644 --- a/Test.NUnitExtensions/Test.NUnitExtensions.csproj +++ b/Test.NUnitExtensions/Test.NUnitExtensions.csproj @@ -48,6 +48,7 @@ + \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index 65f6118..b6a6412 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -19,7 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accessors.DatabaseAccessors EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3B08858C-6FD1-47E7-824C-0B3F1D234455}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Solution Items", "0.Solution Items", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Documentation", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" ProjectSection(SolutionItems) = preProject README.md = README.md EndProjectSection diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs index 24fd4f0..0486273 100644 --- a/Tests.AccessorTests/TodoItemAccessorTests.cs +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -27,14 +27,14 @@ public void GetTodoItems_Ugly() // arrange using (TodoContext db = new TodoContext()) { - UserDBO user = new UserDBO() + UserDTO user = new UserDTO() { Name = "Bob", }; db.Users.Add(user); db.SaveChanges(); - TodoListDBO expectedList = new TodoListDBO() + TodoListDTO expectedList = new TodoListDTO() { UserId = user.Id, Title = Guid.NewGuid().ToString(), @@ -42,11 +42,11 @@ public void GetTodoItems_Ugly() db.TodoLists.Add(expectedList); db.SaveChanges(); - List expectedItemList = new List(); + List expectedItemList = new List(); int expectedTodoItemCount = 5; for (int i = 0; i < expectedTodoItemCount; i++) { - TodoItemDBO expectedItem = new TodoItemDBO() + TodoItemDTO expectedItem = new TodoItemDTO() { TodoListId = expectedList.Id, Description = Guid.NewGuid().ToString(), @@ -65,7 +65,7 @@ public void GetTodoItems_Ugly() Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); foreach (TodoItem actualTodo in actualItemList) { - TodoItemDBO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); + TodoItemDTO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); Assert.AreEqual(expectedTodo.TodoListId, actualTodo.TodoListId); Assert.AreEqual(expectedTodo.Description, actualTodo.Description); Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index 4f1cc51..74e9359 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -40,11 +40,11 @@ public TodoItem Create(TodoList todoList = null, bool? isComplete = null) public TodoItem Create(TodoItem todoItem, bool isActive = true) { TodoItem_Mapper mapper = new TodoItem_Mapper(); - TodoItemDBO model = mapper.ContractToModel(todoItem); + TodoItemDTO model = mapper.ContractToModel(todoItem); // handle active state here so I can create inactive items, but leave active flags off of data contracts model.IsActive = isActive; - TodoItemDBO savedModel = dataAccessor.Create(model); + TodoItemDTO savedModel = dataAccessor.Create(model); TodoItem savedContract = mapper.ModelToContract(savedModel); return savedContract; diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index 37550d6..2faa799 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -37,10 +37,10 @@ public TodoList Create(User user = null) public TodoList Create(TodoList todoList, bool isActive = true) { TodoList_Mapper mapper = new TodoList_Mapper(); - TodoListDBO model = mapper.ContractToModel(todoList); + TodoListDTO model = mapper.ContractToModel(todoList); model.IsActive = isActive; - TodoListDBO savedModel = dataAccessor.Create(model); + TodoListDTO savedModel = dataAccessor.Create(model); TodoList savedContract = mapper.ModelToContract(savedModel); return savedContract; diff --git a/Tests.DataPrep/UserPrep.cs b/Tests.DataPrep/UserPrep.cs index 504540e..9beefd6 100644 --- a/Tests.DataPrep/UserPrep.cs +++ b/Tests.DataPrep/UserPrep.cs @@ -34,10 +34,10 @@ public User Create(User user, bool isActive = true) { // NOTE/TODO: feels like there should be a good way to encapsulate this so most data prep classes don't have to write it User_Mapper mapper = new User_Mapper(); - UserDBO model = mapper.ContractToModel(user); + UserDTO model = mapper.ContractToModel(user); model.IsActive = isActive; - UserDBO savedModel = dataAccessor.Create(model); + UserDTO savedModel = dataAccessor.Create(model); User savedContract = mapper.ModelToContract(savedModel); return savedContract; diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index c28a9d9..6bfb9fd 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -78,7 +78,7 @@ - + From fa0db6d77e9ed063c804c3c0f4f73f378cdd4aca Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 16:34:53 -0500 Subject: [PATCH 27/74] Dependency Injection Kernel Readme --- .../README_DependencyInjectionKernel.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md b/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md index 5f28270..02f4984 100644 --- a/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md +++ b/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md @@ -1 +1,7 @@ - \ No newline at end of file +#Dependency Injection Kernel + +The dependency kernel allows us to centralize our dependency injection configuration. This helps prevents errors +caused by forgetting to update different clients that require configuration for new service types. + +This class allows us offer up alternative configurations (through additional methods) for clients that may only require a subset of the +dependency configuration while keeping the dependency maps in one clear place. \ No newline at end of file From ece6287095728a65ce3010d30d38026817dc792d Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 16:42:45 -0500 Subject: [PATCH 28/74] Test prefixes readme --- Test.NUnitExtensions/README_TestPrefixes.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Test.NUnitExtensions/README_TestPrefixes.md b/Test.NUnitExtensions/README_TestPrefixes.md index 5f28270..bfd42fa 100644 --- a/Test.NUnitExtensions/README_TestPrefixes.md +++ b/Test.NUnitExtensions/README_TestPrefixes.md @@ -1 +1,13 @@ - \ No newline at end of file +# Auto-Generated Test Prefixes + +Prefixing the name of the tested class to a test name produces more clearly organized test results. +It also allows us to more quickly identify trends in test failures. + +However, manually maintaining these prefixes is a pain. If you change a class name, it is easy to forget +to rename all the tests and is boring to rename all the tests. + +Auto-generating the class name based on the test subject types means we can't forget to rename the test +and cleans test name of info we already know when we are in the test class. + +Generated prefixes can also help differentiate tests that generate multiple cases, such as with integration/unit +test reuse. \ No newline at end of file From 17d36ae8b7409eefa6f87c3449397acf63475886 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 16:45:40 -0500 Subject: [PATCH 29/74] add written readmes to solution folder --- Shared.DatabaseContext/Shared.DatabaseContext.csproj | 12 ++++++------ TestingExemplar.sln | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index 6d68f84..6cd545c 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -51,8 +51,8 @@ - - + + 201803052220061_Init.cs @@ -63,14 +63,14 @@ - - - + + + - + diff --git a/TestingExemplar.sln b/TestingExemplar.sln index b6a6412..c42aa38 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -22,6 +22,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Documentation", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" ProjectSection(SolutionItems) = preProject README.md = README.md + Shared.DataContracts\README_DataContracts.md = Shared.DataContracts\README_DataContracts.md + Shared.DatabaseContext\DTOs\README_DataTransferObjects.md = Shared.DatabaseContext\DTOs\README_DataTransferObjects.md + Test.NUnitExtensions\TestFixture_Prefixed.cs = Test.NUnitExtensions\TestFixture_Prefixed.cs EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.Managers", "2.Managers", "{01383730-F2FD-4900-B91C-4784EDA64DF6}" @@ -34,6 +37,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionK EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.NUnitExtensions", "Test.NUnitExtensions\Test.NUnitExtensions.csproj", "{3AC5C65A-6F68-479C-A078-3D2E573111BB}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2338092-6298-42F4-BD55-4D79EB2AFBFB}" + ProjectSection(SolutionItems) = preProject + Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 90cd4d5afd4ec1af080413b97abcd5d049cd28f6 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 17:15:38 -0500 Subject: [PATCH 30/74] Add section of reasoning for result types --- Shared.DataContracts/README_DataContracts.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Shared.DataContracts/README_DataContracts.md b/Shared.DataContracts/README_DataContracts.md index 0b6e893..5fe7f7c 100644 --- a/Shared.DataContracts/README_DataContracts.md +++ b/Shared.DataContracts/README_DataContracts.md @@ -29,4 +29,7 @@ In other words, they: - Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) -#Result Types (i.e. SaveResult/DeleteResult) \ No newline at end of file +#Result Types (i.e. SaveResult/DeleteResult) + +Result types allow a return value with relevant meta-info. Most commonly, operation success or errors in not successful. +They allow you to handle errors in a service and normalize success/failure information for consuming services. \ No newline at end of file From 29a0388cc8fb3e63d7328fa412bac32ccda72e45 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 17:27:58 -0500 Subject: [PATCH 31/74] add readme files for remaining topics --- 1.README_SolutionStructure.md | 0 .../README_DependencyInjection.md | 1 + .../Shared.DependencyInjectionKernel.csproj | 1 + TestingExemplar.sln | 9 +++------ Tests.DataPrep/README_DataPrep.md | 1 + Tests.DataPrep/Tests.DataPrep.csproj | 1 + Tests.ManagerTests/README_TestClassReuse.md | 1 + Tests.ManagerTests/Tests.ManagerTests.csproj | 1 + 8 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 1.README_SolutionStructure.md create mode 100644 Shared.DependencyInjectionKernel/README_DependencyInjection.md create mode 100644 Tests.DataPrep/README_DataPrep.md create mode 100644 Tests.ManagerTests/README_TestClassReuse.md diff --git a/1.README_SolutionStructure.md b/1.README_SolutionStructure.md new file mode 100644 index 0000000..e69de29 diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjection.md b/Shared.DependencyInjectionKernel/README_DependencyInjection.md new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Shared.DependencyInjectionKernel/README_DependencyInjection.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj index 2c08351..9d89934 100644 --- a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj +++ b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj @@ -45,6 +45,7 @@ + diff --git a/TestingExemplar.sln b/TestingExemplar.sln index c42aa38..8a0d85e 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -21,10 +21,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3B08858C EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Documentation", "{9B6F4405-B2EC-4143-A1B2-92A0B1CD0130}" ProjectSection(SolutionItems) = preProject + 1.README_SolutionStructure.md = 1.README_SolutionStructure.md README.md = README.md Shared.DataContracts\README_DataContracts.md = Shared.DataContracts\README_DataContracts.md Shared.DatabaseContext\DTOs\README_DataTransferObjects.md = Shared.DatabaseContext\DTOs\README_DataTransferObjects.md - Test.NUnitExtensions\TestFixture_Prefixed.cs = Test.NUnitExtensions\TestFixture_Prefixed.cs + Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md + Test.NUnitExtensions\README_TestPrefixes.md = Test.NUnitExtensions\README_TestPrefixes.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.Managers", "2.Managers", "{01383730-F2FD-4900-B91C-4784EDA64DF6}" @@ -37,11 +39,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionK EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.NUnitExtensions", "Test.NUnitExtensions\Test.NUnitExtensions.csproj", "{3AC5C65A-6F68-479C-A078-3D2E573111BB}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2338092-6298-42F4-BD55-4D79EB2AFBFB}" - ProjectSection(SolutionItems) = preProject - Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Tests.DataPrep/README_DataPrep.md b/Tests.DataPrep/README_DataPrep.md new file mode 100644 index 0000000..e02abfc --- /dev/null +++ b/Tests.DataPrep/README_DataPrep.md @@ -0,0 +1 @@ + diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index 0e1e429..3012494 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -64,6 +64,7 @@ + diff --git a/Tests.ManagerTests/README_TestClassReuse.md b/Tests.ManagerTests/README_TestClassReuse.md new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Tests.ManagerTests/README_TestClassReuse.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 6bfb9fd..b6a6853 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -79,6 +79,7 @@ + From 722bc58d08894f23c1c7e212faef3d9f45e2b9a6 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 17:41:23 -0500 Subject: [PATCH 32/74] fill out test class reuse readme --- TestingExemplar.sln | 1 + Tests.ManagerTests/README_TestClassReuse.md | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/TestingExemplar.sln b/TestingExemplar.sln index 8a0d85e..dc560f5 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -26,6 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Docume Shared.DataContracts\README_DataContracts.md = Shared.DataContracts\README_DataContracts.md Shared.DatabaseContext\DTOs\README_DataTransferObjects.md = Shared.DatabaseContext\DTOs\README_DataTransferObjects.md Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md + Tests.ManagerTests\README_TestClassReuse.md = Tests.ManagerTests\README_TestClassReuse.md Test.NUnitExtensions\README_TestPrefixes.md = Test.NUnitExtensions\README_TestPrefixes.md EndProjectSection EndProject diff --git a/Tests.ManagerTests/README_TestClassReuse.md b/Tests.ManagerTests/README_TestClassReuse.md index 5f28270..82c1fdd 100644 --- a/Tests.ManagerTests/README_TestClassReuse.md +++ b/Tests.ManagerTests/README_TestClassReuse.md @@ -1 +1,17 @@ - \ No newline at end of file +# Test Class Reuse + +There are to common automated test types written by developers. + - Unit tests: verify a specific piece of code in isolation + - Integration tests: verify that the components in a flow work together as expected + +Between our dependency injection and abstracted data prep, our unit tests can configure both the +dependencies and persistance of data independed of individual tests. This means that our tests +specify a situation, with out regard to execution context. + +Thus, our unit tests and integration tests now only differ by configuration. Using NUnit, +we can easily run a test class with two different configurations and cut our testing effort in half! + +Some examples are shown of test reuse with MSTest, but it is neither as easy nor as clear as with NUnit. + +We have plans to create more clear NUnit attributes that will prefix integration tests and allow us to exclude +individual methods from either unit or integration runs From bf117c2a5635df40808b7a51e706e1902a76efa4 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 17:53:58 -0500 Subject: [PATCH 33/74] fill in dependency injection readme --- .../README_DependencyInjection.md | 24 ++++++++++++++++++- TestingExemplar.sln | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjection.md b/Shared.DependencyInjectionKernel/README_DependencyInjection.md index 5f28270..164d9c9 100644 --- a/Shared.DependencyInjectionKernel/README_DependencyInjection.md +++ b/Shared.DependencyInjectionKernel/README_DependencyInjection.md @@ -1 +1,23 @@ - \ No newline at end of file +# Dependency Injection + +Dependency Inversion is the D of the five SOLID priciples. Dependency injection is a popular way of +achieving dependency inversion. + +Dependency injection turns function calls into configuration. Instead of instantiating the class you want to call, +you have a registry of forms mapped to dependencies. You specify the form of class you want, and the registry container +hands you an implementation. + +In languages like C#, the 'form' is almost always specified using interfaces. Interfaces have the benefit of ensuring a +certain level of behavior and one class can satisfy many interfaces. + +So, what's the deal. Why do we even want this? + +Academically, it breaks the dependency of the higher level class on the lower level class. You no longer are explictly +tied to the details of low level concerns. + +Practically, this + - Allows us to write code top-down, simply writing in the interfaces of the next level of dependencies we need. + This makes for less code re-work and allows us to test a flow without writing the whole dependency stack + - Allows us to swap in different dependencies of equivalent purpose with only config change + - E.g. you could completely switch storage paradigms based on execution environment + - Allows us to isolate code for testing \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index dc560f5..fd92594 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -25,6 +25,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Docume README.md = README.md Shared.DataContracts\README_DataContracts.md = Shared.DataContracts\README_DataContracts.md Shared.DatabaseContext\DTOs\README_DataTransferObjects.md = Shared.DatabaseContext\DTOs\README_DataTransferObjects.md + Shared.DependencyInjectionKernel\README_DependencyInjection.md = Shared.DependencyInjectionKernel\README_DependencyInjection.md Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md Tests.ManagerTests\README_TestClassReuse.md = Tests.ManagerTests\README_TestClassReuse.md Test.NUnitExtensions\README_TestPrefixes.md = Test.NUnitExtensions\README_TestPrefixes.md From f709a580626fb526c04102d83214ea782226b4d7 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 18:01:18 -0500 Subject: [PATCH 34/74] fill in info on distributed di loaders and friend assemblies --- .../README_DependencyInjection.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjection.md b/Shared.DependencyInjectionKernel/README_DependencyInjection.md index 164d9c9..ecd4c96 100644 --- a/Shared.DependencyInjectionKernel/README_DependencyInjection.md +++ b/Shared.DependencyInjectionKernel/README_DependencyInjection.md @@ -20,4 +20,22 @@ Practically, this This makes for less code re-work and allows us to test a flow without writing the whole dependency stack - Allows us to swap in different dependencies of equivalent purpose with only config change - E.g. you could completely switch storage paradigms based on execution environment - - Allows us to isolate code for testing \ No newline at end of file + - Allows us to isolate code for testing + + +# Distributed Dependency Configuration / Loaders + +You may notice that each project (thus assembly) defines it's own dependency injection configuration. +This allows us to configure DI without making implementations public. This prevents people from using +concrete classes directly and thus breaking code isolation. + +It also packages dependencies that are used together, cutting down on use-time config setup. + +# Friend Assemblies +Along side every dependency loader is a friend assembly file. Friend assemblies are a .NET concept +that allows you to expose internal constructs to specific assemblies. + +This allows us to test against concrete classes while keeping them hidden from other consuming assemblies. + +We have a dedicated friendassembly file for simplicity of finding and modifying the friends as well as leaving +this unrelated concern out of the service implementations \ No newline at end of file From f7a8e59f1220637799271704bd1b2b3c932c9291 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 18:11:16 -0500 Subject: [PATCH 35/74] fill in data prep readme --- TestingExemplar.sln | 1 + Tests.DataPrep/README_DataPrep.md | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/TestingExemplar.sln b/TestingExemplar.sln index fd92594..c9e5f04 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Docume 1.README_SolutionStructure.md = 1.README_SolutionStructure.md README.md = README.md Shared.DataContracts\README_DataContracts.md = Shared.DataContracts\README_DataContracts.md + Tests.DataPrep\README_DataPrep.md = Tests.DataPrep\README_DataPrep.md Shared.DatabaseContext\DTOs\README_DataTransferObjects.md = Shared.DatabaseContext\DTOs\README_DataTransferObjects.md Shared.DependencyInjectionKernel\README_DependencyInjection.md = Shared.DependencyInjectionKernel\README_DependencyInjection.md Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md diff --git a/Tests.DataPrep/README_DataPrep.md b/Tests.DataPrep/README_DataPrep.md index e02abfc..80d7bc6 100644 --- a/Tests.DataPrep/README_DataPrep.md +++ b/Tests.DataPrep/README_DataPrep.md @@ -1 +1,20 @@ - +#DataPrep Pattern +The DataPrep pattern is a way of centralizing test data generation and creating readable handles for common +data requests. + +The pattern consists of two parts +1. individual data preps: these handle + - the construction of a particular type based on passed conditions + - abstraction of complex arrangement scenarios +2. data prep orchestrator: this class is responsible for + - providing a central handle for creating test data + - allowing us to configure type data preps uniformly + - allowing us to present type data preps differently for different scenarios + + +We utilize a test data generation library called Bogus. Bogus can generate complex data types, so why don't we use that directly? +Well, + - When data structures change, it is much harder to find specific uses of a library than a central method + - You still end up with a lot of noisy configuration in your tests + - Data prep produces clearer specification of test situations, especially with complex situations + - a custom DataPrep wrapper allows us to absract how we persist data From 1dc1a9936bc9b2b1ac02085b6c46a67d05a88618 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 19:00:58 -0500 Subject: [PATCH 36/74] finish solution structure readme and modify datacontract readme to match --- 1.README_SolutionStructure.md | 51 ++++++++++++++++++++ Shared.DataContracts/README_DataContracts.md | 33 +++++++------ 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/1.README_SolutionStructure.md b/1.README_SolutionStructure.md index e69de29..d7fadc3 100644 --- a/1.README_SolutionStructure.md +++ b/1.README_SolutionStructure.md @@ -0,0 +1,51 @@ +# Service Orientation + +Service orientation is a pattern of the same level as object orientation or functional programming. It determines your basic unit +of design. In OO, you basic unit is an object. In functional, it's a function. In service-oriented, it's a service and a contract. +A service is a cohesive and isolated collection of operations. Every function in the service fits one high-level purpose, typically hiding one +design descision. You should never have to look further than the service to completely understand the work that a service accomplishes. Thus, +it is imparative to have clear and simple hand-offs to and from the service. + +That is where contracts come in. They are the possible hand-off values of a service. If services represent function, contracts represent data. +The simpler your contracts are, the less you are able to have un-expected ties between services, and the less likely you are to break isolation. +As a rule of thumb, if you can't tell exactly what you can and can't do based on the the interface signature (and maybe a contract definition), it is too complex. + +#IDesign +The key to understanding the code layout is a pattern called IDesign. +IDesign is a layered, service-oriented architecture pattern. + +IDesign has five layers + +Clients - responsible for consumption of your program. For example, user interfaces, apis, windows services. +Managers - Organize the order of execution. These are the primary flows of your application +Engines - The algorithms, business logic, data-manipulation type stuff +Accessor - Abstract external resources for use by the application. For example, database access, file system access, external apis +Resources - Anything not controlled by your code (databases, external apis, etc). These are what accessors abstract. + +Layers may only call into the adjacent lower layer. (I.E. engines only call accessors, accessors only call resources). +The one exception is that managers can call to both engines and accessors. Sometimes a client may call an engine, but it is rare +that this is a good choice. +However, engines never call managers. That would mean your processing is calling your orchestration, which can lead to many unexpected +execution order problems. + +These simple rules categorize and organize the vast majority of programming responsibility types. The simple rules allow you to quickly find +a piece of code and limit what other units of code it could be working with, thus reducing complexity. + +By considering the few rules of IDesign, you are also led to follow other known best practices like SOLID, information hiding, stable dependencies and others. +One principle worth calling out specifically is single responsibility principle. IDesign draws attention to sneaky violations of single responsibility principle +by differentiating responsibility types. + + +#Folder Structure +The folder structure reflects the primary responsibilities of IDesign, and other primary concerns like testing. +It allows the solution to be more easily navigated and not have an overwhelming number of choices as the +number of projects grows. + +The numbers in the folders allow us to set the folder order to match the layering metaphor instead of being alphabetic. + +The shared folder is for meta-infrastructure that is needed across projects. For example, dependency injection config, data contracts, and possibly logging. +Do not be tempted to put app functionality in this folder + +#Project Name Prefixes +Adding some namespacing to our projects (e.g. Accessors.Project or Tests.Project) allows our underlying file structure to +be organized by responsibility type and easily navigated. \ No newline at end of file diff --git a/Shared.DataContracts/README_DataContracts.md b/Shared.DataContracts/README_DataContracts.md index 5fe7f7c..87c1a10 100644 --- a/Shared.DataContracts/README_DataContracts.md +++ b/Shared.DataContracts/README_DataContracts.md @@ -1,32 +1,33 @@ #Data Contracts -Data contracts are the data forms agreed on between services. +Data Contracts are the possible hand-off values of a service. If services represent function, contracts represent data. +The simpler your contracts are, the less you are able to have un-expected ties between services, and the less likely you are to break isolation. +As a rule of thumb, if you can't tell exactly what you can and can't do based on the the interface signature (and maybe a contract definition), it is too complex. In other words, they: - Represent the data shared by a flow in the application - are the only non-value types that should be available in multiple projects - are the only non-value types returned from an interface - Data contracts should +Data contracts should - be as flat as possible (very rarely contain non-value types) - Contain only the data needed for the situation, split contracts if you have un-needed data - Be named semantically / so that it is clear what purpose they fulfill - Do not contain state or logic. This is both a matter of concurrency (thread safety) and conceptual clarity. - Represent a useful collection of values, not necessarily the database - This -- improves iteroperability (because services use the same types) -- limits the scope of computation-specific and project-specific types by disallowing them as a return type -- When separated from Database Objects, allows you to shape your program without concern for the database structure -- Limits ability to couple services through data, because the contracts are designed for an application flow, - not to particular pieces of code. Being flat and minimal also reduces the possibility for unintended use or - broken expectations -- Disallowing state and logic, besides enabling thread-safe operations, decouples data from actions. This helps allows us to - operate on the data in many valid ways without mixing unrelated logic. It also keeps you from distributing manager-style code, which leads to unexpected actions. - For example, you are passed an object configured to save to the db, but you want to save it to a nosql. However, you either don't know where that object is going to save - or you have to have every interested portion of code check where that object is configured to save and mutate it to fit the current need. - With separated actions and data, there can be no such confusion because the orchestrating context is always responsible for, - well..., orchestrating. -- Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) +This + - Improves iteroperability (because services use the same types) + - Limits the scope of computation-specific and project-specific types by disallowing them as a return type + - When separated from Data Transfer Objects, allows you to shape your program without concern for the database structure + - Limits ability to couple services through data, because the contracts are designed for an application flow, + not to particular pieces of code. Being flat and minimal also reduces the possibility for unintended use or + broken expectations + - Disallowing state and logic, besides enabling thread-safe operations, decouples data from actions. This helps allows us to + operate on the data in many valid ways without mixing unrelated logic. It also keeps us from distributing manager-style/organizational code, which leads to unexpected actions. + For example, you are passed an object configured to save to the db, but you want to save it to a nosql. However, you either don't know where that object is going to save + or every interested portion of code check where that object is configured to save and mutate it to fit the current need. + With separated actions and data, there can be no such confusion because the orchestrating is always left to the service + - Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) #Result Types (i.e. SaveResult/DeleteResult) From fc83d91cab424a78cd40ebf040ff8c2b5366e26b Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 19:13:52 -0500 Subject: [PATCH 37/74] move test bases into own project --- 1.README_SolutionStructure.md | 2 +- README_NamingPatterns.md | 0 .../Test.NUnitExtensions.csproj | 13 ++- Test.NUnitExtensions/packages.config | 2 +- TestingExemplar.sln | 8 ++ .../Tests.AccessorTests.csproj | 11 ++- Tests.AccessorTests/packages.config | 2 +- Tests.ManagerTests/Tests.ManagerTests.csproj | 11 ++- Tests.ManagerTests/packages.config | 2 +- .../AccessorTestBase.cs | 5 +- Tests.TestBases/App.config | 17 ++++ .../ManagerTestBase.cs | 3 +- Tests.TestBases/Properties/AssemblyInfo.cs | 36 ++++++++ Tests.TestBases/Tests.TestBases.csproj | 82 +++++++++++++++++++ Tests.TestBases/packages.config | 5 ++ 15 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 README_NamingPatterns.md rename {Tests.AccessorTests => Tests.TestBases}/AccessorTestBase.cs (87%) create mode 100644 Tests.TestBases/App.config rename {Tests.ManagerTests => Tests.TestBases}/ManagerTestBase.cs (91%) create mode 100644 Tests.TestBases/Properties/AssemblyInfo.cs create mode 100644 Tests.TestBases/Tests.TestBases.csproj create mode 100644 Tests.TestBases/packages.config diff --git a/1.README_SolutionStructure.md b/1.README_SolutionStructure.md index d7fadc3..4ee6a88 100644 --- a/1.README_SolutionStructure.md +++ b/1.README_SolutionStructure.md @@ -44,7 +44,7 @@ number of projects grows. The numbers in the folders allow us to set the folder order to match the layering metaphor instead of being alphabetic. The shared folder is for meta-infrastructure that is needed across projects. For example, dependency injection config, data contracts, and possibly logging. -Do not be tempted to put app functionality in this folder +Do not be tempted to put app functionality in this folder. #Project Name Prefixes Adding some namespacing to our projects (e.g. Accessors.Project or Tests.Project) allows our underlying file structure to diff --git a/README_NamingPatterns.md b/README_NamingPatterns.md new file mode 100644 index 0000000..e69de29 diff --git a/Test.NUnitExtensions/Test.NUnitExtensions.csproj b/Test.NUnitExtensions/Test.NUnitExtensions.csproj index 4a5e8f0..ce21c6a 100644 --- a/Test.NUnitExtensions/Test.NUnitExtensions.csproj +++ b/Test.NUnitExtensions/Test.NUnitExtensions.csproj @@ -1,5 +1,6 @@  + Debug @@ -11,6 +12,8 @@ Test.NUnitExtensions v4.6.1 512 + + true @@ -30,8 +33,8 @@ 4 - - ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll @@ -51,4 +54,10 @@ + + + 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}. + + + \ No newline at end of file diff --git a/Test.NUnitExtensions/packages.config b/Test.NUnitExtensions/packages.config index b93fa21..ebeb58f 100644 --- a/Test.NUnitExtensions/packages.config +++ b/Test.NUnitExtensions/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index c9e5f04..3aeeaa7 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Docume Shared.DatabaseContext\DTOs\README_DataTransferObjects.md = Shared.DatabaseContext\DTOs\README_DataTransferObjects.md Shared.DependencyInjectionKernel\README_DependencyInjection.md = Shared.DependencyInjectionKernel\README_DependencyInjection.md Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md + README_NamingPatterns.md = README_NamingPatterns.md Tests.ManagerTests\README_TestClassReuse.md = Tests.ManagerTests\README_TestClassReuse.md Test.NUnitExtensions\README_TestPrefixes.md = Test.NUnitExtensions\README_TestPrefixes.md EndProjectSection @@ -42,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionK EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.NUnitExtensions", "Test.NUnitExtensions\Test.NUnitExtensions.csproj", "{3AC5C65A-6F68-479C-A078-3D2E573111BB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.TestBases", "Tests.TestBases\Tests.TestBases.csproj", "{EBD233E2-509F-4A6A-B43E-034986583AE2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -84,6 +87,10 @@ Global {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Debug|Any CPU.Build.0 = Debug|Any CPU {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Release|Any CPU.Build.0 = Release|Any CPU + {EBD233E2-509F-4A6A-B43E-034986583AE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EBD233E2-509F-4A6A-B43E-034986583AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EBD233E2-509F-4A6A-B43E-034986583AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EBD233E2-509F-4A6A-B43E-034986583AE2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -98,6 +105,7 @@ Global {AF26B020-F939-4353-A41D-F6C0F87D0B81} = {CA030337-D04B-4393-9869-897FA379EC1B} {5F633149-4C66-4D34-98AB-28EE4662B442} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} {3AC5C65A-6F68-479C-A078-3D2E573111BB} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} + {EBD233E2-509F-4A6A-B43E-034986583AE2} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index d06df71..b728e7b 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -1,5 +1,6 @@  + Debug @@ -53,8 +54,8 @@ ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll @@ -65,7 +66,6 @@ - @@ -95,6 +95,10 @@ {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} Tests.DataPrep + + {ebd233e2-509f-4a6a-b43e-034986583ae2} + Tests.TestBases + @@ -104,6 +108,7 @@ + \ No newline at end of file diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config index 5336859..3133ef8 100644 --- a/Tests.AccessorTests/packages.config +++ b/Tests.AccessorTests/packages.config @@ -5,5 +5,5 @@ - + \ No newline at end of file diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index b6a6853..3eccba3 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -1,5 +1,6 @@  + @@ -57,8 +58,8 @@ ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll @@ -70,7 +71,6 @@ - @@ -110,6 +110,10 @@ {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} Tests.DataPrep + + {ebd233e2-509f-4a6a-b43e-034986583ae2} + Tests.TestBases + @@ -120,6 +124,7 @@ + \ No newline at end of file diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index ad69891..6143718 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/Tests.AccessorTests/AccessorTestBase.cs b/Tests.TestBases/AccessorTestBase.cs similarity index 87% rename from Tests.AccessorTests/AccessorTestBase.cs rename to Tests.TestBases/AccessorTestBase.cs index 8aeeb4a..402426c 100644 --- a/Tests.AccessorTests/AccessorTestBase.cs +++ b/Tests.TestBases/AccessorTestBase.cs @@ -1,10 +1,9 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NUnit.Framework; +using NUnit.Framework; using Shared.DatabaseContext; using System.Transactions; using Tests.DataPrep; -namespace Tests.AccessorTests +namespace Tests { public abstract class AccessorTestBase { diff --git a/Tests.TestBases/App.config b/Tests.TestBases/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Tests.TestBases/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.ManagerTests/ManagerTestBase.cs b/Tests.TestBases/ManagerTestBase.cs similarity index 91% rename from Tests.ManagerTests/ManagerTestBase.cs rename to Tests.TestBases/ManagerTestBase.cs index 3cec9c3..7477191 100644 --- a/Tests.ManagerTests/ManagerTestBase.cs +++ b/Tests.TestBases/ManagerTestBase.cs @@ -1,5 +1,4 @@ -//using Microsoft.VisualStudio.TestTools.UnitTesting; -using NUnit.Framework; +using NUnit.Framework; using Shared.DatabaseContext; using System.Transactions; using Tests.DataPrep; diff --git a/Tests.TestBases/Properties/AssemblyInfo.cs b/Tests.TestBases/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0f8c4c1 --- /dev/null +++ b/Tests.TestBases/Properties/AssemblyInfo.cs @@ -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("Tests.TestBases")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("Tests.TestBases")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[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("ebd233e2-509f-4a6a-b43e-034986583ae2")] + +// 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")] diff --git a/Tests.TestBases/Tests.TestBases.csproj b/Tests.TestBases/Tests.TestBases.csproj new file mode 100644 index 0000000..9dce8e0 --- /dev/null +++ b/Tests.TestBases/Tests.TestBases.csproj @@ -0,0 +1,82 @@ + + + + + + Debug + AnyCPU + {EBD233E2-509F-4A6A-B43E-034986583AE2} + Library + Properties + Tests.TestBases + Tests.TestBases + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll + + + + + + + + + + + + + + + + + + + + + + + + {6886BD35-1655-456B-A4C2-6B57BD557254} + Shared.DatabaseContext + + + {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} + Tests.DataPrep + + + + + + 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}. + + + + \ No newline at end of file diff --git a/Tests.TestBases/packages.config b/Tests.TestBases/packages.config new file mode 100644 index 0000000..5ecf148 --- /dev/null +++ b/Tests.TestBases/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From b41cf9271c609cbf856f5e8e2bfabbdac040f1ce Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 19:22:58 -0500 Subject: [PATCH 38/74] testing tools readme --- TestingExemplar.sln | 1 + Tests.TestBases/README_TestingTools.md | 22 ++++++++++++++++++++++ Tests.TestBases/Tests.TestBases.csproj | 1 + 3 files changed, 24 insertions(+) create mode 100644 Tests.TestBases/README_TestingTools.md diff --git a/TestingExemplar.sln b/TestingExemplar.sln index 3aeeaa7..9cc9627 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -30,6 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.Documentation", "0.Docume Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md = Shared.DependencyInjectionKernel\README_DependencyInjectionKernel.md README_NamingPatterns.md = README_NamingPatterns.md Tests.ManagerTests\README_TestClassReuse.md = Tests.ManagerTests\README_TestClassReuse.md + Tests.TestBases\README_TestingTools.md = Tests.TestBases\README_TestingTools.md Test.NUnitExtensions\README_TestPrefixes.md = Test.NUnitExtensions\README_TestPrefixes.md EndProjectSection EndProject diff --git a/Tests.TestBases/README_TestingTools.md b/Tests.TestBases/README_TestingTools.md new file mode 100644 index 0000000..a767355 --- /dev/null +++ b/Tests.TestBases/README_TestingTools.md @@ -0,0 +1,22 @@ +# Testing Tools + +This is sort of a catch-all doc for testing concerns and awesome libraries that make testing easier. + +# Test Dependency Generation +When testing a code, you want the subject of test to be isolated so that there are no errors from code you +don't intend to test. +Dependency injection allows us to configure test dependencies that only do what we expect for the test, but +it can be a lot of work to specify stub dependencies. + +That is where JustMock comes in. It auto-generates test dependencies and allows you to modify their behavior +in the unit test as needed. + +# Complex Object Comparison +DeepEqual allows you to compare complex objects by their values and modify comparison behavior as needed. + +# Data Cleanup +.NET transactions allow you to specify each test as a unit of work. That unit can then be committed or rolled back +as a whole. This means that you don't have to worry about leaving test data behind, it happens auto-magically. + +# DataPrep +Has its own doc, check it out \ No newline at end of file diff --git a/Tests.TestBases/Tests.TestBases.csproj b/Tests.TestBases/Tests.TestBases.csproj index 9dce8e0..87b05f2 100644 --- a/Tests.TestBases/Tests.TestBases.csproj +++ b/Tests.TestBases/Tests.TestBases.csproj @@ -57,6 +57,7 @@ + From 35abb737e8d5c56b7ec01f563ac37eae73729b68 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Wed, 14 Mar 2018 19:37:27 -0500 Subject: [PATCH 39/74] naming patterns readme --- README_NamingPatterns.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README_NamingPatterns.md b/README_NamingPatterns.md index e69de29..5fd4f5c 100644 --- a/README_NamingPatterns.md +++ b/README_NamingPatterns.md @@ -0,0 +1,27 @@ +# Naming + +Naming is one of the most important tasks you do as a programmer. Name determine how coders will percieve the decomposition of the system +, how easy it is to tell what code does, and how easy it is to find code for a specific need. + +##Manager Naming: + Managers should be named for the application flow they organize. For example, UserCheckoutManager is all the tools functions needed to +help a user review their order and purchase. +Managers tend to not be centered on nouns, but on chunks of the UX (user experience). Manager are the head of your application. +If you were to get rid of all of your client (web apps, etc) and write a new one, you should only have to map manager methods to UI +components. + +The functions in a manager should be named for the purpose they accomplish, not the data that they process. + +#Engine Naming +Engines tend to be pretty easy to name. They generally have one computational purpose or one verb that they center around. + +#Accessor Naming +Accessors are intrinsically tied to a data source. They can be used by many flows and tend to center around a data type. + + +#Variable Naming +You should be able to tell what a varible in intended for, not just it's type (though in some cases, like accessors, the type indicates sufficient purpose). +This prevents mistaken manipulation of a variable and clarifies intent for later modification. + +You should also never reuse a variable. If you've changed the intent of the data, you should give it a new name to reflect the reason for the change. +For example, if you sort a list, re-assign it to a variable that declares it as sorted. \ No newline at end of file From 994856d0e632481129c4d0145cd398dc099defc3 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 15 Mar 2018 15:53:33 -0500 Subject: [PATCH 40/74] add db context override to collapse entity validation error --- Shared.DatabaseContext/TodoContext.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Shared.DatabaseContext/TodoContext.cs b/Shared.DatabaseContext/TodoContext.cs index 572e959..5aa5da8 100644 --- a/Shared.DatabaseContext/TodoContext.cs +++ b/Shared.DatabaseContext/TodoContext.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Data.Entity; +using System.Data.Entity.Validation; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -17,5 +18,28 @@ public class TodoContext : DbContext public TodoContext() : base("TodoDb") { } + + public override int SaveChanges() + { + // collapse the entity validation errors into the exception message for convenience of debugging + try + { + return base.SaveChanges(); + } + catch (DbEntityValidationException ex) + { + var entityErrorList = ex.EntityValidationErrors + .SelectMany(x => x.ValidationErrors) + .Select(x => x.ErrorMessage); + + var entityErrorMessage = string.Join("; ", entityErrorList); + + // combine entity errors with original exception + var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", entityErrorMessage); + + // re-throw the error with the new exception message + throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); + } + } } } From 3fb8686cad96708b8033c63935794ed9558b2302 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Tue, 20 Mar 2018 20:30:54 -0500 Subject: [PATCH 41/74] add explanations that relate idesign to orthogonality and Information Hiding closes #19 --- 1.README_SolutionStructure.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/1.README_SolutionStructure.md b/1.README_SolutionStructure.md index 4ee6a88..d24b1c1 100644 --- a/1.README_SolutionStructure.md +++ b/1.README_SolutionStructure.md @@ -14,7 +14,7 @@ As a rule of thumb, if you can't tell exactly what you can and can't do based on The key to understanding the code layout is a pattern called IDesign. IDesign is a layered, service-oriented architecture pattern. -IDesign has five layers +IDesign has five layers. Clients - responsible for consumption of your program. For example, user interfaces, apis, windows services. Managers - Organize the order of execution. These are the primary flows of your application @@ -22,6 +22,13 @@ Engines - The algorithms, business logic, data-manipulation type stuff Accessor - Abstract external resources for use by the application. For example, database access, file system access, external apis Resources - Anything not controlled by your code (databases, external apis, etc). These are what accessors abstract. +Viewed in terms of orthogonality and information hiding, each layer is responsible for isolating/hiding a particular type of design concern. + +Accessors - Third party code or components not fully in your application's control +Engines - Computation +Managers - Composition of functionality +Clients - Application representation and interaction + Layers may only call into the adjacent lower layer. (I.E. engines only call accessors, accessors only call resources). The one exception is that managers can call to both engines and accessors. Sometimes a client may call an engine, but it is rare that this is a good choice. From edf7afa74040dc47f7674cd3f00608924a590615 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Tue, 27 Mar 2018 10:59:40 -0500 Subject: [PATCH 42/74] Add presentation links to readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a286859..26623e8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ This project is to record and share patterns and libraries that make testing As a result, it also demonstrates many other patterns and libraries that enable good development practices. +Here is the presentation the triggered the project: https://1drv.ms/p/s!AjVvNQ4uturOdRxhCnyW16c_yk4 + +Here is a presentation that describes the design philosphies: https://1drv.ms/b/s!AjVvNQ4uturOby6OwKMFpMUlMqA + This project is very much overkill for a Todo list. However, the overkill is to demonstrate the patterns in a way that can easily be transfered to a large project Testing Patterns From a3f08a3768c7f77e877d8c71c3278054aa7d5528 Mon Sep 17 00:00:00 2001 From: farlee2121 Date: Mon, 30 Apr 2018 10:18:33 -0500 Subject: [PATCH 43/74] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26623e8..93f7971 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Testing Patterns - Dependency Injection - DataPrep (centralized test data generators) - ConfigWrappers //pending -- Inconclusive tests to mark untested code // pending +- Inconclusive tests to mark untested code - Test name modification for test runner (display extra info without manually adding it to each test name) - Unit/Integration test reuse From f8a51b8db6b1b8e6e42d60501665da0a4286788e Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Wed, 26 Dec 2018 16:37:34 -0600 Subject: [PATCH 44/74] Change datacontracts to a standard library and update NUnit --- .../Accessors.DatabaseAccessors.csproj | 2 +- ...anagers.LazyCollectionOfAllManagers.csproj | 2 +- .../Shared.DataContracts.csproj | 58 ++----------------- .../Properties/AssemblyInfo.cs | 0 .../Shared.DatabaseContext.csproj | 2 +- .../Test.NUnitExtensions.csproj | 8 +-- Test.NUnitExtensions/TestFixture_Prefixed.cs | 17 +++++- Test.NUnitExtensions/packages.config | 2 +- TestingExemplar.sln | 14 ++--- .../Tests.AccessorTests.csproj | 12 ++-- Tests.AccessorTests/packages.config | 3 +- Tests.DataPrep/Tests.DataPrep.csproj | 2 +- Tests.ManagerTests/Tests.ManagerTests.csproj | 14 ++--- Tests.ManagerTests/packages.config | 4 +- Tests.TestBases/Tests.TestBases.csproj | 8 +-- Tests.TestBases/packages.config | 2 +- 16 files changed, 60 insertions(+), 90 deletions(-) rename {Shared.DataContracts => Shared.DataContracts2}/Properties/AssemblyInfo.cs (100%) diff --git a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj index 7965408..0ffd92c 100644 --- a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj +++ b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj @@ -70,7 +70,7 @@ Shared.DatabaseContext - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} Shared.DataContracts diff --git a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj index 2ed9e43..2689acf 100644 --- a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj +++ b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj @@ -66,7 +66,7 @@ Accessors.DatabaseAccessors - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} Shared.DataContracts diff --git a/Shared.DataContracts/Shared.DataContracts.csproj b/Shared.DataContracts/Shared.DataContracts.csproj index 9b569c8..9f5c4f4 100644 --- a/Shared.DataContracts/Shared.DataContracts.csproj +++ b/Shared.DataContracts/Shared.DataContracts.csproj @@ -1,55 +1,7 @@ - - - + + - Debug - AnyCPU - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} - Library - Properties - Shared.DataContracts - Shared.DataContracts - v4.6.1 - 512 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/Shared.DataContracts/Properties/AssemblyInfo.cs b/Shared.DataContracts2/Properties/AssemblyInfo.cs similarity index 100% rename from Shared.DataContracts/Properties/AssemblyInfo.cs rename to Shared.DataContracts2/Properties/AssemblyInfo.cs diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index 6cd545c..6ef3f8c 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -83,7 +83,7 @@ - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} Shared.DataContracts diff --git a/Test.NUnitExtensions/Test.NUnitExtensions.csproj b/Test.NUnitExtensions/Test.NUnitExtensions.csproj index ce21c6a..a56d527 100644 --- a/Test.NUnitExtensions/Test.NUnitExtensions.csproj +++ b/Test.NUnitExtensions/Test.NUnitExtensions.csproj @@ -1,6 +1,6 @@  - + Debug @@ -33,8 +33,8 @@ 4 - - ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll @@ -58,6 +58,6 @@ 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}. - + \ No newline at end of file diff --git a/Test.NUnitExtensions/TestFixture_Prefixed.cs b/Test.NUnitExtensions/TestFixture_Prefixed.cs index 8192d23..9b0d60a 100644 --- a/Test.NUnitExtensions/TestFixture_Prefixed.cs +++ b/Test.NUnitExtensions/TestFixture_Prefixed.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -31,7 +32,7 @@ public IEnumerable BuildFrom(ITypeInfo typeInfo) // This possibly implies that cases are built after the fixture methods run // https://groups.google.com/forum/#!topic/nunit-discuss/PT0NQaL7AMg NUnitTestFixtureBuilder b = new NUnitTestFixtureBuilder(); - TestSuite testSuite = b.BuildFrom(typeInfo, this); + TestSuite testSuite = b.BuildFrom(typeInfo, new NoFilter()); foreach (NUnit.Framework.Internal.Test t in testSuite.Tests) { t.Name = $"{_prefix}_{t.Name}"; @@ -54,4 +55,18 @@ public IEnumerable BuildFrom(ITypeInfo typeInfo) // return testMethod; // } //} + + class NoFilter : IPreFilter + { + //ref: https://github.com/nunit/nunit/issues/3050 + public bool IsMatch(Type type) + { + return true; + } + + public bool IsMatch(Type type, MethodInfo method) + { + return true; + } + } } diff --git a/Test.NUnitExtensions/packages.config b/Test.NUnitExtensions/packages.config index ebeb58f..b552965 100644 --- a/Test.NUnitExtensions/packages.config +++ b/Test.NUnitExtensions/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index 9cc9627..c2f4a82 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managers.LazyCollectionOfAllManagers", "Managers.LazyCollectionOfAllManagers\Managers.LazyCollectionOfAllManagers.csproj", "{20052ECB-4E1D-4F2F-9F06-79111FE381F8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DataContracts", "Shared.DataContracts\Shared.DataContracts.csproj", "{49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DatabaseContext", "Shared.DatabaseContext\Shared.DatabaseContext.csproj", "{6886BD35-1655-456B-A4C2-6B57BD557254}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.DataPrep", "Tests.DataPrep\Tests.DataPrep.csproj", "{458ED4A8-E0F2-4089-94CB-20B0EFDD4B46}" @@ -46,6 +44,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.NUnitExtensions", "Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.TestBases", "Tests.TestBases\Tests.TestBases.csproj", "{EBD233E2-509F-4A6A-B43E-034986583AE2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DataContracts", "Shared.DataContracts\Shared.DataContracts.csproj", "{0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -56,10 +56,6 @@ Global {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {20052ECB-4E1D-4F2F-9F06-79111FE381F8}.Release|Any CPU.Build.0 = Release|Any CPU - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B}.Release|Any CPU.Build.0 = Release|Any CPU {6886BD35-1655-456B-A4C2-6B57BD557254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6886BD35-1655-456B-A4C2-6B57BD557254}.Debug|Any CPU.Build.0 = Debug|Any CPU {6886BD35-1655-456B-A4C2-6B57BD557254}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -92,13 +88,16 @@ Global {EBD233E2-509F-4A6A-B43E-034986583AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBD233E2-509F-4A6A-B43E-034986583AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {EBD233E2-509F-4A6A-B43E-034986583AE2}.Release|Any CPU.Build.0 = Release|Any CPU + {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {20052ECB-4E1D-4F2F-9F06-79111FE381F8} = {01383730-F2FD-4900-B91C-4784EDA64DF6} - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} {6886BD35-1655-456B-A4C2-6B57BD557254} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} @@ -107,6 +106,7 @@ Global {5F633149-4C66-4D34-98AB-28EE4662B442} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} {3AC5C65A-6F68-479C-A078-3D2E573111BB} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {EBD233E2-509F-4A6A-B43E-034986583AE2} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} + {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index b728e7b..6293706 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -1,6 +1,7 @@  - + + Debug @@ -54,8 +55,8 @@ ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll @@ -84,7 +85,7 @@ Shared.DatabaseContext - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} Shared.DataContracts @@ -108,7 +109,8 @@ - + + \ No newline at end of file diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config index 3133ef8..cf33de9 100644 --- a/Tests.AccessorTests/packages.config +++ b/Tests.AccessorTests/packages.config @@ -5,5 +5,6 @@ - + + \ No newline at end of file diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index 3012494..aeddbf3 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -72,7 +72,7 @@ Shared.DatabaseContext - {49F40A81-DBBC-4904-96E3-E5EF1F7D2A7B} + {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} Shared.DataContracts diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 3eccba3..d23e763 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -1,7 +1,7 @@  - - + + Debug @@ -58,8 +58,8 @@ ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll @@ -95,7 +95,7 @@ Shared.DatabaseContext - {49f40a81-dbbc-4904-96e3-e5ef1f7d2a7b} + {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} Shared.DataContracts @@ -123,8 +123,8 @@ - - + + \ No newline at end of file diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index 6143718..cc2dcb7 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -6,6 +6,6 @@ - - + + \ No newline at end of file diff --git a/Tests.TestBases/Tests.TestBases.csproj b/Tests.TestBases/Tests.TestBases.csproj index 87b05f2..394dba3 100644 --- a/Tests.TestBases/Tests.TestBases.csproj +++ b/Tests.TestBases/Tests.TestBases.csproj @@ -1,6 +1,6 @@  - + Debug @@ -39,8 +39,8 @@ ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll @@ -78,6 +78,6 @@ 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}. - + \ No newline at end of file diff --git a/Tests.TestBases/packages.config b/Tests.TestBases/packages.config index 5ecf148..6349b44 100644 --- a/Tests.TestBases/packages.config +++ b/Tests.TestBases/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file From c88df51ad7dd69bc4e08a3fc77749c58a67eb9e0 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Wed, 26 Dec 2018 17:11:03 -0600 Subject: [PATCH 45/74] update di containter to .net standard --- .../Properties/AssemblyInfo.cs | 36 ---------- .../Properties/AssemblyInfo.cs | 36 ---------- .../Shared.DependencyInjectionKernel.csproj | 69 +++---------------- .../packages.config | 4 -- TestingExemplar.sln | 14 ++-- Tests.ManagerTests/Tests.ManagerTests.csproj | 2 +- 6 files changed, 18 insertions(+), 143 deletions(-) delete mode 100644 Shared.DataContracts2/Properties/AssemblyInfo.cs delete mode 100644 Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs delete mode 100644 Shared.DependencyInjectionKernel/packages.config diff --git a/Shared.DataContracts2/Properties/AssemblyInfo.cs b/Shared.DataContracts2/Properties/AssemblyInfo.cs deleted file mode 100644 index f2ae5e9..0000000 --- a/Shared.DataContracts2/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Shared.DataContracts")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Shared.DataContracts")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("49f40a81-dbbc-4904-96e3-e5ef1f7d2a7b")] - -// 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")] diff --git a/Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs b/Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs deleted file mode 100644 index d9cff75..0000000 --- a/Shared.DependencyInjectionKernel/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Shared.DependencyInjectionKernel")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Shared.DependencyInjectionKernel")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("5f633149-4c66-4d34-98ab-28ee4662b442")] - -// 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")] diff --git a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj index 9d89934..ab61e36 100644 --- a/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj +++ b/Shared.DependencyInjectionKernel/Shared.DependencyInjectionKernel.csproj @@ -1,65 +1,16 @@ - - - + + - Debug - AnyCPU - {5F633149-4C66-4D34-98AB-28EE4662B442} - Library - Properties - Shared.DependencyInjectionKernel - Shared.DependencyInjectionKernel - v4.6.1 - 512 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - - - - - - - - - - - - - - + - - + + - - {af26b020-f939-4353-a41d-f6c0f87d0b81} - Accessors.DatabaseAccessors - - - {20052ecb-4e1d-4f2f-9f06-79111fe381f8} - Managers.LazyCollectionOfAllManagers - + + - - \ No newline at end of file + + diff --git a/Shared.DependencyInjectionKernel/packages.config b/Shared.DependencyInjectionKernel/packages.config deleted file mode 100644 index 8e2c684..0000000 --- a/Shared.DependencyInjectionKernel/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/TestingExemplar.sln b/TestingExemplar.sln index c2f4a82..d62f385 100644 --- a/TestingExemplar.sln +++ b/TestingExemplar.sln @@ -38,14 +38,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4.Accessors", "4.Accessors" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "5.Shared", "5.Shared", "{E1966F97-64AF-4CA1-9CDB-DA841C9491B9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionKernel", "Shared.DependencyInjectionKernel\Shared.DependencyInjectionKernel.csproj", "{5F633149-4C66-4D34-98AB-28EE4662B442}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.NUnitExtensions", "Test.NUnitExtensions\Test.NUnitExtensions.csproj", "{3AC5C65A-6F68-479C-A078-3D2E573111BB}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.TestBases", "Tests.TestBases\Tests.TestBases.csproj", "{EBD233E2-509F-4A6A-B43E-034986583AE2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DataContracts", "Shared.DataContracts\Shared.DataContracts.csproj", "{0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.DependencyInjectionKernel", "Shared.DependencyInjectionKernel\Shared.DependencyInjectionKernel.csproj", "{A697FACF-33EB-47CF-91CD-11CB6A870CB6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -76,10 +76,6 @@ Global {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF26B020-F939-4353-A41D-F6C0F87D0B81}.Release|Any CPU.Build.0 = Release|Any CPU - {5F633149-4C66-4D34-98AB-28EE4662B442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5F633149-4C66-4D34-98AB-28EE4662B442}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5F633149-4C66-4D34-98AB-28EE4662B442}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5F633149-4C66-4D34-98AB-28EE4662B442}.Release|Any CPU.Build.0 = Release|Any CPU {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Debug|Any CPU.Build.0 = Debug|Any CPU {3AC5C65A-6F68-479C-A078-3D2E573111BB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -92,6 +88,10 @@ Global {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Debug|Any CPU.Build.0 = Debug|Any CPU {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Release|Any CPU.ActiveCfg = Release|Any CPU {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E}.Release|Any CPU.Build.0 = Release|Any CPU + {A697FACF-33EB-47CF-91CD-11CB6A870CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A697FACF-33EB-47CF-91CD-11CB6A870CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A697FACF-33EB-47CF-91CD-11CB6A870CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A697FACF-33EB-47CF-91CD-11CB6A870CB6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -103,10 +103,10 @@ Global {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {AF26B020-F939-4353-A41D-F6C0F87D0B81} = {CA030337-D04B-4393-9869-897FA379EC1B} - {5F633149-4C66-4D34-98AB-28EE4662B442} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} {3AC5C65A-6F68-479C-A078-3D2E573111BB} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {EBD233E2-509F-4A6A-B43E-034986583AE2} = {3B08858C-6FD1-47E7-824C-0B3F1D234455} {0C5F8E80-076A-4C48-900D-D5E6B0C1F34E} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} + {A697FACF-33EB-47CF-91CD-11CB6A870CB6} = {E1966F97-64AF-4CA1-9CDB-DA841C9491B9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1292F67E-01C7-4886-997A-51E54049301C} diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index d23e763..9acc6d1 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -99,7 +99,7 @@ Shared.DataContracts - {5F633149-4C66-4D34-98AB-28EE4662B442} + {a697facf-33eb-47cf-91cd-11cb6a870cb6} Shared.DependencyInjectionKernel From 6e75144e28ac6801dd10f67960447f1d088a1f1b Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 09:55:57 -0600 Subject: [PATCH 46/74] Basically functional with entity framework core --- .../Accessors.DatabaseAccessors.csproj | 72 +++++++++- Accessors.DatabaseAccessors/App.config | 10 +- .../TodoItemAccessor.cs | 4 +- .../TodoListAccessor.cs | 4 +- Accessors.DatabaseAccessors/packages.config | 25 +++- .../App.config | 10 +- ...anagers.LazyCollectionOfAllManagers.csproj | 6 - .../packages.config | 1 - .../201803052220061_Init.Designer.cs | 29 ---- .../Migrations/201803052220061_Init.cs | 58 -------- .../Migrations/201803052220061_Init.resx | 126 ------------------ ...201803061729594_AddActiveFlags.Designer.cs | 29 ---- .../201803061729594_AddActiveFlags.cs | 20 --- .../201803061729594_AddActiveFlags.resx | 126 ------------------ .../Migrations/Configuration.cs | 23 ---- .../Properties/AssemblyInfo.cs | 36 ----- .../Shared.DatabaseContext.csproj | 95 ++----------- Shared.DatabaseContext/TodoContext.cs | 48 ++++--- Tests.AccessorTests/App.config | 10 +- .../Tests.AccessorTests.csproj | 91 ++++++++++++- Tests.AccessorTests/packages.config | 30 ++++- Tests.DataPrep/App.config | 10 +- Tests.DataPrep/Tests.DataPrep.csproj | 78 ++++++++++- Tests.DataPrep/packages.config | 27 +++- Tests.ManagerTests/App.config | 10 +- Tests.ManagerTests/Tests.ManagerTests.csproj | 80 ++++++++++- Tests.ManagerTests/packages.config | 27 +++- Tests.TestBases/AccessorTestBase.cs | 2 +- Tests.TestBases/App.config | 10 +- Tests.TestBases/ManagerTestBase.cs | 2 +- Tests.TestBases/Tests.TestBases.csproj | 78 ++++++++++- Tests.TestBases/packages.config | 27 +++- 32 files changed, 609 insertions(+), 595 deletions(-) delete mode 100644 Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs delete mode 100644 Shared.DatabaseContext/Migrations/201803052220061_Init.cs delete mode 100644 Shared.DatabaseContext/Migrations/201803052220061_Init.resx delete mode 100644 Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs delete mode 100644 Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs delete mode 100644 Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx delete mode 100644 Shared.DatabaseContext/Migrations/Configuration.cs delete mode 100644 Shared.DatabaseContext/Properties/AssemblyInfo.cs diff --git a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj index 0ffd92c..69cd69c 100644 --- a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj +++ b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj @@ -33,18 +33,82 @@ ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll + + ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll + + + ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + diff --git a/Accessors.DatabaseAccessors/App.config b/Accessors.DatabaseAccessors/App.config index 7e1d79c..18f60bd 100644 --- a/Accessors.DatabaseAccessors/App.config +++ b/Accessors.DatabaseAccessors/App.config @@ -1,7 +1,7 @@  - +
@@ -14,4 +14,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index 7796ac2..3152852 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -1,9 +1,9 @@ -using Shared.DatabaseContext; +using Microsoft.EntityFrameworkCore; +using Shared.DatabaseContext; using Shared.DatabaseContext.DBOs; using Shared.DataContracts; using System; using System.Collections.Generic; -using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs index 1bfdf19..cb47910 100644 --- a/Accessors.DatabaseAccessors/TodoListAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -1,9 +1,9 @@ -using Shared.DatabaseContext; +using Microsoft.EntityFrameworkCore; +using Shared.DatabaseContext; using Shared.DatabaseContext.DBOs; using Shared.DataContracts; using System; using System.Collections.Generic; -using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/Accessors.DatabaseAccessors/packages.config b/Accessors.DatabaseAccessors/packages.config index 8b7b658..5bd046e 100644 --- a/Accessors.DatabaseAccessors/packages.config +++ b/Accessors.DatabaseAccessors/packages.config @@ -1,6 +1,29 @@  - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/App.config b/Managers.LazyCollectionOfAllManagers/App.config index 7e1d79c..18f60bd 100644 --- a/Managers.LazyCollectionOfAllManagers/App.config +++ b/Managers.LazyCollectionOfAllManagers/App.config @@ -1,7 +1,7 @@  - +
@@ -14,4 +14,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj index 2689acf..d7661dc 100644 --- a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj +++ b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj @@ -30,12 +30,6 @@ 4 - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll diff --git a/Managers.LazyCollectionOfAllManagers/packages.config b/Managers.LazyCollectionOfAllManagers/packages.config index 4400cc5..8e2c684 100644 --- a/Managers.LazyCollectionOfAllManagers/packages.config +++ b/Managers.LazyCollectionOfAllManagers/packages.config @@ -1,5 +1,4 @@  - \ No newline at end of file diff --git a/Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs b/Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs deleted file mode 100644 index d03f666..0000000 --- a/Shared.DatabaseContext/Migrations/201803052220061_Init.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -namespace Shared.DatabaseContext.Migrations -{ - using System.CodeDom.Compiler; - using System.Data.Entity.Migrations; - using System.Data.Entity.Migrations.Infrastructure; - using System.Resources; - - [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] - public sealed partial class Init : IMigrationMetadata - { - private readonly ResourceManager Resources = new ResourceManager(typeof(Init)); - - string IMigrationMetadata.Id - { - get { return "201803052220061_Init"; } - } - - string IMigrationMetadata.Source - { - get { return null; } - } - - string IMigrationMetadata.Target - { - get { return Resources.GetString("Target"); } - } - } -} diff --git a/Shared.DatabaseContext/Migrations/201803052220061_Init.cs b/Shared.DatabaseContext/Migrations/201803052220061_Init.cs deleted file mode 100644 index 667f59a..0000000 --- a/Shared.DatabaseContext/Migrations/201803052220061_Init.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace Shared.DatabaseContext.Migrations -{ - using System; - using System.Data.Entity.Migrations; - - public partial class Init : DbMigration - { - public override void Up() - { - CreateTable( - "dbo.TodoItems", - c => new - { - Id = c.Guid(nullable: false, identity: true), - TodoListId = c.Guid(nullable: false), - Description = c.String(), - IsComplete = c.Boolean(nullable: false), - IsActive = c.Boolean(nullable: false), - }) - .PrimaryKey(t => t.Id) - .ForeignKey("dbo.TodoLists", t => t.TodoListId, cascadeDelete: true) - .Index(t => t.TodoListId); - - CreateTable( - "dbo.TodoLists", - c => new - { - Id = c.Guid(nullable: false, identity: true), - UserId = c.Guid(nullable: false), - Title = c.String(), - }) - .PrimaryKey(t => t.Id) - .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true) - .Index(t => t.UserId); - - CreateTable( - "dbo.Users", - c => new - { - Id = c.Guid(nullable: false, identity: true), - Name = c.String(), - }) - .PrimaryKey(t => t.Id); - - } - - public override void Down() - { - DropForeignKey("dbo.TodoItems", "TodoListId", "dbo.TodoLists"); - DropForeignKey("dbo.TodoLists", "UserId", "dbo.Users"); - DropIndex("dbo.TodoLists", new[] { "UserId" }); - DropIndex("dbo.TodoItems", new[] { "TodoListId" }); - DropTable("dbo.Users"); - DropTable("dbo.TodoLists"); - DropTable("dbo.TodoItems"); - } - } -} diff --git a/Shared.DatabaseContext/Migrations/201803052220061_Init.resx b/Shared.DatabaseContext/Migrations/201803052220061_Init.resx deleted file mode 100644 index 6b563d1..0000000 --- a/Shared.DatabaseContext/Migrations/201803052220061_Init.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - H4sIAAAAAAAEAO1a3W7bNhS+H7B3EHS1DamVtDddYLdInKQwlsRBnBa7C2jp2CFGkapIBTaGPdku9kh7hR3qz/qjJf/EyIqiQJFQ5MfDcz4eHn7Mv3//0/+48Jn1DKGkgg/sk96xbQF3hUf5fGBHavbmvf3xw48/9C89f2F9yfq90/1wJJcD+0mp4NRxpPsEPpE9n7qhkGKmeq7wHeIJ5+3x8a/OyYkDCGEjlmX17yOuqA/xL/jrUHAXAhURdiM8YDJtxy+TGNW6JT7IgLgwsCdPJASvd0EUmRIJOFTBQtnWGaMErZkAm9kW4VwootDW088SJioUfD4JsIGwh2UA2G9GmIR0Daer7l2Xc/xWL8dZDcyg3Egq4W8IePIu9Y9THb6Vl+3cf+jBS/S0WupVx14c2A/CEyMF/sX52Laq850OWaj7mvzcw1GyV4A4spo7HuVkQU7pf0fWMGIqCmHAIVIhYUfWXTRl1P0Nlg/iD+ADHjFWNB2Nx2+lBmy6C0UAoVrewyxd0MizLac8zqkOzIcVxiTr/BRR/PkW5yZTBjkxCi6ZKBHCJ+AQEgXeHVEKQq4hIHZtbfLKVNpZ11Sq1inXw1yAdEMaJKRIQ6RC3Ka2dUMW18Dn6mlg44+2dUUX4GUtKfhnTnFX4yAVRq1zjeRQ+AEDBdlU50IwIHxjq0fyzFX0eXOcW/JM57H/De60rXtgcQf5RINk4xeJ+bjqeBUK/16wMvfz748TEYWutlCs6fRAwjmospl9Z7W5WrecRtlxy6UQ37dcG+sw54c7brcHqhjsf6MZaa1NNlI6Dfxj0qlM5+K3RiqXOuxEY42wA4XT4d/p28Y9/f+eqWeK8ZmUwqWx1fVclfCtbOol96w28iWGV8iLS8Bo0gDjh3YM7F9qXlgDndG2AJ2TsQx7YlfDP+YXoI8yS59EuiAbEukSr7430UVeuQUZA6GOGWFIUokcpFzV6UW5SwPCWoyvjOtITG1XPkP1ywUEwDWpWkLSZeosZ9anz2epuKvNO32nwK520tXO7XXsMB/iZfLlhe5m5DMe/924/TpIaFrEgYhoClGX6Ys18wEImeRGfQ7hCAgLRuTXy9qRh/slPfVkmnCrhNKYE1AVikvbWqXiJqbWiFnH0a4x4eSUbMHR+70JI8+rlfEF19WNWRUnhW6mAqYazw5HSm58af01ZnQ4QQpIqQeqG7C80I5OqF86mh2xPsl1T3MVh6TEanGIMat1ce8ax2TFRb6BVvqNkwg4mdDjGJSe/g0JAqxzCspP2mJNEtln+GayuRbiJxiOKxskkdzafCas2sgcKl9xarT0ioZIprRgta2h59e6FdOFYetlM1UzQj1s2abMRuifk1GGCruYQuoZNoW5wvX5OkvHBWoDhxpHxzIcYSRsqIiHgkU+N58Z5tHFFF9EWZf6zWgldaQIV/rQHa+ogJTWWGjfBC1TQcpYWWsdqe9UQlY7BGscqdURZdJ1pmSy+/dEyew02o6SxtEvQ8msBC4imMpiM0qqHJQ4nTS9mjAnJ98eQpwVC5uH1zjyZUKbXKmL45OWA4ekdlJWu+Sz5ydm5WTsp6dU+0NJ7dhKutgWuuaZevrImiwlJv04qr3JVzZkFNe76nBDOJ2BVInYYuOp+r7yzvJ63jwcKT3W/eHj4KJRxOnXCGisAM2orpRbRaJNFcvaO0N9ztotZoT3qMXA/jPGOLVGvz+uYI6scYgsOLWOrb/28VzBn0noYh75ySeLn4uA2z1JTKna+TmiHWMrjf8bZFdZUt+KWQnETqwqqfIb8GljifsbjGBRVd6D63ZQjnOJ4cBybqM8sL1evZUwZ66YXlIN/gYV4A3D94JEypW7bbXnXZ8ZDqzo/n8U3Lpy002jjaO2XqVNiumB7U0FBj5JnkYlzijimifKv5omahbpmlTe5knyL00TNEujh5CAKwaX7oodBd9GPbNJ0n5VUu+GxpuzkEHWexE5t34ZxT1c+Ns+TCOSzlcQ+i/9OLil3Zv3GfGZyBJJxaKsS6WkuQFFPNzaZyEWTcRV+NkFKeMH8y+ERdjl0p+CN+LjSAWRwiWDP2WlB3idjNbNH2vWZZv74/heI/exBDST4hJgzM8jyrzc7quGq4gBQme5tE7UsVS6Xpwvc6RbwTsCpe7Lk/MD4I0LweSYT4i+NG1uG27da5gTd5lpCmaQ9kCU3d6/oGQeEl+mGKvx+Cty2PMXH/4DywD0+eIqAAA= - - - dbo - - \ No newline at end of file diff --git a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs deleted file mode 100644 index ea1f75f..0000000 --- a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -namespace Shared.DatabaseContext.Migrations -{ - using System.CodeDom.Compiler; - using System.Data.Entity.Migrations; - using System.Data.Entity.Migrations.Infrastructure; - using System.Resources; - - [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] - public sealed partial class AddActiveFlags : IMigrationMetadata - { - private readonly ResourceManager Resources = new ResourceManager(typeof(AddActiveFlags)); - - string IMigrationMetadata.Id - { - get { return "201803061729594_AddActiveFlags"; } - } - - string IMigrationMetadata.Source - { - get { return null; } - } - - string IMigrationMetadata.Target - { - get { return Resources.GetString("Target"); } - } - } -} diff --git a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs deleted file mode 100644 index 867b90e..0000000 --- a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Shared.DatabaseContext.Migrations -{ - using System; - using System.Data.Entity.Migrations; - - public partial class AddActiveFlags : DbMigration - { - public override void Up() - { - AddColumn("dbo.TodoLists", "IsActive", c => c.Boolean(nullable: false)); - AddColumn("dbo.Users", "IsActive", c => c.Boolean(nullable: false)); - } - - public override void Down() - { - DropColumn("dbo.Users", "IsActive"); - DropColumn("dbo.TodoLists", "IsActive"); - } - } -} diff --git a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx b/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx deleted file mode 100644 index b195d5c..0000000 --- a/Shared.DatabaseContext/Migrations/201803061729594_AddActiveFlags.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - H4sIAAAAAAAEAO1a227jNhB9L9B/EPTUFlkryb60gb2LxEkWRpM4iLOLvgW0NHaIUqRWpAIbRb+sD/2k/kKHulk3WrKdGNlgESCwKfJwODwzHB36v3/+7X9c+Mx6glBSwQf2Ue/QtoC7wqN8PrAjNXv3q/3xw48/9C88f2F9yfq91/1wJJcD+1Gp4MRxpPsIPpE9n7qhkGKmeq7wHeIJ5/jw8Dfn6MgBhLARy7L6dxFX1If4C34dCu5CoCLCroUHTKbt+GQSo1o3xAcZEBcG9uSRhOD1zokiUyIBhypYKNs6ZZSgNRNgM9sinAtFFNp68lnCRIWCzycBNhB2vwwA+80Ik5Cu4WTVvetyDo/1cpzVwAzKjaQS/oaAR+9T/zjV4Vt52c79hx68QE+rpV517MWBfS88MVLgn5+Nbas638mQhbqvyc89HCV7BYgDq7njQU4W5JT+O7CGEVNRCAMOkQoJO7Buoymj7u+wvBd/Ah/wiLGi6Wg8Pis1YNNtKAII1fIOZumCRp5tOeVxTnVgPqwwJlnnp4ji5xucm0wZ5MQouGSiRAifgENIFHi3RCkIuYaA2LW1yStTaWddUalap1wPcw7SDWmQkCLdIhVimNrWNVlcAZ+rx4GNH23rki7Ay1pS8M+cYlTjIBVGrXON5FD4AQMF2VRnQjAgfGOrR/LUVfRpc5wb8kTnsf8N7rStO2BxB/lIgyTwi8R8WHW8DIV/J1iZ+/nzh4mIQldbKNZ0uifhHFTZzL6zCq7WkNMoO4ZcCvE95NpYhzk/3DHc7qlisIdAe+7w0Es3hkZKoIekUzksis8aQ6LUYadw0Ag7hEI6/HsYtLFL/3+lFDZx5VRK4dJ49fXcmfC2bM0F96w2EicOqAQBugJZQQPkAdoxsH+pLXQNdEb/AnRO6jLskV2l0Zifgz5aLe03XSAOiXSJV3c0usgrtyDzINR7TxiSXSKXKVd1mlLu0oCwFuMr4zoSXNuVz1B9cg4BcE3Oli3pMnWWw+vT57NU3NXmnb5TYFc76Wp1xDp2mIuKMvnywnsz8hnLkW7cfh0kNC1iT0Q0bVGX6Ys1/B4ImeRGfZ7hCAgLRuSvu7WjE+MlPT1lmrirhNKYE1AVikvbWqXiJqbWiFnH0a4x4eSUbMHR8d6EkefVyviC6+rGrIqcQjdTIVTdzw5HSm58af01ZnQ4QQpIqQeqAVheaEcn1F+Cmh2xPsl1T3MVh6TEanGIMat1ce8ax2TFRR5AKz3JSQSlTHhyDMpT/5oEAdZLBSUqbbEmiQw1fDfZXJvxEwzHlQ0STW5tPhNWf2QOlac4NVp6SUMkU1r42tbQ82vdiunCEHrZTNWMUN+2LCizEfpzMspQqRdTSD3DpjCXuD5fZ+m40G3gUOPoWBYkjIQNlfVQsMjn5jPDPLqY4oso61K/Ga2k1hThSg+64xUVmdIaC+2boGU1exkra60j9Z3KltUOwRpHanVEmXSdKZlE/zNRMjuNtqOkcfTLUDIrgYsIprLYjJIqGSVOJ01vkDDJGfoMZMnKjs2JYhz5MiRJXvKL45OWb3Zza6d3tUs+e36KV07rfnpytl8m1Y7SpIttoYueqKeP0clS4kEU86M3+cqGjOJ6Vx2uCaczkCoRkuzjw6Pjyl3U67kXcqT0WPfLob0LYhGnXyOgsbo1o7p6bxXANlV1a3cx9Tlrb1YjfLdbDOy/YowTa/THwwrmwBqHyIIT69D6+zmudPgTCV3MSD/5ZPFzEXC7a5spVTtf2bRjbHUP8gbZVb522IpZCcROrCrdXOzIpxdjQuMh+TZYUFTdX4n7d1DVc/llz1J3o3SyvZa/lWhprgFfUil/g+r4htv3gkTKVc1tdfldr2D2rHZ/O+p2XdXqpl/Hu7ZewU6K+oHtTQVufJI9jSqlUeA2T5Q/NU3ULGA2KeDNk+RPmiZolo33IY9XDC69/XYUwxu13ia5/1XJ4Bsab85CBsnzRaTu+ksxxnDhd5iYRiSdryD0rzI5uKXozfuM+ExkiaRiUdalUs1cgyIehvZpiIUXcRU+dkHK+EcJXwiLsMuFPwVvxMeRCiKFSwZ/yko/ctDJaN38sZ5ftrk/jt+v5HMsAc2kuAQY87OIMi+3+7KhEjNA6CyX1pp6L5WuOefLHOlG8I5Aqfvy5HwP+OaHYHLMJ0TXjJvbhqF7BXPiLjNtwwzSvhFlt/fPKZmHxJcpxmo8fkUOe/7iw/9H+xqejiwAAA== - - - dbo - - \ No newline at end of file diff --git a/Shared.DatabaseContext/Migrations/Configuration.cs b/Shared.DatabaseContext/Migrations/Configuration.cs deleted file mode 100644 index 001f361..0000000 --- a/Shared.DatabaseContext/Migrations/Configuration.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Shared.DatabaseContext.Migrations -{ - using System; - using System.Data.Entity; - using System.Data.Entity.Migrations; - using System.Linq; - - internal sealed class Configuration : DbMigrationsConfiguration - { - public Configuration() - { - AutomaticMigrationsEnabled = false; - } - - protected override void Seed(Shared.DatabaseContext.TodoContext context) - { - // This method will be called after migrating to the latest version. - - // You can use the DbSet.AddOrUpdate() helper extension method - // to avoid creating duplicate seed data. - } - } -} diff --git a/Shared.DatabaseContext/Properties/AssemblyInfo.cs b/Shared.DatabaseContext/Properties/AssemblyInfo.cs deleted file mode 100644 index f501ccb..0000000 --- a/Shared.DatabaseContext/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Shared.DatabaseContext")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Shared.DatabaseContext")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("6886bd35-1655-456b-a4c2-6b57bd557254")] - -// 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")] diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index 6ef3f8c..f08b304 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -1,91 +1,18 @@ - - - + + - Debug - AnyCPU - {6886BD35-1655-456B-A4C2-6B57BD557254} - Library - Properties - Shared.DatabaseContext - Shared.DatabaseContext - v4.6.1 - 512 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll - - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - - - - - - - - - - - - - - - - - 201803052220061_Init.cs - - - - 201803061729594_AddActiveFlags.cs - - - - - - - - - - - - - + - - 201803052220061_Init.cs - - - 201803061729594_AddActiveFlags.cs - + + + + + - - {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} - Shared.DataContracts - + - + \ No newline at end of file diff --git a/Shared.DatabaseContext/TodoContext.cs b/Shared.DatabaseContext/TodoContext.cs index 5aa5da8..f2bf5b3 100644 --- a/Shared.DatabaseContext/TodoContext.cs +++ b/Shared.DatabaseContext/TodoContext.cs @@ -1,8 +1,7 @@ -using Shared.DatabaseContext.DBOs; +using Microsoft.EntityFrameworkCore; +using Shared.DatabaseContext.DBOs; using System; using System.Collections.Generic; -using System.Data.Entity; -using System.Data.Entity.Validation; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -15,31 +14,40 @@ public class TodoContext : DbContext public DbSet TodoItems { get; set; } public DbSet TodoLists { get; set; } - public TodoContext() : base("TodoDb") + public TodoContext() : base() { } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + //optionsBuilder.UseSqlServer(System.Configuration.ConfigurationManager.ConnectionStrings["TodoContext"].ConnectionString); + optionsBuilder.UseInMemoryDatabase(); + base.OnConfiguring(optionsBuilder); + } + public override int SaveChanges() { - // collapse the entity validation errors into the exception message for convenience of debugging - try - { - return base.SaveChanges(); - } - catch (DbEntityValidationException ex) - { - var entityErrorList = ex.EntityValidationErrors - .SelectMany(x => x.ValidationErrors) - .Select(x => x.ErrorMessage); + return base.SaveChanges(); + ////https://github.com/aspnet/EntityFrameworkCore/issues/4434 + // // collapse the entity validation errors into the exception message for convenience of debugging + // try + // { + // return base.SaveChanges(); + // } + // catch (DbEntityValidationException ex) + // { + // var entityErrorList = ex.EntityValidationErrors + // .SelectMany(x => x.ValidationErrors) + // .Select(x => x.ErrorMessage); - var entityErrorMessage = string.Join("; ", entityErrorList); + // var entityErrorMessage = string.Join("; ", entityErrorList); - // combine entity errors with original exception - var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", entityErrorMessage); + // // combine entity errors with original exception + // var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", entityErrorMessage); - // re-throw the error with the new exception message - throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); - } + // // re-throw the error with the new exception message + // throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); + // } } } } diff --git a/Tests.AccessorTests/App.config b/Tests.AccessorTests/App.config index 7c4b11d..096c55f 100644 --- a/Tests.AccessorTests/App.config +++ b/Tests.AccessorTests/App.config @@ -1,7 +1,7 @@  - +
@@ -18,4 +18,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index 6293706..9df1dcf 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -40,14 +40,60 @@ 4 + + ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.InMemory.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.InMemory.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll + + + ..\packages\Microsoft.EntityFrameworkCore.SqlServer.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll @@ -58,10 +104,47 @@ ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + + ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + + ..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll + + + ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + + ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config index cf33de9..5a8d449 100644 --- a/Tests.AccessorTests/packages.config +++ b/Tests.AccessorTests/packages.config @@ -1,10 +1,38 @@  + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.DataPrep/App.config b/Tests.DataPrep/App.config index 7e1d79c..18f60bd 100644 --- a/Tests.DataPrep/App.config +++ b/Tests.DataPrep/App.config @@ -1,7 +1,7 @@  - +
@@ -14,4 +14,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index aeddbf3..194564a 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -36,15 +36,85 @@ ..\packages\Bogus.22.0.5\lib\net40\Bogus.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll + + + ..\packages\Microsoft.EntityFrameworkCore.SqlServer.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll + + + ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + diff --git a/Tests.DataPrep/packages.config b/Tests.DataPrep/packages.config index e2d5f5b..cdb290e 100644 --- a/Tests.DataPrep/packages.config +++ b/Tests.DataPrep/packages.config @@ -2,5 +2,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.ManagerTests/App.config b/Tests.ManagerTests/App.config index 7e1d79c..18f60bd 100644 --- a/Tests.ManagerTests/App.config +++ b/Tests.ManagerTests/App.config @@ -1,7 +1,7 @@  - +
@@ -14,4 +14,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 9acc6d1..41bc88f 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -40,14 +40,54 @@ 4 + + ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.InMemory.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.InMemory.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll @@ -61,10 +101,42 @@ ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + + ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll + + + ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index cc2dcb7..db27335 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -1,11 +1,36 @@  + - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests.TestBases/AccessorTestBase.cs b/Tests.TestBases/AccessorTestBase.cs index 402426c..ce5dd3c 100644 --- a/Tests.TestBases/AccessorTestBase.cs +++ b/Tests.TestBases/AccessorTestBase.cs @@ -14,7 +14,7 @@ public abstract class AccessorTestBase public virtual void TestInitialize() { TodoContext database = new TodoContext(); - database.Database.CreateIfNotExists(); + database.Database.EnsureCreated(); // transactionScope causes db changes to be rolled back at end of test _transactionScope = new TransactionScope(); diff --git a/Tests.TestBases/App.config b/Tests.TestBases/App.config index 7e1d79c..18f60bd 100644 --- a/Tests.TestBases/App.config +++ b/Tests.TestBases/App.config @@ -1,7 +1,7 @@  - +
@@ -14,4 +14,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Tests.TestBases/ManagerTestBase.cs b/Tests.TestBases/ManagerTestBase.cs index 7477191..255a853 100644 --- a/Tests.TestBases/ManagerTestBase.cs +++ b/Tests.TestBases/ManagerTestBase.cs @@ -15,7 +15,7 @@ public abstract class ManagerTestBase public virtual void TestInitialize() { TodoContext database = new TodoContext(); - database.Database.CreateIfNotExists(); + database.Database.EnsureCreated(); // transactionScope causes db changes to be rolled back at end of test _transactionScope = new TransactionScope(); diff --git a/Tests.TestBases/Tests.TestBases.csproj b/Tests.TestBases/Tests.TestBases.csproj index 394dba3..55b1ad5 100644 --- a/Tests.TestBases/Tests.TestBases.csproj +++ b/Tests.TestBases/Tests.TestBases.csproj @@ -33,18 +33,88 @@ 4 - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll + + + ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll + + + ..\packages\Microsoft.EntityFrameworkCore.SqlServer.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + + ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll + + + ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + diff --git a/Tests.TestBases/packages.config b/Tests.TestBases/packages.config index 6349b44..5649d0a 100644 --- a/Tests.TestBases/packages.config +++ b/Tests.TestBases/packages.config @@ -1,5 +1,30 @@  - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4703cc34e72a4ef60b0d43502c47ea4b31b901fd Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 10:44:29 -0600 Subject: [PATCH 47/74] add dependencies needed for ef migrations --- Shared.DatabaseContext/Shared.DatabaseContext.csproj | 4 ++++ Shared.DatabaseContext/packages.config | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 Shared.DatabaseContext/packages.config diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index f08b304..dc76f80 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -9,6 +9,10 @@ + + all + runtime; build; native; contentfiles; analyzers + diff --git a/Shared.DatabaseContext/packages.config b/Shared.DatabaseContext/packages.config deleted file mode 100644 index 01429a7..0000000 --- a/Shared.DatabaseContext/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file From db1a4dd7253eed2354145b3b09b4b4132edd738b Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 14:50:35 -0600 Subject: [PATCH 48/74] update accessor project to net standard --- .../Accessors.DatabaseAccessors.csproj | 145 ++---------------- .../Properties/AssemblyInfo.cs | 36 ----- Accessors.DatabaseAccessors/packages.config | 29 ---- 3 files changed, 10 insertions(+), 200 deletions(-) delete mode 100644 Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs delete mode 100644 Accessors.DatabaseAccessors/packages.config diff --git a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj index 69cd69c..552d855 100644 --- a/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj +++ b/Accessors.DatabaseAccessors/Accessors.DatabaseAccessors.csproj @@ -1,142 +1,17 @@ - - - + + - Debug - AnyCPU - {AF26B020-F939-4353-A41D-F6C0F87D0B81} - Library - Properties - Accessors.DatabaseAccessors - Accessors.DatabaseAccessors - v4.6.1 - 512 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll - - - ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - - - - - - + - - + + + - - {6886BD35-1655-456B-A4C2-6B57BD557254} - Shared.DatabaseContext - - - {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} - Shared.DataContracts - + + - + \ No newline at end of file diff --git a/Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs b/Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs deleted file mode 100644 index 72f0383..0000000 --- a/Accessors.DatabaseAccessors/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Accessors.DatabaseAccessors")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Accessors.DatabaseAccessors")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("af26b020-f939-4353-a41d-f6c0f87d0b81")] - -// 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")] diff --git a/Accessors.DatabaseAccessors/packages.config b/Accessors.DatabaseAccessors/packages.config deleted file mode 100644 index 5bd046e..0000000 --- a/Accessors.DatabaseAccessors/packages.config +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 4ea7024ab7b6cbb5ef535396762a865bb92db122 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 14:56:18 -0600 Subject: [PATCH 49/74] Update manager project to net standard --- .../App.config | 25 ------- ...anagers.LazyCollectionOfAllManagers.csproj | 71 +++---------------- .../Properties/AssemblyInfo.cs | 36 ---------- .../packages.config | 4 -- 4 files changed, 10 insertions(+), 126 deletions(-) delete mode 100644 Managers.LazyCollectionOfAllManagers/App.config delete mode 100644 Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs delete mode 100644 Managers.LazyCollectionOfAllManagers/packages.config diff --git a/Managers.LazyCollectionOfAllManagers/App.config b/Managers.LazyCollectionOfAllManagers/App.config deleted file mode 100644 index 18f60bd..0000000 --- a/Managers.LazyCollectionOfAllManagers/App.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj index d7661dc..d6e1456 100644 --- a/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj +++ b/Managers.LazyCollectionOfAllManagers/Managers.LazyCollectionOfAllManagers.csproj @@ -1,68 +1,17 @@ - - - + + - Debug - AnyCPU - {20052ECB-4E1D-4F2F-9F06-79111FE381F8} - Library - Properties - Managers.LazyCollectionOfAllManagers - Managers.LazyCollectionOfAllManagers - v4.6.1 - 512 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - - - - - - - - - - - - - - - - - + - - + + + - - {AF26B020-F939-4353-A41D-F6C0F87D0B81} - Accessors.DatabaseAccessors - - - {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} - Shared.DataContracts - + + - + \ No newline at end of file diff --git a/Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs b/Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs deleted file mode 100644 index f726028..0000000 --- a/Managers.LazyCollectionOfAllManagers/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Managers.LazyCollectionOfAllManagers")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Managers.LazyCollectionOfAllManagers")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("20052ecb-4e1d-4f2f-9f06-79111fe381f8")] - -// 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")] diff --git a/Managers.LazyCollectionOfAllManagers/packages.config b/Managers.LazyCollectionOfAllManagers/packages.config deleted file mode 100644 index 8e2c684..0000000 --- a/Managers.LazyCollectionOfAllManagers/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From e33877435b145b4f4e3fc4cf08150bdd3e0bc9fa Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 14:57:33 -0600 Subject: [PATCH 50/74] remove unnecessary app config --- Shared.DatabaseContext/App.config | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Shared.DatabaseContext/App.config diff --git a/Shared.DatabaseContext/App.config b/Shared.DatabaseContext/App.config deleted file mode 100644 index 7e1d79c..0000000 --- a/Shared.DatabaseContext/App.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - -
- - - - - - - - - - - - \ No newline at end of file From bafdf74022cc7151afd7b0b4a65b02650f81c3f2 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 15:53:22 -0600 Subject: [PATCH 51/74] Update the nunit extension to net standard --- .../Properties/AssemblyInfo.cs | 36 ----------- .../Test.NUnitExtensions.csproj | 63 ++----------------- Test.NUnitExtensions/packages.config | 4 -- 3 files changed, 5 insertions(+), 98 deletions(-) delete mode 100644 Test.NUnitExtensions/Properties/AssemblyInfo.cs delete mode 100644 Test.NUnitExtensions/packages.config diff --git a/Test.NUnitExtensions/Properties/AssemblyInfo.cs b/Test.NUnitExtensions/Properties/AssemblyInfo.cs deleted file mode 100644 index 448a990..0000000 --- a/Test.NUnitExtensions/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Test.NUnitExtensions")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Test.NUnitExtensions")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("3ac5c65a-6f68-479c-a078-3d2e573111bb")] - -// 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")] diff --git a/Test.NUnitExtensions/Test.NUnitExtensions.csproj b/Test.NUnitExtensions/Test.NUnitExtensions.csproj index a56d527..5e283ca 100644 --- a/Test.NUnitExtensions/Test.NUnitExtensions.csproj +++ b/Test.NUnitExtensions/Test.NUnitExtensions.csproj @@ -1,63 +1,10 @@ - - - - + + - Debug - AnyCPU - {3AC5C65A-6F68-479C-A078-3D2E573111BB} - Library - Properties - Test.NUnitExtensions - Test.NUnitExtensions - v4.6.1 - 512 - - + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll - - - - - - - - - - - - - - + - - + - - - - 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}. - - - \ No newline at end of file diff --git a/Test.NUnitExtensions/packages.config b/Test.NUnitExtensions/packages.config deleted file mode 100644 index b552965..0000000 --- a/Test.NUnitExtensions/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 913d2715091ac51f906094b785aaf6320d4c1710 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 16:03:32 -0600 Subject: [PATCH 52/74] update dataprep to net standard --- .../Tests.AccessorTests.csproj | 3 + Tests.AccessorTests/packages.config | 1 + Tests.DataPrep/App.config | 25 --- Tests.DataPrep/Properties/AssemblyInfo.cs | 36 ----- Tests.DataPrep/Tests.DataPrep.csproj | 152 ++---------------- Tests.DataPrep/packages.config | 31 ---- Tests.ManagerTests/Tests.ManagerTests.csproj | 3 + Tests.ManagerTests/packages.config | 1 + 8 files changed, 17 insertions(+), 235 deletions(-) delete mode 100644 Tests.DataPrep/App.config delete mode 100644 Tests.DataPrep/Properties/AssemblyInfo.cs delete mode 100644 Tests.DataPrep/packages.config diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index 9df1dcf..edaf2b3 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -43,6 +43,9 @@ ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + + ..\packages\Bogus.25.0.2\lib\net40\Bogus.dll + ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config index 5a8d449..5b4f003 100644 --- a/Tests.AccessorTests/packages.config +++ b/Tests.AccessorTests/packages.config @@ -1,6 +1,7 @@  + diff --git a/Tests.DataPrep/App.config b/Tests.DataPrep/App.config deleted file mode 100644 index 18f60bd..0000000 --- a/Tests.DataPrep/App.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests.DataPrep/Properties/AssemblyInfo.cs b/Tests.DataPrep/Properties/AssemblyInfo.cs deleted file mode 100644 index 20cb72c..0000000 --- a/Tests.DataPrep/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Tests.DataPrep")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Tests.DataPrep")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("458ed4a8-e0f2-4089-94cb-20b0efdd4b46")] - -// 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")] diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index 194564a..5501f0d 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -1,150 +1,16 @@ - - - + + - Debug - AnyCPU - {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} - Library - Properties - Tests.DataPrep - Tests.DataPrep - v4.6.1 - 512 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll - - - ..\packages\Bogus.22.0.5\lib\net40\Bogus.dll - - - ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll - - - ..\packages\Microsoft.EntityFrameworkCore.SqlServer.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - ..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - - - - - - - + - - - + + + - - {6886BD35-1655-456B-A4C2-6B57BD557254} - Shared.DatabaseContext - - - {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} - Shared.DataContracts - + - + \ No newline at end of file diff --git a/Tests.DataPrep/packages.config b/Tests.DataPrep/packages.config deleted file mode 100644 index cdb290e..0000000 --- a/Tests.DataPrep/packages.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 41bc88f..f66e71a 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -43,6 +43,9 @@ ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll + + ..\packages\Bogus.25.0.2\lib\net40\Bogus.dll + ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config index db27335..813634a 100644 --- a/Tests.ManagerTests/packages.config +++ b/Tests.ManagerTests/packages.config @@ -1,6 +1,7 @@  + From a68dc43f550d96c2a9dd7d7212cd5b636f27e06b Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 16:07:59 -0600 Subject: [PATCH 53/74] update test bases to net standard --- Tests.TestBases/App.config | 25 ---- Tests.TestBases/Properties/AssemblyInfo.cs | 36 ----- Tests.TestBases/Tests.TestBases.csproj | 153 +-------------------- Tests.TestBases/packages.config | 30 ---- 4 files changed, 7 insertions(+), 237 deletions(-) delete mode 100644 Tests.TestBases/App.config delete mode 100644 Tests.TestBases/Properties/AssemblyInfo.cs delete mode 100644 Tests.TestBases/packages.config diff --git a/Tests.TestBases/App.config b/Tests.TestBases/App.config deleted file mode 100644 index 18f60bd..0000000 --- a/Tests.TestBases/App.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests.TestBases/Properties/AssemblyInfo.cs b/Tests.TestBases/Properties/AssemblyInfo.cs deleted file mode 100644 index 0f8c4c1..0000000 --- a/Tests.TestBases/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("Tests.TestBases")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Tests.TestBases")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[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("ebd233e2-509f-4a6a-b43e-034986583ae2")] - -// 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")] diff --git a/Tests.TestBases/Tests.TestBases.csproj b/Tests.TestBases/Tests.TestBases.csproj index 55b1ad5..10f6881 100644 --- a/Tests.TestBases/Tests.TestBases.csproj +++ b/Tests.TestBases/Tests.TestBases.csproj @@ -1,153 +1,14 @@ - - - - + + - Debug - AnyCPU - {EBD233E2-509F-4A6A-B43E-034986583AE2} - Library - Properties - Tests.TestBases - Tests.TestBases - v4.6.1 - 512 - - + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll - - - ..\packages\Microsoft.EntityFrameworkCore.SqlServer.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - ..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - - - - - + - - + + - - {6886BD35-1655-456B-A4C2-6B57BD557254} - Shared.DatabaseContext - - - {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} - Tests.DataPrep - + - - - - 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}. - - - \ No newline at end of file diff --git a/Tests.TestBases/packages.config b/Tests.TestBases/packages.config deleted file mode 100644 index 5649d0a..0000000 --- a/Tests.TestBases/packages.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From e3ba72c447c562a13052e44448917a02a2662b3e Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 17:22:32 -0600 Subject: [PATCH 54/74] Update accessor tests to net core --- .../Properties/AssemblyInfo.cs | 20 -- .../Tests.AccessorTests.csproj | 215 ++---------------- Tests.AccessorTests/packages.config | 39 ---- 3 files changed, 19 insertions(+), 255 deletions(-) delete mode 100644 Tests.AccessorTests/Properties/AssemblyInfo.cs delete mode 100644 Tests.AccessorTests/packages.config diff --git a/Tests.AccessorTests/Properties/AssemblyInfo.cs b/Tests.AccessorTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 1d7654d..0000000 --- a/Tests.AccessorTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tests.AccessorTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Tests.AccessorTests")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("802f9c0a-9fc5-444b-bd3b-aed8b6f148a8")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index edaf2b3..61af152 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -1,202 +1,25 @@ - - - - - + + - Debug - AnyCPU - {802F9C0A-9FC5-444B-BD3B-AED8B6F148A8} - Library - Properties - Tests.AccessorTests - Tests.AccessorTests - v4.6.1 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - + netcoreapp2.1 + + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll - - - ..\packages\Bogus.25.0.2\lib\net40\Bogus.dll - - - ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll - - - - ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.EntityFrameworkCore.InMemory.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.InMemory.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Relational.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll - - - ..\packages\Microsoft.EntityFrameworkCore.SqlServer.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - - ..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - - - ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll - - - - ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll - - - - - - - + - - + + + + + + + + - - {AF26B020-F939-4353-A41D-F6C0F87D0B81} - Accessors.DatabaseAccessors - - - {6886BD35-1655-456B-A4C2-6B57BD557254} - Shared.DatabaseContext - - - {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} - Shared.DataContracts - - - {3AC5C65A-6F68-479C-A078-3D2E573111BB} - Test.NUnitExtensions - - - {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} - Tests.DataPrep - - - {ebd233e2-509f-4a6a-b43e-034986583ae2} - Tests.TestBases - + + + - - - - - 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}. - - - - - - - - \ No newline at end of file + + diff --git a/Tests.AccessorTests/packages.config b/Tests.AccessorTests/packages.config deleted file mode 100644 index 5b4f003..0000000 --- a/Tests.AccessorTests/packages.config +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From c283637e3cd798f15a199014cbb03c0989ac841b Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Thu, 27 Dec 2018 17:23:15 -0600 Subject: [PATCH 55/74] update manager tests to new project file format, but still use .net 47 because justmock is not .net core compatible --- Tests.ManagerTests/Properties/AssemblyInfo.cs | 20 -- Tests.ManagerTests/Tests.ManagerTests.csproj | 219 ++---------------- Tests.ManagerTests/TodoCRUDManagerTests.cs | 2 - Tests.ManagerTests/packages.config | 37 --- 4 files changed, 20 insertions(+), 258 deletions(-) delete mode 100644 Tests.ManagerTests/Properties/AssemblyInfo.cs delete mode 100644 Tests.ManagerTests/packages.config diff --git a/Tests.ManagerTests/Properties/AssemblyInfo.cs b/Tests.ManagerTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 9453ec3..0000000 --- a/Tests.ManagerTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tests.ManagerTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HP Inc.")] -[assembly: AssemblyProduct("Tests.ManagerTests")] -[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("7d0ba0fb-fa51-4964-9e41-7d03bff47a94")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index f66e71a..f9575fd 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -1,205 +1,26 @@ - - - - - + + - Debug - AnyCPU - {7D0BA0FB-FA51-4964-9E41-7D03BFF47A94} - Library - Properties - Tests.ManagerTests - Tests.ManagerTests - v4.6.1 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - + net47 + + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll - - - ..\packages\Bogus.25.0.2\lib\net40\Bogus.dll - - - ..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll - - - - ..\packages\Microsoft.EntityFrameworkCore.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll - - - ..\packages\Microsoft.EntityFrameworkCore.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll - - - ..\packages\Microsoft.EntityFrameworkCore.InMemory.2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.InMemory.dll - - - ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll - - - ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll - - - ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll - - - ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll - - - ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll - - - ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll - - - ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - - - ..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - - - ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll - - - ..\packages\JustMock.2018.1.117.2\lib\Net\Telerik.JustMock.dll - - - - - - - - + - - - - + + + + + + + + - - {AF26B020-F939-4353-A41D-F6C0F87D0B81} - Accessors.DatabaseAccessors - - - {20052ECB-4E1D-4F2F-9F06-79111FE381F8} - Managers.LazyCollectionOfAllManagers - - - {6886bd35-1655-456b-a4c2-6b57bd557254} - Shared.DatabaseContext - - - {0c5f8e80-076a-4c48-900d-d5e6b0c1f34e} - Shared.DataContracts - - - {a697facf-33eb-47cf-91cd-11cb6a870cb6} - Shared.DependencyInjectionKernel - - - {3AC5C65A-6F68-479C-A078-3D2E573111BB} - Test.NUnitExtensions - - - {458ED4A8-E0F2-4089-94CB-20B0EFDD4B46} - Tests.DataPrep - - - {ebd233e2-509f-4a6a-b43e-034986583ae2} - Tests.TestBases - + + + + - - - - - 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}. - - - - - - - - \ No newline at end of file + + diff --git a/Tests.ManagerTests/TodoCRUDManagerTests.cs b/Tests.ManagerTests/TodoCRUDManagerTests.cs index 4ab5e29..e6c8c87 100644 --- a/Tests.ManagerTests/TodoCRUDManagerTests.cs +++ b/Tests.ManagerTests/TodoCRUDManagerTests.cs @@ -6,8 +6,6 @@ using Managers.LazyCollectionOfAllManagers; using Ninject; using NUnit.Framework; -using Shared.DatabaseContext; -using Shared.DatabaseContext.DBOs; using Shared.DataContracts; using Shared.DependencyInjectionKernel; using Telerik.JustMock; diff --git a/Tests.ManagerTests/packages.config b/Tests.ManagerTests/packages.config deleted file mode 100644 index 813634a..0000000 --- a/Tests.ManagerTests/packages.config +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 0edaaaf83c276b365127870150143277592f6ba2 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 25 Mar 2019 09:29:02 -0500 Subject: [PATCH 56/74] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93f7971..8464bbe 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This project is to record and share patterns and libraries that make testing As a result, it also demonstrates many other patterns and libraries that enable good development practices. -Here is the presentation the triggered the project: https://1drv.ms/p/s!AjVvNQ4uturOdRxhCnyW16c_yk4 +Here is the presentation the triggered the project: https://20xtesting.slides.spencerfarley.com Here is a presentation that describes the design philosphies: https://1drv.ms/b/s!AjVvNQ4uturOby6OwKMFpMUlMqA From 82d28c95f14ea7705b79eb29680c11e876c49494 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 25 Mar 2019 09:44:53 -0500 Subject: [PATCH 57/74] update justmock to version that supports .netcore --- Shared.DatabaseContext/TodoContext.cs | 2 +- Tests.AccessorTests/Tests.AccessorTests.csproj | 2 +- Tests.ManagerTests/Tests.ManagerTests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Shared.DatabaseContext/TodoContext.cs b/Shared.DatabaseContext/TodoContext.cs index f2bf5b3..90e603f 100644 --- a/Shared.DatabaseContext/TodoContext.cs +++ b/Shared.DatabaseContext/TodoContext.cs @@ -21,7 +21,7 @@ public TodoContext() : base() protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { //optionsBuilder.UseSqlServer(System.Configuration.ConfigurationManager.ConnectionStrings["TodoContext"].ConnectionString); - optionsBuilder.UseInMemoryDatabase(); + optionsBuilder.UseInMemoryDatabase(nameof(TodoContext)); base.OnConfiguring(optionsBuilder); } diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index 61af152..c44dde4 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -8,7 +8,7 @@ - + diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index f9575fd..11ea7db 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -8,7 +8,7 @@ - + From e5de0e1b6c59d1d6b019349528b53125aff6e6b6 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 25 Mar 2019 09:51:53 -0500 Subject: [PATCH 58/74] Update manager test project to run on netcore --- Tests.ManagerTests/Tests.ManagerTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 11ea7db..317a619 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -1,7 +1,7 @@  - net47 + netcoreapp2.1 false From eb8d639765ed08df3890bcb0c82ce0653aaeafcf Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 25 Mar 2019 09:53:28 -0500 Subject: [PATCH 59/74] update all nuget packages --- Shared.DatabaseContext/Shared.DatabaseContext.csproj | 10 +++++----- Tests.AccessorTests/Tests.AccessorTests.csproj | 8 ++++---- Tests.DataPrep/Tests.DataPrep.csproj | 4 ++-- Tests.ManagerTests/Tests.ManagerTests.csproj | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Shared.DatabaseContext/Shared.DatabaseContext.csproj b/Shared.DatabaseContext/Shared.DatabaseContext.csproj index dc76f80..868a4ad 100644 --- a/Shared.DatabaseContext/Shared.DatabaseContext.csproj +++ b/Shared.DatabaseContext/Shared.DatabaseContext.csproj @@ -5,11 +5,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers diff --git a/Tests.AccessorTests/Tests.AccessorTests.csproj b/Tests.AccessorTests/Tests.AccessorTests.csproj index c44dde4..e0c629f 100644 --- a/Tests.AccessorTests/Tests.AccessorTests.csproj +++ b/Tests.AccessorTests/Tests.AccessorTests.csproj @@ -9,11 +9,11 @@ - - - + + + - + diff --git a/Tests.DataPrep/Tests.DataPrep.csproj b/Tests.DataPrep/Tests.DataPrep.csproj index 5501f0d..138d1a9 100644 --- a/Tests.DataPrep/Tests.DataPrep.csproj +++ b/Tests.DataPrep/Tests.DataPrep.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/Tests.ManagerTests/Tests.ManagerTests.csproj b/Tests.ManagerTests/Tests.ManagerTests.csproj index 317a619..8804f56 100644 --- a/Tests.ManagerTests/Tests.ManagerTests.csproj +++ b/Tests.ManagerTests/Tests.ManagerTests.csproj @@ -9,11 +9,11 @@ - - - + + + - + From 78079148b5260d417cbe9a9007f2f2472eb3b0d3 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Wed, 27 Mar 2019 19:24:35 -0500 Subject: [PATCH 60/74] Add EnsureDatastore to the test data persistance to completely hide storage type from unit tests --- Tests.DataPrep/DataPrep.cs | 5 +++++ Tests.DataPrep/TestDataPersistance.cs | 12 ++++++++++++ Tests.TestBases/AccessorTestBase.cs | 3 +-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Tests.DataPrep/DataPrep.cs b/Tests.DataPrep/DataPrep.cs index f2edaca..c1551ee 100644 --- a/Tests.DataPrep/DataPrep.cs +++ b/Tests.DataPrep/DataPrep.cs @@ -31,5 +31,10 @@ public TodoDataPrep(bool shouldPersistData) TodoLists = new TodoListPrep(dataPersistance, Users); TodoItems = new TodoItemPrep(dataPersistance, TodoLists); } + + public void EnsureDatastore() + { + dataPersistance.EnsureDatastore(); + } } } diff --git a/Tests.DataPrep/TestDataPersistance.cs b/Tests.DataPrep/TestDataPersistance.cs index 6b7c065..7a6d2bb 100644 --- a/Tests.DataPrep/TestDataPersistance.cs +++ b/Tests.DataPrep/TestDataPersistance.cs @@ -8,6 +8,8 @@ public interface ITestDataAccessor // should probably make this more constrained to just expected data model types, // but that would require refactoring all data models to implement an interface, which i'm not confident the agilx code can handle T Create(T entity) where T : class; + + void EnsureDatastore(); } @@ -29,6 +31,11 @@ public T Create(T entity) where T : class } + public void EnsureDatastore() + { + TodoContext database = new TodoContext(); + database.Database.EnsureCreated(); + } } class NoPersistanceTestDataAccessor : ITestDataAccessor @@ -39,6 +46,11 @@ public T Create(T entity) where T : class return entity; } + + public void EnsureDatastore() + { + // no action needed + } } } diff --git a/Tests.TestBases/AccessorTestBase.cs b/Tests.TestBases/AccessorTestBase.cs index ce5dd3c..4d737b1 100644 --- a/Tests.TestBases/AccessorTestBase.cs +++ b/Tests.TestBases/AccessorTestBase.cs @@ -13,8 +13,7 @@ public abstract class AccessorTestBase [SetUp] public virtual void TestInitialize() { - TodoContext database = new TodoContext(); - database.Database.EnsureCreated(); + dataPrep.EnsureDatastore(); // transactionScope causes db changes to be rolled back at end of test _transactionScope = new TransactionScope(); From 259bdec73409544a6c65e07c0487b12fe9d81cfb Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sun, 31 Mar 2019 21:29:21 -0500 Subject: [PATCH 61/74] Functional abstracted Id type. All tests pass, friendly with deepequal --- .../TodoItemAccessor.cs | 10 +-- .../TodoListAccessor.cs | 14 +-- .../ListExplorationManager.cs | 8 +- .../TodoCRUDManager.cs | 8 +- Shared.DataContracts/DataConstants.cs | 13 --- Shared.DataContracts/Id.cs | 86 +++++++++++++++++++ Shared.DataContracts/TodoItem.cs | 4 +- Shared.DataContracts/TodoList.cs | 4 +- Shared.DataContracts/User.cs | 2 +- Shared.DatabaseContext/DTOs/MapperBase.cs | 3 + Tests.AccessorTests/TodoItemAccessorTests.cs | 7 +- 11 files changed, 118 insertions(+), 41 deletions(-) delete mode 100644 Shared.DataContracts/DataConstants.cs create mode 100644 Shared.DataContracts/Id.cs diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index 3152852..56de7c8 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -12,17 +12,17 @@ namespace Accessors.DatabaseAccessors { public interface ITodoItemAccessor { - IEnumerable GetTodoItemsForList(Guid listId); + IEnumerable GetTodoItemsForList(Id listId); SaveResult SaveTodoItem(TodoItem todoItem); - DeleteResult DeleteTodoItem(Guid id); + DeleteResult DeleteTodoItem(Id id); } class TodoItemAccessor : ITodoItemAccessor { TodoItem_Mapper mapper = new TodoItem_Mapper(); - public DeleteResult DeleteTodoItem(Guid id) + public DeleteResult DeleteTodoItem(Id id) { using (TodoContext db = new TodoContext()) { @@ -37,7 +37,7 @@ public DeleteResult DeleteTodoItem(Guid id) } } - public IEnumerable GetTodoItemsForList(Guid listId) + public IEnumerable GetTodoItemsForList(Id listId) { IEnumerable todoItemList; using (TodoContext db = new TodoContext()) @@ -54,7 +54,7 @@ public SaveResult SaveTodoItem(TodoItem todoItem) { TodoItemDTO dbModel = mapper.ContractToModel(todoItem); - if(todoItem.Id == DataConstants.DefaultId) + if(todoItem.Id == Id.Default) { db.TodoItems.Add(dbModel); } diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs index cb47910..3ac0307 100644 --- a/Accessors.DatabaseAccessors/TodoListAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -12,20 +12,20 @@ namespace Accessors.DatabaseAccessors { public interface ITodoListAccessor { - TodoList GetTodoList(Guid id); + TodoList GetTodoList(Id id); - IEnumerable GetTodoListsForUser(Guid userId); + IEnumerable GetTodoListsForUser(Id userId); SaveResult SaveTodoList(TodoList todoList); - DeleteResult DeleteTodoList(Guid id); + DeleteResult DeleteTodoList(Id id); } class TodoListAccessor : ITodoListAccessor { TodoList_Mapper mapper = new TodoList_Mapper(); - public DeleteResult DeleteTodoList(Guid id) + public DeleteResult DeleteTodoList(Id id) { using (TodoContext db = new TodoContext()) { @@ -40,7 +40,7 @@ public DeleteResult DeleteTodoList(Guid id) } } - public TodoList GetTodoList(Guid id) + public TodoList GetTodoList(Id id) { using (TodoContext db = new TodoContext()) { @@ -52,7 +52,7 @@ public TodoList GetTodoList(Guid id) } } - public IEnumerable GetTodoListsForUser(Guid userId) + public IEnumerable GetTodoListsForUser(Id userId) { IEnumerable todoListContracts; using (TodoContext db = new TodoContext()) @@ -71,7 +71,7 @@ public SaveResult SaveTodoList(TodoList todoList) { TodoListDTO dbModel = mapper.ContractToModel(todoList); - if (todoList.Id == DataConstants.DefaultId) + if (todoList.Id == Id.Default) { db.TodoLists.Add(dbModel); } diff --git a/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs b/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs index 25c35d6..de9f2fa 100644 --- a/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs +++ b/Managers.LazyCollectionOfAllManagers/ListExplorationManager.cs @@ -9,9 +9,9 @@ namespace Managers.LazyCollectionOfAllManagers { public interface IListExplorationManager { - UserAccountStats GetUserStats(Guid userId); + UserAccountStats GetUserStats(Id userId); - IEnumerable GetUserLists(Guid userId); + IEnumerable GetUserLists(Id userId); } @@ -20,12 +20,12 @@ public interface IListExplorationManager internal class ListExplorationManager : IListExplorationManager { - public IEnumerable GetUserLists(Guid userId) + public IEnumerable GetUserLists(Id userId) { throw new NotImplementedException(); } - public UserAccountStats GetUserStats(Guid userId) + public UserAccountStats GetUserStats(Id userId) { throw new NotImplementedException(); } diff --git a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs index 56700d9..fa6d6dd 100644 --- a/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs +++ b/Managers.LazyCollectionOfAllManagers/TodoCRUDManager.cs @@ -10,9 +10,9 @@ namespace Managers.LazyCollectionOfAllManagers { public interface ITodoCRUDManager { - TodoList GetTodoList(Guid id); + TodoList GetTodoList(Id id); - IEnumerable GetTodoItems(Guid listId); + IEnumerable GetTodoItems(Id listId); SaveResult SaveTodoItem(TodoItem todoItem); @@ -34,12 +34,12 @@ public TodoCRUDManager(ITodoListAccessor todoListAccessor, ITodoItemAccessor tod // for this 'flow' in the application // - public IEnumerable GetTodoItems(Guid listId) + public IEnumerable GetTodoItems(Id listId) { return todoItemAccessor.GetTodoItemsForList(listId); } - public TodoList GetTodoList(Guid id) + public TodoList GetTodoList(Id id) { return todoListAccessor.GetTodoList(id); } diff --git a/Shared.DataContracts/DataConstants.cs b/Shared.DataContracts/DataConstants.cs deleted file mode 100644 index bb37079..0000000 --- a/Shared.DataContracts/DataConstants.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Shared.DataContracts -{ - public static class DataConstants - { - public static Guid DefaultId = Guid.Empty; - } -} diff --git a/Shared.DataContracts/Id.cs b/Shared.DataContracts/Id.cs new file mode 100644 index 0000000..01b1763 --- /dev/null +++ b/Shared.DataContracts/Id.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.DataContracts +{ + public struct Id : IComparable, IComparable, IEquatable, IFormattable + { + // this would also work genericly + // https://stackoverflow.com/questions/5377237/strongly-typing-id-values-in-c-sharp + private readonly Guid _guid; + private static readonly Guid _default = Guid.Empty; + + public Id(Guid? guid) + { + _guid = guid ?? Guid.Empty; + } + + public static readonly Id Default = new Id(Guid.Empty); + + public static Id New() + { + return new Id(Guid.NewGuid()); + } + + public static explicit operator Id(Guid guid) + { + return new Id(guid); + } + + public static implicit operator Guid(Id id) + { + return id._guid; + } + + public override bool Equals(object obj) + { + return obj is Id && this.Equals((Id)obj); + } + + public int CompareTo(object obj) + { + if(obj is Id) + { + return this.CompareTo((Id)obj); + } + else + { + throw new Exception("Types not comparable"); + } + } + + public int CompareTo(Id other) + { + return _guid.CompareTo(other); + } + + public bool Equals(Id other) + { + return _guid.Equals(other); + } + + public override string ToString() + { + return _guid.ToString(); + } + public string ToString(string format, IFormatProvider formatProvider) + { + return _guid.ToString(format, formatProvider); + } + + public override int GetHashCode() + { + return _guid.GetHashCode(); + } + public static bool operator ==(Id a, Id b) + { + return a.Equals(b); + } + + public static bool operator !=(Id a, Id b) + { + return !(a == b); + } + } +} diff --git a/Shared.DataContracts/TodoItem.cs b/Shared.DataContracts/TodoItem.cs index 2bcf134..2e21823 100644 --- a/Shared.DataContracts/TodoItem.cs +++ b/Shared.DataContracts/TodoItem.cs @@ -4,9 +4,9 @@ namespace Shared.DataContracts { public class TodoItem { - public Guid Id { get; set; } + public Id Id { get; set; } - public Guid TodoListId { get; set; } + public Id TodoListId { get; set; } public string Description { get; set; } diff --git a/Shared.DataContracts/TodoList.cs b/Shared.DataContracts/TodoList.cs index 89b9d93..09c65de 100644 --- a/Shared.DataContracts/TodoList.cs +++ b/Shared.DataContracts/TodoList.cs @@ -4,9 +4,9 @@ namespace Shared.DataContracts { public class TodoList { - public Guid Id { get; set; } + public Id Id { get; set; } - public Guid UserId { get; set; } + public Id UserId { get; set; } public string Title { get; set; } } diff --git a/Shared.DataContracts/User.cs b/Shared.DataContracts/User.cs index 1bb3810..0b202bf 100644 --- a/Shared.DataContracts/User.cs +++ b/Shared.DataContracts/User.cs @@ -8,7 +8,7 @@ namespace Shared.DataContracts { public class User { - public Guid Id { get; set; } + public Id Id { get; set; } public string Name { get; set; } diff --git a/Shared.DatabaseContext/DTOs/MapperBase.cs b/Shared.DatabaseContext/DTOs/MapperBase.cs index 63010d1..0c45cff 100644 --- a/Shared.DatabaseContext/DTOs/MapperBase.cs +++ b/Shared.DatabaseContext/DTOs/MapperBase.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; @@ -17,6 +18,8 @@ public MapperBase() { cfg.CreateMap(); cfg.CreateMap(); + cfg.CreateMap().ConvertUsing((guid) => (Id)guid); + cfg.CreateMap().ConvertUsing((id) => (Guid)id); }); map = config.CreateMapper(); diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs index 0486273..a353310 100644 --- a/Tests.AccessorTests/TodoItemAccessorTests.cs +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Accessors.DatabaseAccessors; +using DeepEqual; using DeepEqual.Syntax; using NUnit.Framework; using Shared.DatabaseContext; @@ -59,14 +60,14 @@ public void GetTodoItems_Ugly() db.SaveChanges(); // act - IEnumerable actualItemList = accessor.GetTodoItemsForList(expectedList.Id); + IEnumerable actualItemList = accessor.GetTodoItemsForList(new Id(expectedList.Id)); //assert Assert.AreEqual(expectedItemList.Count, actualItemList.Count()); foreach (TodoItem actualTodo in actualItemList) { TodoItemDTO expectedTodo = expectedItemList.FirstOrDefault(ti => ti.Id == actualTodo.Id); - Assert.AreEqual(expectedTodo.TodoListId, actualTodo.TodoListId); + Assert.AreEqual((Id)expectedTodo.TodoListId, actualTodo.TodoListId); Assert.AreEqual(expectedTodo.Description, actualTodo.Description); Assert.AreEqual(expectedTodo.IsComplete, actualTodo.IsComplete); } @@ -91,7 +92,7 @@ public void GetTodoItems_Final() IEnumerable actualItemList = accessor.GetTodoItemsForList(todoList.Id); //assert - expectedItemList.ShouldDeepEqual(actualItemList); + expectedItemList.WithDeepEqual(actualItemList); } [Test] From 5dea745e22c0f465ddaa6a194185e0de7b55f8a1 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sun, 31 Mar 2019 21:59:49 -0500 Subject: [PATCH 62/74] A few cleanups based on experiment with generics --- .../TodoItemAccessor.cs | 2 +- .../TodoListAccessor.cs | 2 +- Shared.DataContracts/Id.cs | 26 ++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Accessors.DatabaseAccessors/TodoItemAccessor.cs b/Accessors.DatabaseAccessors/TodoItemAccessor.cs index 56de7c8..caeff6e 100644 --- a/Accessors.DatabaseAccessors/TodoItemAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoItemAccessor.cs @@ -54,7 +54,7 @@ public SaveResult SaveTodoItem(TodoItem todoItem) { TodoItemDTO dbModel = mapper.ContractToModel(todoItem); - if(todoItem.Id == Id.Default) + if(todoItem.Id.IsDefault()) { db.TodoItems.Add(dbModel); } diff --git a/Accessors.DatabaseAccessors/TodoListAccessor.cs b/Accessors.DatabaseAccessors/TodoListAccessor.cs index 3ac0307..7d351aa 100644 --- a/Accessors.DatabaseAccessors/TodoListAccessor.cs +++ b/Accessors.DatabaseAccessors/TodoListAccessor.cs @@ -71,7 +71,7 @@ public SaveResult SaveTodoList(TodoList todoList) { TodoListDTO dbModel = mapper.ContractToModel(todoList); - if (todoList.Id == Id.Default) + if (todoList.Id.IsDefault()) { db.TodoLists.Add(dbModel); } diff --git a/Shared.DataContracts/Id.cs b/Shared.DataContracts/Id.cs index 01b1763..05f885b 100644 --- a/Shared.DataContracts/Id.cs +++ b/Shared.DataContracts/Id.cs @@ -4,24 +4,30 @@ namespace Shared.DataContracts { - public struct Id : IComparable, IComparable, IEquatable, IFormattable + public struct Id : IComparable, IComparable, IEquatable { - // this would also work genericly - // https://stackoverflow.com/questions/5377237/strongly-typing-id-values-in-c-sharp private readonly Guid _guid; - private static readonly Guid _default = Guid.Empty; + private static readonly Guid _default = default(Guid); public Id(Guid? guid) { - _guid = guid ?? Guid.Empty; + _guid = guid ?? _default; } - public static readonly Id Default = new Id(Guid.Empty); + public bool IsDefault() + { + return this._guid.Equals(_default); + } + + public static Id Default() + { + return new Id(_default); + } public static Id New() { return new Id(Guid.NewGuid()); - } + } public static explicit operator Id(Guid guid) { @@ -40,7 +46,7 @@ public override bool Equals(object obj) public int CompareTo(object obj) { - if(obj is Id) + if (obj is Id) { return this.CompareTo((Id)obj); } @@ -64,10 +70,6 @@ public override string ToString() { return _guid.ToString(); } - public string ToString(string format, IFormatProvider formatProvider) - { - return _guid.ToString(format, formatProvider); - } public override int GetHashCode() { From 18a38f6605a1f4c4eace1ac8b0ad47fbc20ebc67 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sun, 31 Mar 2019 22:07:06 -0500 Subject: [PATCH 63/74] fix assertion --- Tests.AccessorTests/TodoItemAccessorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs index a353310..8d30f9f 100644 --- a/Tests.AccessorTests/TodoItemAccessorTests.cs +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -92,7 +92,7 @@ public void GetTodoItems_Final() IEnumerable actualItemList = accessor.GetTodoItemsForList(todoList.Id); //assert - expectedItemList.WithDeepEqual(actualItemList); + expectedItemList.WithDeepEqual(actualItemList).Assert(); } [Test] From a96521d53274863a9f06bc7796f7f90c4f79d34c Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 6 Apr 2019 14:13:51 -0500 Subject: [PATCH 64/74] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..d6f40c5 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,17 @@ +# ASP.NET Core +# Build and test ASP.NET Core projects targeting .NET Core. +# Add steps that run tests, create a NuGet package, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core + +trigger: +- master + +pool: + vmImage: 'Ubuntu-16.04' + +variables: + buildConfiguration: 'Release' + +steps: +- script: dotnet build --configuration $(buildConfiguration) + displayName: 'dotnet build $(buildConfiguration)' From 7d5cdb9521e8deeab59bc22a44beb9a99a65d28f Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 6 Apr 2019 14:50:05 -0500 Subject: [PATCH 65/74] Update azure-pipelines.yml for Azure Pipelines [skip ci] --- azure-pipelines.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d6f40c5..88933df 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,5 +13,10 @@ variables: buildConfiguration: 'Release' steps: +- script: dotnet restore + displayName: Restore nuget - script: dotnet build --configuration $(buildConfiguration) displayName: 'dotnet build $(buildConfiguration)' +- script: dotnet tests + displayName: Unit Tests + From dd95f52193d3b2e0b9bd3c944bff0b6b8610ef42 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 6 Apr 2019 14:55:42 -0500 Subject: [PATCH 66/74] Update azure-pipelines.yml for Azure Pipelines [skip ci] --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 88933df..392d650 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,6 +17,6 @@ steps: displayName: Restore nuget - script: dotnet build --configuration $(buildConfiguration) displayName: 'dotnet build $(buildConfiguration)' -- script: dotnet tests +- script: dotnet test displayName: Unit Tests From 39ad025abab7bf34c47e8895bcecba3f98e3d4ae Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 6 Apr 2019 15:06:18 -0500 Subject: [PATCH 67/74] Update azure-pipelines.yml for Azure Pipelines [skip ci] --- azure-pipelines.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 392d650..6c039bd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,6 +17,10 @@ steps: displayName: Restore nuget - script: dotnet build --configuration $(buildConfiguration) displayName: 'dotnet build $(buildConfiguration)' -- script: dotnet test +- task: DotNetCoreCLI@2 + inputs: + command: test + projects: '**/Tests.*/*.csproj' + arguments: '--configuration $(buildConfiguration) --collect "Code coverage"' displayName: Unit Tests From e6a26ce5d9e8d636155955ef5b9ab298ac111488 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 6 Apr 2019 15:15:44 -0500 Subject: [PATCH 68/74] Update azure-pipelines.yml for Azure Pipelines [skip ci] change platform for code coverage --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6c039bd..dbb28f0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,7 +7,7 @@ trigger: - master pool: - vmImage: 'Ubuntu-16.04' + vmImage: 'vs2017-win2016' variables: buildConfiguration: 'Release' From b9f655eb1a968f9d4a448e287461ea6cbe156457 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 6 Apr 2019 15:28:58 -0500 Subject: [PATCH 69/74] Add build pipeline link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8464bbe..7edcc6f 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,5 @@ Testing Libraries - .NET Transactions TransactionScope - NUnit - alternatives: MSTest + +Example Build Pipeline: https://spencerfarley.visualstudio.com/TestingPatterns/ From 4846d903c0fae92ccff188b50d3e484adb77bc14 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Wed, 10 Apr 2019 17:41:47 -0500 Subject: [PATCH 70/74] abstract datastore creation from manager test base --- Tests.TestBases/ManagerTestBase.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests.TestBases/ManagerTestBase.cs b/Tests.TestBases/ManagerTestBase.cs index 255a853..92836f4 100644 --- a/Tests.TestBases/ManagerTestBase.cs +++ b/Tests.TestBases/ManagerTestBase.cs @@ -14,8 +14,7 @@ public abstract class ManagerTestBase [SetUp] public virtual void TestInitialize() { - TodoContext database = new TodoContext(); - database.Database.EnsureCreated(); + dataPrep.EnsureDatastore(); // transactionScope causes db changes to be rolled back at end of test _transactionScope = new TransactionScope(); From 1a27614467468699a6412689befe2bcc9aa000bb Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 20 Apr 2019 17:21:55 -0500 Subject: [PATCH 71/74] Centralize repetitive methods in a generic base class --- Tests.DataPrep/DataPrep.cs | 8 +------ Tests.DataPrep/TodoItemPrep.cs | 20 ++--------------- Tests.DataPrep/TodoListPrep.cs | 20 ++--------------- Tests.DataPrep/TypePrepBase.cs | 41 ++++++++++++++++++++++++++++++++++ Tests.DataPrep/UserPrep.cs | 33 ++------------------------- 5 files changed, 48 insertions(+), 74 deletions(-) create mode 100644 Tests.DataPrep/TypePrepBase.cs diff --git a/Tests.DataPrep/DataPrep.cs b/Tests.DataPrep/DataPrep.cs index c1551ee..2391f97 100644 --- a/Tests.DataPrep/DataPrep.cs +++ b/Tests.DataPrep/DataPrep.cs @@ -1,10 +1,4 @@ -using Bogus; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace Tests.DataPrep { public class TodoDataPrep diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index 74e9359..7eb6a32 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -8,16 +8,12 @@ namespace Tests.DataPrep { - public class TodoItemPrep + public class TodoItemPrep : TypePrepBase { - ITestDataAccessor dataAccessor; TodoListPrep todoListPrep; - Bogus.Faker random = new Bogus.Faker(); - - public TodoItemPrep(ITestDataAccessor dataAccessor, TodoListPrep todoListPrep) + public TodoItemPrep(ITestDataAccessor dataAccessor, TodoListPrep todoListPrep) : base (dataAccessor) { - this.dataAccessor = dataAccessor; this.todoListPrep = todoListPrep; } @@ -37,18 +33,6 @@ public TodoItem Create(TodoList todoList = null, bool? isComplete = null) return savedItem; } - public TodoItem Create(TodoItem todoItem, bool isActive = true) - { - TodoItem_Mapper mapper = new TodoItem_Mapper(); - TodoItemDTO model = mapper.ContractToModel(todoItem); - // handle active state here so I can create inactive items, but leave active flags off of data contracts - model.IsActive = isActive; - - TodoItemDTO savedModel = dataAccessor.Create(model); - TodoItem savedContract = mapper.ModelToContract(savedModel); - - return savedContract; - } public IEnumerable CreateManyForList(int count, TodoList todoList) { diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index 2faa799..59bca9e 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -8,15 +8,11 @@ namespace Tests.DataPrep { - public class TodoListPrep + public class TodoListPrep : TypePrepBase { - Bogus.Faker random = new Bogus.Faker(); - - ITestDataAccessor dataAccessor; UserPrep userPrep; - public TodoListPrep(ITestDataAccessor dataAccessor, UserPrep userPrep) + public TodoListPrep(ITestDataAccessor dataAccessor, UserPrep userPrep) : base(dataAccessor) { - this.dataAccessor = dataAccessor; this.userPrep = userPrep; } @@ -34,18 +30,6 @@ public TodoList Create(User user = null) return savedList; } - public TodoList Create(TodoList todoList, bool isActive = true) - { - TodoList_Mapper mapper = new TodoList_Mapper(); - TodoListDTO model = mapper.ContractToModel(todoList); - model.IsActive = isActive; - - TodoListDTO savedModel = dataAccessor.Create(model); - TodoList savedContract = mapper.ModelToContract(savedModel); - - return savedContract; - } - public IEnumerable CreateManyForUser(int count, User user) { List todoLists = new List(); diff --git a/Tests.DataPrep/TypePrepBase.cs b/Tests.DataPrep/TypePrepBase.cs new file mode 100644 index 0000000..7aecec0 --- /dev/null +++ b/Tests.DataPrep/TypePrepBase.cs @@ -0,0 +1,41 @@ +using Bogus; +using Shared.DatabaseContext.DBOs; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tests.DataPrep +{ + public class TypePrepBase where T : class where PersistedType : class, DatabaseObjectBase + { + protected ITestDataAccessor dataAccessor; + protected Faker random = new Faker(); + + protected MapperBase mapper = new MapperBase(); + + public TypePrepBase(ITestDataAccessor dataAccessor) + { + this.dataAccessor = dataAccessor; + } + + public virtual T Create() + { + Faker faker = new Faker(); + T saved = Create(faker.Generate()); + return saved; + } + + public virtual T Create(T existing, bool isActive = true) + { + PersistedType model = mapper.ContractToModel(existing); + // handle active state here so I can create inactive items, but leave active flags off of data contracts + model.IsActive = isActive; + + PersistedType savedModel = dataAccessor.Create(model); + T savedContract = mapper.ModelToContract(savedModel); + + return savedContract; + } + + } +} diff --git a/Tests.DataPrep/UserPrep.cs b/Tests.DataPrep/UserPrep.cs index 9beefd6..a15c16b 100644 --- a/Tests.DataPrep/UserPrep.cs +++ b/Tests.DataPrep/UserPrep.cs @@ -9,39 +9,10 @@ namespace Tests.DataPrep { - public class UserPrep + public class UserPrep : TypePrepBase { - Bogus.Faker random = new Bogus.Faker(); - - ITestDataAccessor dataAccessor; - public UserPrep(ITestDataAccessor dataAccessor) - { - this.dataAccessor = dataAccessor; - } - - public User Create() + public UserPrep(ITestDataAccessor dataAccessor) : base(dataAccessor) { - User user = new User() - { - Name = random.Name.FullName(), - }; - User savedUser = Create(user); - - return savedUser; } - - public User Create(User user, bool isActive = true) - { - // NOTE/TODO: feels like there should be a good way to encapsulate this so most data prep classes don't have to write it - User_Mapper mapper = new User_Mapper(); - UserDTO model = mapper.ContractToModel(user); - model.IsActive = isActive; - - UserDTO savedModel = dataAccessor.Create(model); - User savedContract = mapper.ModelToContract(savedModel); - - return savedContract; - } - } } From e102b4ea96045d2fcce46dcd0e9138a4fbb80251 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Sat, 20 Apr 2019 17:49:37 -0500 Subject: [PATCH 72/74] enable datapreps to return unsaved objects for easier create tests --- Tests.AccessorTests/TodoItemAccessorTests.cs | 8 +------- Tests.AccessorTests/TodoListAccessorTests.cs | 6 +----- Tests.DataPrep/TodoItemPrep.cs | 14 ++++++++++---- Tests.DataPrep/TodoListPrep.cs | 13 ++++++++++--- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Tests.AccessorTests/TodoItemAccessorTests.cs b/Tests.AccessorTests/TodoItemAccessorTests.cs index 8d30f9f..0ad08a3 100644 --- a/Tests.AccessorTests/TodoItemAccessorTests.cs +++ b/Tests.AccessorTests/TodoItemAccessorTests.cs @@ -115,13 +115,7 @@ public void SaveTodoItem_Update() public void SaveTodoItem_Create() { // arrange - TodoList parentList = dataPrep.TodoLists.Create(); - TodoItem expectedTodoItem = new TodoItem() - { - TodoListId = parentList.Id, - Description = Guid.NewGuid().ToString(), - IsComplete = false, - }; + TodoItem expectedTodoItem = dataPrep.TodoItems.Create(isPersisted: false); // act SaveResult saveResult = accessor.SaveTodoItem(expectedTodoItem); diff --git a/Tests.AccessorTests/TodoListAccessorTests.cs b/Tests.AccessorTests/TodoListAccessorTests.cs index c769584..30a8e29 100644 --- a/Tests.AccessorTests/TodoListAccessorTests.cs +++ b/Tests.AccessorTests/TodoListAccessorTests.cs @@ -56,11 +56,7 @@ public void SaveTodoList_Update() public void SaveTodoList_Create() { User user = dataPrep.Users.Create(); - TodoList newTodoList = new TodoList() - { - UserId = user.Id, - Title = Guid.NewGuid().ToString(), - }; + TodoList newTodoList = dataPrep.TodoLists.Create(isPersisted: false); SaveResult saveResult = accessor.SaveTodoList(newTodoList); TodoList actualTodoList = saveResult.Result; diff --git a/Tests.DataPrep/TodoItemPrep.cs b/Tests.DataPrep/TodoItemPrep.cs index 7eb6a32..0b1ad9c 100644 --- a/Tests.DataPrep/TodoItemPrep.cs +++ b/Tests.DataPrep/TodoItemPrep.cs @@ -17,7 +17,7 @@ public TodoItemPrep(ITestDataAccessor dataAccessor, TodoListPrep todoListPrep) : this.todoListPrep = todoListPrep; } - public TodoItem Create(TodoList todoList = null, bool? isComplete = null) + public TodoItem Create(TodoList todoList = null, bool? isComplete = null, bool isPersisted = true) { TodoList sanitizedTodoList = todoList ?? todoListPrep.Create(); @@ -28,9 +28,15 @@ public TodoItem Create(TodoList todoList = null, bool? isComplete = null) IsComplete = isComplete ?? random.PickRandom(true, false), }; - TodoItem savedItem = Create(todoItem); - - return savedItem; + if (isPersisted) + { + TodoItem savedItem = Create(todoItem); + return savedItem; + } + else + { + return todoItem; + } } diff --git a/Tests.DataPrep/TodoListPrep.cs b/Tests.DataPrep/TodoListPrep.cs index 59bca9e..b5ee99b 100644 --- a/Tests.DataPrep/TodoListPrep.cs +++ b/Tests.DataPrep/TodoListPrep.cs @@ -16,7 +16,7 @@ public TodoListPrep(ITestDataAccessor dataAccessor, UserPrep userPrep) : base(da this.userPrep = userPrep; } - public TodoList Create(User user = null) + public TodoList Create(User user = null, bool isPersisted = true) { User sanitizedUser = user ?? userPrep.Create(); TodoList todoList = new TodoList() @@ -25,9 +25,16 @@ public TodoList Create(User user = null) Title = random.Lorem.Sentence(), }; - TodoList savedList = Create(todoList); + if (isPersisted) + { + TodoList savedList = base.Create(todoList); + return savedList; + } + else + { + return todoList; + } - return savedList; } public IEnumerable CreateManyForUser(int count, User user) From 0d2f15dff933b21c8d4bd35d793383cbcbdeff97 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 6 May 2019 10:01:21 -0500 Subject: [PATCH 73/74] try moving readmes to wiki repository --- .gitmodules | 3 + 1.README_SolutionStructure.md | 58 ------------------- README.md | 2 +- README_NamingPatterns.md | 27 --------- Shared.DataContracts/README_DataContracts.md | 36 ------------ .../DTOs/README_DataTransferObjects.md | 12 ---- .../README_DependencyInjection.md | 41 ------------- .../README_DependencyInjectionKernel.md | 7 --- Test.NUnitExtensions/README_TestPrefixes.md | 13 ----- Tests.DataPrep/README_DataPrep.md | 20 ------- .../README_IntegrationReuse_WhiteDoc.md | 51 ---------------- Tests.ManagerTests/README_TestClassReuse.md | 17 ------ Tests.TestBases/README_TestingTools.md | 22 ------- wiki | 1 + 14 files changed, 5 insertions(+), 305 deletions(-) create mode 100644 .gitmodules delete mode 100644 1.README_SolutionStructure.md delete mode 100644 README_NamingPatterns.md delete mode 100644 Shared.DataContracts/README_DataContracts.md delete mode 100644 Shared.DatabaseContext/DTOs/README_DataTransferObjects.md delete mode 100644 Shared.DependencyInjectionKernel/README_DependencyInjection.md delete mode 100644 Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md delete mode 100644 Test.NUnitExtensions/README_TestPrefixes.md delete mode 100644 Tests.DataPrep/README_DataPrep.md delete mode 100644 Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md delete mode 100644 Tests.ManagerTests/README_TestClassReuse.md delete mode 100644 Tests.TestBases/README_TestingTools.md create mode 160000 wiki diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..12873f3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "wiki"] + path = wiki + url = https://github.com/farlee2121/TestingPatterns.wiki.git/ diff --git a/1.README_SolutionStructure.md b/1.README_SolutionStructure.md deleted file mode 100644 index d24b1c1..0000000 --- a/1.README_SolutionStructure.md +++ /dev/null @@ -1,58 +0,0 @@ -# Service Orientation - -Service orientation is a pattern of the same level as object orientation or functional programming. It determines your basic unit -of design. In OO, you basic unit is an object. In functional, it's a function. In service-oriented, it's a service and a contract. -A service is a cohesive and isolated collection of operations. Every function in the service fits one high-level purpose, typically hiding one -design descision. You should never have to look further than the service to completely understand the work that a service accomplishes. Thus, -it is imparative to have clear and simple hand-offs to and from the service. - -That is where contracts come in. They are the possible hand-off values of a service. If services represent function, contracts represent data. -The simpler your contracts are, the less you are able to have un-expected ties between services, and the less likely you are to break isolation. -As a rule of thumb, if you can't tell exactly what you can and can't do based on the the interface signature (and maybe a contract definition), it is too complex. - -#IDesign -The key to understanding the code layout is a pattern called IDesign. -IDesign is a layered, service-oriented architecture pattern. - -IDesign has five layers. - -Clients - responsible for consumption of your program. For example, user interfaces, apis, windows services. -Managers - Organize the order of execution. These are the primary flows of your application -Engines - The algorithms, business logic, data-manipulation type stuff -Accessor - Abstract external resources for use by the application. For example, database access, file system access, external apis -Resources - Anything not controlled by your code (databases, external apis, etc). These are what accessors abstract. - -Viewed in terms of orthogonality and information hiding, each layer is responsible for isolating/hiding a particular type of design concern. - -Accessors - Third party code or components not fully in your application's control -Engines - Computation -Managers - Composition of functionality -Clients - Application representation and interaction - -Layers may only call into the adjacent lower layer. (I.E. engines only call accessors, accessors only call resources). -The one exception is that managers can call to both engines and accessors. Sometimes a client may call an engine, but it is rare -that this is a good choice. -However, engines never call managers. That would mean your processing is calling your orchestration, which can lead to many unexpected -execution order problems. - -These simple rules categorize and organize the vast majority of programming responsibility types. The simple rules allow you to quickly find -a piece of code and limit what other units of code it could be working with, thus reducing complexity. - -By considering the few rules of IDesign, you are also led to follow other known best practices like SOLID, information hiding, stable dependencies and others. -One principle worth calling out specifically is single responsibility principle. IDesign draws attention to sneaky violations of single responsibility principle -by differentiating responsibility types. - - -#Folder Structure -The folder structure reflects the primary responsibilities of IDesign, and other primary concerns like testing. -It allows the solution to be more easily navigated and not have an overwhelming number of choices as the -number of projects grows. - -The numbers in the folders allow us to set the folder order to match the layering metaphor instead of being alphabetic. - -The shared folder is for meta-infrastructure that is needed across projects. For example, dependency injection config, data contracts, and possibly logging. -Do not be tempted to put app functionality in this folder. - -#Project Name Prefixes -Adding some namespacing to our projects (e.g. Accessors.Project or Tests.Project) allows our underlying file structure to -be organized by responsibility type and easily navigated. \ No newline at end of file diff --git a/README.md b/README.md index 7edcc6f..825a396 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ As a result, it also demonstrates many other patterns and libraries that enable Here is the presentation the triggered the project: https://20xtesting.slides.spencerfarley.com -Here is a presentation that describes the design philosphies: https://1drv.ms/b/s!AjVvNQ4uturOby6OwKMFpMUlMqA +Here is a presentation that describes the design philosophies: https://1drv.ms/b/s!AjVvNQ4uturOby6OwKMFpMUlMqA This project is very much overkill for a Todo list. However, the overkill is to demonstrate the patterns in a way that can easily be transfered to a large project diff --git a/README_NamingPatterns.md b/README_NamingPatterns.md deleted file mode 100644 index 5fd4f5c..0000000 --- a/README_NamingPatterns.md +++ /dev/null @@ -1,27 +0,0 @@ -# Naming - -Naming is one of the most important tasks you do as a programmer. Name determine how coders will percieve the decomposition of the system -, how easy it is to tell what code does, and how easy it is to find code for a specific need. - -##Manager Naming: - Managers should be named for the application flow they organize. For example, UserCheckoutManager is all the tools functions needed to -help a user review their order and purchase. -Managers tend to not be centered on nouns, but on chunks of the UX (user experience). Manager are the head of your application. -If you were to get rid of all of your client (web apps, etc) and write a new one, you should only have to map manager methods to UI -components. - -The functions in a manager should be named for the purpose they accomplish, not the data that they process. - -#Engine Naming -Engines tend to be pretty easy to name. They generally have one computational purpose or one verb that they center around. - -#Accessor Naming -Accessors are intrinsically tied to a data source. They can be used by many flows and tend to center around a data type. - - -#Variable Naming -You should be able to tell what a varible in intended for, not just it's type (though in some cases, like accessors, the type indicates sufficient purpose). -This prevents mistaken manipulation of a variable and clarifies intent for later modification. - -You should also never reuse a variable. If you've changed the intent of the data, you should give it a new name to reflect the reason for the change. -For example, if you sort a list, re-assign it to a variable that declares it as sorted. \ No newline at end of file diff --git a/Shared.DataContracts/README_DataContracts.md b/Shared.DataContracts/README_DataContracts.md deleted file mode 100644 index 87c1a10..0000000 --- a/Shared.DataContracts/README_DataContracts.md +++ /dev/null @@ -1,36 +0,0 @@ -#Data Contracts - -Data Contracts are the possible hand-off values of a service. If services represent function, contracts represent data. -The simpler your contracts are, the less you are able to have un-expected ties between services, and the less likely you are to break isolation. -As a rule of thumb, if you can't tell exactly what you can and can't do based on the the interface signature (and maybe a contract definition), it is too complex. -In other words, they: - - Represent the data shared by a flow in the application - - are the only non-value types that should be available in multiple projects - - are the only non-value types returned from an interface - -Data contracts should - - be as flat as possible (very rarely contain non-value types) - - Contain only the data needed for the situation, split contracts if you have un-needed data - - Be named semantically / so that it is clear what purpose they fulfill - - Do not contain state or logic. This is both a matter of concurrency (thread safety) and conceptual clarity. - - Represent a useful collection of values, not necessarily the database - -This - - Improves iteroperability (because services use the same types) - - Limits the scope of computation-specific and project-specific types by disallowing them as a return type - - When separated from Data Transfer Objects, allows you to shape your program without concern for the database structure - - Limits ability to couple services through data, because the contracts are designed for an application flow, - not to particular pieces of code. Being flat and minimal also reduces the possibility for unintended use or - broken expectations - - Disallowing state and logic, besides enabling thread-safe operations, decouples data from actions. This helps allows us to - operate on the data in many valid ways without mixing unrelated logic. It also keeps us from distributing manager-style/organizational code, which leads to unexpected actions. - For example, you are passed an object configured to save to the db, but you want to save it to a nosql. However, you either don't know where that object is going to save - or every interested portion of code check where that object is configured to save and mutate it to fit the current need. - With separated actions and data, there can be no such confusion because the orchestrating is always left to the service - - Allows internal service changes without impact to external code (As long as the internal data maps to the contract, no related services care) - - -#Result Types (i.e. SaveResult/DeleteResult) - -Result types allow a return value with relevant meta-info. Most commonly, operation success or errors in not successful. -They allow you to handle errors in a service and normalize success/failure information for consuming services. \ No newline at end of file diff --git a/Shared.DatabaseContext/DTOs/README_DataTransferObjects.md b/Shared.DatabaseContext/DTOs/README_DataTransferObjects.md deleted file mode 100644 index 6ea69da..0000000 --- a/Shared.DatabaseContext/DTOs/README_DataTransferObjects.md +++ /dev/null @@ -1,12 +0,0 @@ -#Data Transfer Objects - -At first blush, these may seem the same as data contracts. However, data transfer objects reflect expected results -of data source queries. They allow us to encode knowledge about our data stucture for consumption in our code. -DataContracts on the other hand, should have no ties to the data structure. - -Handing off from DTOs to DataContracts allows only our accessors to contain knowledge of the datasource, while the -rest of the application is un-impacted by database changes. This makes it much easier to make data schema changes -without causing bugs. As long as the accessors map to the data contracts, no changes outside the accessor are needed. - -Adding this additional set of models can make for a lot of boring object mapping work. Fortunately, there are libraries -like AutoMapper that automate that work, making database-isolation the clear winner of the design concerns. \ No newline at end of file diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjection.md b/Shared.DependencyInjectionKernel/README_DependencyInjection.md deleted file mode 100644 index ecd4c96..0000000 --- a/Shared.DependencyInjectionKernel/README_DependencyInjection.md +++ /dev/null @@ -1,41 +0,0 @@ -# Dependency Injection - -Dependency Inversion is the D of the five SOLID priciples. Dependency injection is a popular way of -achieving dependency inversion. - -Dependency injection turns function calls into configuration. Instead of instantiating the class you want to call, -you have a registry of forms mapped to dependencies. You specify the form of class you want, and the registry container -hands you an implementation. - -In languages like C#, the 'form' is almost always specified using interfaces. Interfaces have the benefit of ensuring a -certain level of behavior and one class can satisfy many interfaces. - -So, what's the deal. Why do we even want this? - -Academically, it breaks the dependency of the higher level class on the lower level class. You no longer are explictly -tied to the details of low level concerns. - -Practically, this - - Allows us to write code top-down, simply writing in the interfaces of the next level of dependencies we need. - This makes for less code re-work and allows us to test a flow without writing the whole dependency stack - - Allows us to swap in different dependencies of equivalent purpose with only config change - - E.g. you could completely switch storage paradigms based on execution environment - - Allows us to isolate code for testing - - -# Distributed Dependency Configuration / Loaders - -You may notice that each project (thus assembly) defines it's own dependency injection configuration. -This allows us to configure DI without making implementations public. This prevents people from using -concrete classes directly and thus breaking code isolation. - -It also packages dependencies that are used together, cutting down on use-time config setup. - -# Friend Assemblies -Along side every dependency loader is a friend assembly file. Friend assemblies are a .NET concept -that allows you to expose internal constructs to specific assemblies. - -This allows us to test against concrete classes while keeping them hidden from other consuming assemblies. - -We have a dedicated friendassembly file for simplicity of finding and modifying the friends as well as leaving -this unrelated concern out of the service implementations \ No newline at end of file diff --git a/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md b/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md deleted file mode 100644 index 02f4984..0000000 --- a/Shared.DependencyInjectionKernel/README_DependencyInjectionKernel.md +++ /dev/null @@ -1,7 +0,0 @@ -#Dependency Injection Kernel - -The dependency kernel allows us to centralize our dependency injection configuration. This helps prevents errors -caused by forgetting to update different clients that require configuration for new service types. - -This class allows us offer up alternative configurations (through additional methods) for clients that may only require a subset of the -dependency configuration while keeping the dependency maps in one clear place. \ No newline at end of file diff --git a/Test.NUnitExtensions/README_TestPrefixes.md b/Test.NUnitExtensions/README_TestPrefixes.md deleted file mode 100644 index bfd42fa..0000000 --- a/Test.NUnitExtensions/README_TestPrefixes.md +++ /dev/null @@ -1,13 +0,0 @@ -# Auto-Generated Test Prefixes - -Prefixing the name of the tested class to a test name produces more clearly organized test results. -It also allows us to more quickly identify trends in test failures. - -However, manually maintaining these prefixes is a pain. If you change a class name, it is easy to forget -to rename all the tests and is boring to rename all the tests. - -Auto-generating the class name based on the test subject types means we can't forget to rename the test -and cleans test name of info we already know when we are in the test class. - -Generated prefixes can also help differentiate tests that generate multiple cases, such as with integration/unit -test reuse. \ No newline at end of file diff --git a/Tests.DataPrep/README_DataPrep.md b/Tests.DataPrep/README_DataPrep.md deleted file mode 100644 index 80d7bc6..0000000 --- a/Tests.DataPrep/README_DataPrep.md +++ /dev/null @@ -1,20 +0,0 @@ -#DataPrep Pattern -The DataPrep pattern is a way of centralizing test data generation and creating readable handles for common -data requests. - -The pattern consists of two parts -1. individual data preps: these handle - - the construction of a particular type based on passed conditions - - abstraction of complex arrangement scenarios -2. data prep orchestrator: this class is responsible for - - providing a central handle for creating test data - - allowing us to configure type data preps uniformly - - allowing us to present type data preps differently for different scenarios - - -We utilize a test data generation library called Bogus. Bogus can generate complex data types, so why don't we use that directly? -Well, - - When data structures change, it is much harder to find specific uses of a library than a central method - - You still end up with a lot of noisy configuration in your tests - - Data prep produces clearer specification of test situations, especially with complex situations - - a custom DataPrep wrapper allows us to absract how we persist data diff --git a/Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md b/Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md deleted file mode 100644 index ce7746d..0000000 --- a/Tests.ManagerTests/README_IntegrationReuse_WhiteDoc.md +++ /dev/null @@ -1,51 +0,0 @@ -# Integration Reuse WhiteDoc (discovery process) - -TL;DR; Discovered that NUnit is much more powerful than MSTest - -I started out using MSTest. Integration tests could be reused in several ways - -1. Creating a second class, instantiating the unit test class with a full DI configuration and dataprep set to persist. -Then create a test method that calls into each method on the unit test class you want to reuse -- Pros: clear names and differentiation in the test runner. Can pick and choose methods to reuse. -- cons: lots of manual maintenence -2. Inherit from the original test class, modifying the constructor to specify integration mode --Pros: No additional changes when test names are added/removed/renamed --Cons: it causes duplicate names and both integration and unit runs will be directed to the inherited class, making it unclear which test is which - -3. Reflecting over a class's methods and raising an exception that highlights the failed method with a reason - - Cons: still collapses test runs in test explorer. Reflection is slow - -4. Generating a code file at build time with a plugin. It would be a pretty simple plugin with simple emitted code -- Cons: have to write and run additional code as well as install an extension - -5. Try extending TestMethod or TestClass to run tests twice - -Alternative #5 led me to explore extensibility in MSTest. In short, it is kinda limited and does not let you set the test name. -How to extend MSTest here -- https://blogs.msdn.microsoft.com/devops/2017/07/18/extending-mstest-v2/ -- https://github.com/Microsoft/testfx-docs/blob/master/RFCs/003-Customize-Running-Tests.md - -However, NUnit can handle runs with different parameters out of the box. It has much more powerful functionality and extensibility. - -NOTE: you can run MSTest and NUnit side by side, which makes it very easy to transition progressively - -The question is now how to generate differentiated names in the test runner with NUnit. -- https://www.red-gate.com/simple-talk/dotnet/net-tools/testing-times-ahead-extending-nunit/ -- https://github.com/nunit/docs/wiki/Custom-Attributes -- https://github.com/nunit/docs/wiki/Writing-Engine-Extensions -- Could probably use TestCase attributes to define integration/not on each method. A bit verbose, non-semantic, and extra init work -- NOTE: Changing the test name with something like IApplyToTest is not changing the name in the test runner -- NOTE: NUnit supports test name string formatting https://stackoverflow.com/questions/26374265/access-nunit-test-name-within-testcasesource - -- Conclusion: The rules for name generation are not very clear in NUnit. - However, I have verified that you can sucessfully overwrite the name in either - the test builder or the fixture builder. - It is not entirely clear how to extend these types while maintaining behavior - because you cannot override when you inherit from the default attributes. Instead, - the logic is available through internal builders and type constructors. - However, you can also inherit from the default attribute and 'hide' the base class's method - by creating one of the same signature. This breaks liscov substitution, but it - allows you to reuse the property logic of the base attibutes - - -BONUS: Interesting thread on using NUnit tests to augment documentation https://stackoverflow.com/questions/8727684/how-can-i-generate-documentation-from-nunit-tests \ No newline at end of file diff --git a/Tests.ManagerTests/README_TestClassReuse.md b/Tests.ManagerTests/README_TestClassReuse.md deleted file mode 100644 index 82c1fdd..0000000 --- a/Tests.ManagerTests/README_TestClassReuse.md +++ /dev/null @@ -1,17 +0,0 @@ -# Test Class Reuse - -There are to common automated test types written by developers. - - Unit tests: verify a specific piece of code in isolation - - Integration tests: verify that the components in a flow work together as expected - -Between our dependency injection and abstracted data prep, our unit tests can configure both the -dependencies and persistance of data independed of individual tests. This means that our tests -specify a situation, with out regard to execution context. - -Thus, our unit tests and integration tests now only differ by configuration. Using NUnit, -we can easily run a test class with two different configurations and cut our testing effort in half! - -Some examples are shown of test reuse with MSTest, but it is neither as easy nor as clear as with NUnit. - -We have plans to create more clear NUnit attributes that will prefix integration tests and allow us to exclude -individual methods from either unit or integration runs diff --git a/Tests.TestBases/README_TestingTools.md b/Tests.TestBases/README_TestingTools.md deleted file mode 100644 index a767355..0000000 --- a/Tests.TestBases/README_TestingTools.md +++ /dev/null @@ -1,22 +0,0 @@ -# Testing Tools - -This is sort of a catch-all doc for testing concerns and awesome libraries that make testing easier. - -# Test Dependency Generation -When testing a code, you want the subject of test to be isolated so that there are no errors from code you -don't intend to test. -Dependency injection allows us to configure test dependencies that only do what we expect for the test, but -it can be a lot of work to specify stub dependencies. - -That is where JustMock comes in. It auto-generates test dependencies and allows you to modify their behavior -in the unit test as needed. - -# Complex Object Comparison -DeepEqual allows you to compare complex objects by their values and modify comparison behavior as needed. - -# Data Cleanup -.NET transactions allow you to specify each test as a unit of work. That unit can then be committed or rolled back -as a whole. This means that you don't have to worry about leaving test data behind, it happens auto-magically. - -# DataPrep -Has its own doc, check it out \ No newline at end of file diff --git a/wiki b/wiki new file mode 160000 index 0000000..0545a39 --- /dev/null +++ b/wiki @@ -0,0 +1 @@ +Subproject commit 0545a390b28362e723a4c904f837bce82b769864 From 37770dc5d5922c11934867e7af4651317aa79f96 Mon Sep 17 00:00:00 2001 From: Spencer Farley Date: Mon, 6 May 2019 10:02:30 -0500 Subject: [PATCH 74/74] submodule changes --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 0545a39..08ba564 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 0545a390b28362e723a4c904f837bce82b769864 +Subproject commit 08ba5643616c6a9415b90542bb38754cc7e86e34