diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/IProductService.cs b/IProductService.cs
new file mode 100644
index 0000000..c74913a
--- /dev/null
+++ b/IProductService.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public interface IProductService
+ {
+ Task UpdateProductInfo();
+ Task GetProductBySku(string sku);
+ Task GetProductForSaleBySku(string sku);
+ Task> GetProducts();
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/IProductService.cs b/IProductService.cs
new file mode 100644
index 0000000..c74913a
--- /dev/null
+++ b/IProductService.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public interface IProductService
+ {
+ Task UpdateProductInfo();
+ Task GetProductBySku(string sku);
+ Task GetProductForSaleBySku(string sku);
+ Task> GetProducts();
+ }
+}
\ No newline at end of file
diff --git a/Product.cs b/Product.cs
new file mode 100644
index 0000000..dac2987
--- /dev/null
+++ b/Product.cs
@@ -0,0 +1,25 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public class Product
+ {
+ public string Sku { get; set; }
+ }
+
+ public class ProductViewModel
+ {
+ public string Sku { get; set; }
+ }
+
+ public static class Extensions
+ {
+ public static ProductViewModel ToViewModel(this Product product)
+ {
+ return new()
+ {
+ Sku = product.Sku
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/IProductService.cs b/IProductService.cs
new file mode 100644
index 0000000..c74913a
--- /dev/null
+++ b/IProductService.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public interface IProductService
+ {
+ Task UpdateProductInfo();
+ Task GetProductBySku(string sku);
+ Task GetProductForSaleBySku(string sku);
+ Task> GetProducts();
+ }
+}
\ No newline at end of file
diff --git a/Product.cs b/Product.cs
new file mode 100644
index 0000000..dac2987
--- /dev/null
+++ b/Product.cs
@@ -0,0 +1,25 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public class Product
+ {
+ public string Sku { get; set; }
+ }
+
+ public class ProductViewModel
+ {
+ public string Sku { get; set; }
+ }
+
+ public static class Extensions
+ {
+ public static ProductViewModel ToViewModel(this Product product)
+ {
+ return new()
+ {
+ Sku = product.Sku
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductDelegates.cs b/ProductDelegates.cs
new file mode 100644
index 0000000..25b610e
--- /dev/null
+++ b/ProductDelegates.cs
@@ -0,0 +1,10 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public static class ProductDelegates
+ {
+ public delegate Task GetProductBySku(string sku);
+ public delegate Task GetProductForSaleBySku(string sku);
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/IProductService.cs b/IProductService.cs
new file mode 100644
index 0000000..c74913a
--- /dev/null
+++ b/IProductService.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public interface IProductService
+ {
+ Task UpdateProductInfo();
+ Task GetProductBySku(string sku);
+ Task GetProductForSaleBySku(string sku);
+ Task> GetProducts();
+ }
+}
\ No newline at end of file
diff --git a/Product.cs b/Product.cs
new file mode 100644
index 0000000..dac2987
--- /dev/null
+++ b/Product.cs
@@ -0,0 +1,25 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public class Product
+ {
+ public string Sku { get; set; }
+ }
+
+ public class ProductViewModel
+ {
+ public string Sku { get; set; }
+ }
+
+ public static class Extensions
+ {
+ public static ProductViewModel ToViewModel(this Product product)
+ {
+ return new()
+ {
+ Sku = product.Sku
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductDelegates.cs b/ProductDelegates.cs
new file mode 100644
index 0000000..25b610e
--- /dev/null
+++ b/ProductDelegates.cs
@@ -0,0 +1,10 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public static class ProductDelegates
+ {
+ public delegate Task GetProductBySku(string sku);
+ public delegate Task GetProductForSaleBySku(string sku);
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..86e97ca
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+Cohesion
+===============
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/IProductService.cs b/IProductService.cs
new file mode 100644
index 0000000..c74913a
--- /dev/null
+++ b/IProductService.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public interface IProductService
+ {
+ Task UpdateProductInfo();
+ Task GetProductBySku(string sku);
+ Task GetProductForSaleBySku(string sku);
+ Task> GetProducts();
+ }
+}
\ No newline at end of file
diff --git a/Product.cs b/Product.cs
new file mode 100644
index 0000000..dac2987
--- /dev/null
+++ b/Product.cs
@@ -0,0 +1,25 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public class Product
+ {
+ public string Sku { get; set; }
+ }
+
+ public class ProductViewModel
+ {
+ public string Sku { get; set; }
+ }
+
+ public static class Extensions
+ {
+ public static ProductViewModel ToViewModel(this Product product)
+ {
+ return new()
+ {
+ Sku = product.Sku
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductDelegates.cs b/ProductDelegates.cs
new file mode 100644
index 0000000..25b610e
--- /dev/null
+++ b/ProductDelegates.cs
@@ -0,0 +1,10 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public static class ProductDelegates
+ {
+ public delegate Task GetProductBySku(string sku);
+ public delegate Task GetProductForSaleBySku(string sku);
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..86e97ca
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+Cohesion
+===============
diff --git a/TestInterface.cs b/TestInterface.cs
new file mode 100644
index 0000000..041c222
--- /dev/null
+++ b/TestInterface.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Moq;
+using Shouldly;
+using Xunit;
+
+namespace Cohesion
+{
+ public class TestWithInterface
+ {
+ [Fact]
+ public async Task Test()
+ {
+ var sku = Guid.NewGuid().ToString();
+
+ var mockProductService = new Mock();
+ mockProductService.Setup(x => x.GetProductBySku(sku)).Returns(Task.FromResult(new Product()
+ {
+ Sku = sku
+ }));
+
+ var sut = new GetProductBySkuHandler(mockProductService.Object);
+ var result = await sut.Handle(new GetProductBySkuRequest(sku), CancellationToken.None);
+
+ result.Sku.ShouldBe(sku);
+ }
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea5ebf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,205 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+x64/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Roslyn cache directories
+*.ide/
+
+# AWS
+*.aws-sam/
+
+# 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
+
+*_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
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# 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 addin-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+
+# 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
+## TODO: Comment the next line if you want to checkin your
+## web deploy settings but do note that will include unencrypted
+## passwords
+#*.pubxml
+
+# NuGet Packages Directory
+#packages/*
+## TODO: If the tool you use requires repositories.config
+## uncomment the next line
+#!packages/repositories.config
+
+# Enable "build/" folder in the NuGet Packages folder since
+# NuGet packages use it for MSBuild targets.
+# This line needs to be after the ignore of the build folder
+# (and the packages folder if the line above has been uncommented)
+#!packages/build/
+
+!src/packages/**/*.dll
+!src/packages/**/*.pdb
+
+# Windows Azure Build Output
+csx/
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# LightSwitch generated files
+GeneratedArtifacts/
+_Pvt_Extensions/
+ModelManifest.xml
+src/packages/EventStore.Client.3.3.1/lib/net40/EventStore.ClientAPI.xml
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# Vagrant VM files
+.vagrant
+vagrant/dbv/data/meta/revision
+
+# Visual Studio 2015 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Cohesion.csproj b/Cohesion.csproj
new file mode 100644
index 0000000..0aa43ac
--- /dev/null
+++ b/Cohesion.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GetProductBySku.cs b/GetProductBySku.cs
new file mode 100644
index 0000000..c555a6a
--- /dev/null
+++ b/GetProductBySku.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuRequest : IRequest
+ {
+ public GetProductBySkuRequest(string sku)
+ {
+ Sku = sku;
+ }
+
+ public string Sku { get; set; }
+ }
+
+ public class GetProductBySkuHandler : IRequestHandler
+ {
+ private readonly IProductService _productService;
+
+ public GetProductBySkuHandler(IProductService productService)
+ {
+ _productService = productService;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _productService.GetProductBySku(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/GetProductBySku2.cs b/GetProductBySku2.cs
new file mode 100644
index 0000000..1962a35
--- /dev/null
+++ b/GetProductBySku2.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediatR;
+
+namespace Cohesion
+{
+ public class GetProductBySkuHandlerDelegateExample : IRequestHandler
+ {
+ private readonly ProductDelegates.GetProductForSaleBySku _getProduct;
+
+ public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductForSaleBySku getProduct)
+ {
+ _getProduct = getProduct;
+ }
+
+ public async Task Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
+ {
+ var product = await _getProduct(request.Sku);
+ return product.ToViewModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/IProductService.cs b/IProductService.cs
new file mode 100644
index 0000000..c74913a
--- /dev/null
+++ b/IProductService.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public interface IProductService
+ {
+ Task UpdateProductInfo();
+ Task GetProductBySku(string sku);
+ Task GetProductForSaleBySku(string sku);
+ Task> GetProducts();
+ }
+}
\ No newline at end of file
diff --git a/Product.cs b/Product.cs
new file mode 100644
index 0000000..dac2987
--- /dev/null
+++ b/Product.cs
@@ -0,0 +1,25 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public class Product
+ {
+ public string Sku { get; set; }
+ }
+
+ public class ProductViewModel
+ {
+ public string Sku { get; set; }
+ }
+
+ public static class Extensions
+ {
+ public static ProductViewModel ToViewModel(this Product product)
+ {
+ return new()
+ {
+ Sku = product.Sku
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductDelegates.cs b/ProductDelegates.cs
new file mode 100644
index 0000000..25b610e
--- /dev/null
+++ b/ProductDelegates.cs
@@ -0,0 +1,10 @@
+using System.Threading.Tasks;
+
+namespace Cohesion
+{
+ public static class ProductDelegates
+ {
+ public delegate Task GetProductBySku(string sku);
+ public delegate Task GetProductForSaleBySku(string sku);
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..86e97ca
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+Cohesion
+===============
diff --git a/TestInterface.cs b/TestInterface.cs
new file mode 100644
index 0000000..041c222
--- /dev/null
+++ b/TestInterface.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Moq;
+using Shouldly;
+using Xunit;
+
+namespace Cohesion
+{
+ public class TestWithInterface
+ {
+ [Fact]
+ public async Task Test()
+ {
+ var sku = Guid.NewGuid().ToString();
+
+ var mockProductService = new Mock();
+ mockProductService.Setup(x => x.GetProductBySku(sku)).Returns(Task.FromResult(new Product()
+ {
+ Sku = sku
+ }));
+
+ var sut = new GetProductBySkuHandler(mockProductService.Object);
+ var result = await sut.Handle(new GetProductBySkuRequest(sku), CancellationToken.None);
+
+ result.Sku.ShouldBe(sku);
+ }
+ }
+}
\ No newline at end of file
diff --git a/TestWithDelegate.cs b/TestWithDelegate.cs
new file mode 100644
index 0000000..5053353
--- /dev/null
+++ b/TestWithDelegate.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Shouldly;
+using Xunit;
+
+namespace Cohesion
+{
+ public class TestWithDelegate
+ {
+ [Fact]
+ public async Task Test()
+ {
+ var sku = Guid.NewGuid().ToString();
+
+ var sut = new GetProductBySkuHandlerDelegateExample(x => Task.FromResult(new Product { Sku = x }));
+ var result = await sut.Handle(new GetProductBySkuRequest(sku), CancellationToken.None);
+
+ result.Sku.ShouldBe(sku);
+ }
+ }
+}
\ No newline at end of file