From e58494996594d1f0f24b628071e331ee9da1d2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Fri, 14 Jun 2019 00:45:23 -0500 Subject: [PATCH 01/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5463cd8..dd8e0a7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Use [Vortex](https://github.com/equilaterus/Vortex) side-by-side with **AutoMapp using Equilaterus.Vortex.AutoMapper.Extensions; ... -// Returns IMaybe +// Returns Maybe var maybeResult = IMapper.MaybeMap(sourceEntity); ``` From 6c254dc150f5a6466c22adad7b23e416b9fae0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 12:53:46 -0500 Subject: [PATCH 02/10] Fixing unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index c945c9e..3e1a540 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -28,23 +28,23 @@ public void MaybeMap_Success() public void MaybeMap_Null_ThrowsException() { var mapperMock = new Mock(); - mapperMock.Setup(x => x.Map(It.IsAny())) + mapperMock.Setup(x => x.Map(null)) .Returns(null); var objectMock = mapperMock.Object; - Assert.Throws(() => objectMock.MaybeMap(new object())); + Assert.Throws(() => objectMock.MaybeMap(null)); } [Fact] public void MaybeMap_SourceDestination_Success() { var mapperMock = new Mock(); - mapperMock.Setup(x => x.Map(It.IsAny(), It.IsAny())) + mapperMock.Setup(x => x.Map("1", 0.2)) .Returns(1.2); var objectMock = mapperMock.Object; - var result = objectMock.MaybeMap(new object(), new double()); + var result = objectMock.MaybeMap("1", 0.2); Assert.IsType>(result); Assert.Equal(1.2, result.Match(x => x, 0)); @@ -54,12 +54,12 @@ public void MaybeMap_SourceDestination_Success() public void MaybeMap_SourceDestination_Null_ThrowsException() { var mapperMock = new Mock(); - mapperMock.Setup(x => x.Map(It.IsAny(), It.IsAny())) + mapperMock.Setup(x => x.Map(null, null)) .Returns(null); var objectMock = mapperMock.Object; - Assert.Throws(() => objectMock.MaybeMap(new object(), new object())); + Assert.Throws(() => objectMock.MaybeMap(null, null)); } } } From 630b9f9714852da164297ae24695426ba2fba35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 12:56:20 -0500 Subject: [PATCH 03/10] Updating tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index 3e1a540..2ab87ae 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -13,13 +13,15 @@ public class MapperExtensions [Fact] public void MaybeMap_Success() { + // Prepare var mapperMock = new Mock(); mapperMock.Setup(x => x.Map(1)) .Returns(1.2); - var objectMock = mapperMock.Object; - var result = objectMock.MaybeMap(1); + // Execute + var result = mapperMock.Object.MaybeMap(1); + // Verify Assert.IsType>(result); Assert.Equal(1.2, result.Match(x => x, 0)); } @@ -27,25 +29,27 @@ public void MaybeMap_Success() [Fact] public void MaybeMap_Null_ThrowsException() { + // Prepare var mapperMock = new Mock(); mapperMock.Setup(x => x.Map(null)) .Returns(null); - var objectMock = mapperMock.Object; - - Assert.Throws(() => objectMock.MaybeMap(null)); + // Execute + Assert.Throws(() => mapperMock.Object.MaybeMap(null)); } [Fact] public void MaybeMap_SourceDestination_Success() { + // Prepare var mapperMock = new Mock(); mapperMock.Setup(x => x.Map("1", 0.2)) .Returns(1.2); - var objectMock = mapperMock.Object; - var result = objectMock.MaybeMap("1", 0.2); + // Execute + var result = mapperMock.Object.MaybeMap("1", 0.2); + // Verify Assert.IsType>(result); Assert.Equal(1.2, result.Match(x => x, 0)); } @@ -53,13 +57,13 @@ public void MaybeMap_SourceDestination_Success() [Fact] public void MaybeMap_SourceDestination_Null_ThrowsException() { + // Prepare var mapperMock = new Mock(); mapperMock.Setup(x => x.Map(null, null)) .Returns(null); - - var objectMock = mapperMock.Object; - - Assert.Throws(() => objectMock.MaybeMap(null, null)); + + // Execute + Assert.Throws(() => mapperMock.Object.MaybeMap(null, null)); } } } From 36dc8048e2b3fadb830c7f5b971b84b60f794948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 12:57:55 -0500 Subject: [PATCH 04/10] Updating test to avoid collision with newer methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index 2ab87ae..9a2d589 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -63,7 +63,7 @@ public void MaybeMap_SourceDestination_Null_ThrowsException() .Returns(null); // Execute - Assert.Throws(() => mapperMock.Object.MaybeMap(null, null)); + Assert.Throws(() => mapperMock.Object.MaybeMap(null, new object())); } } } From 1d4dfcd7573b83ef1fe0dda833cdb2cd50a40477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 12:58:35 -0500 Subject: [PATCH 05/10] Adding additional IMapper methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- src/MapperExtensions.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/MapperExtensions.cs b/src/MapperExtensions.cs index 4f54143..d22674a 100644 --- a/src/MapperExtensions.cs +++ b/src/MapperExtensions.cs @@ -14,10 +14,34 @@ public static Maybe MaybeMap( return new Maybe(mapper.Map(source)); } + public static Maybe MaybeMap( + this IMapper mapper, object source, Action opts) + { + return new Maybe(mapper.Map(source, opts)); + } + + public static Maybe MaybeMap( + this IMapper mapper, TSource source) + { + return new Maybe(mapper.Map(source)); + } + + public static Maybe MaybeMap( + this IMapper mapper, TSource source, Action> opts) + { + return new Maybe(mapper.Map(source, opts)); + } + public static Maybe MaybeMap( this IMapper mapper, TSource source, TDestination destination) { return new Maybe(mapper.Map(source, destination)); } + + public static Maybe MaybeMap( + this IMapper mapper, TSource source, TDestination destination, Action> opts) + { + return new Maybe(mapper.Map(source, destination, opts)); + } } } From 02a9c99a8c4bb07c7e9161bbf72c70177d1c1e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 13:05:09 -0500 Subject: [PATCH 06/10] Adding MaybeOpts tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index 9a2d589..baa713b 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -38,6 +38,34 @@ public void MaybeMap_Null_ThrowsException() Assert.Throws(() => mapperMock.Object.MaybeMap(null)); } + [Fact] + public void MaybeMapOpts_Success() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(1, null)) + .Returns(1.2); + + // Execute + var result = mapperMock.Object.MaybeMap(1, null); + + // Verify + Assert.IsType>(result); + Assert.Equal(1.2, result.Match(x => x, 0)); + } + + [Fact] + public void MaybeMapOpts_Null_ThrowsException() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(null, null)) + .Returns(null); + + // Execute + Assert.Throws(() => mapperMock.Object.MaybeMap(null, null)); + } + [Fact] public void MaybeMap_SourceDestination_Success() { From d739a23976cfe54f9f012b4868fe6ef274c5d30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 13:09:58 -0500 Subject: [PATCH 07/10] Added MaybeMapDestination tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index baa713b..9f57793 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -66,6 +66,34 @@ public void MaybeMapOpts_Null_ThrowsException() Assert.Throws(() => mapperMock.Object.MaybeMap(null, null)); } + [Fact] + public void MaybeMapDestination_Success() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(1)) + .Returns(1.2); + + // Execute + var result = mapperMock.Object.MaybeMap(1); + + // Verify + Assert.IsType>(result); + Assert.Equal(1.2, result.Match(x => x, 0)); + } + + [Fact] + public void MaybeMapDestination_Null_ThrowsException() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(null)) + .Returns(null); + + // Execute + Assert.Throws(() => mapperMock.Object.MaybeMap(null)); + } + [Fact] public void MaybeMap_SourceDestination_Success() { From 3a36bd4994128fcd49fc9d9c1a0e9dfb876e5521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 13:11:33 -0500 Subject: [PATCH 08/10] Added MaybeMapDestinationOpt tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index 9f57793..baedd6f 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -94,6 +94,34 @@ public void MaybeMapDestination_Null_ThrowsException() Assert.Throws(() => mapperMock.Object.MaybeMap(null)); } + [Fact] + public void MaybeMapDestinationOpt_Success() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(1, null)) + .Returns(1.2); + + // Execute + var result = mapperMock.Object.MaybeMap(1, null); + + // Verify + Assert.IsType>(result); + Assert.Equal(1.2, result.Match(x => x, 0)); + } + + [Fact] + public void MaybeMapDestinationOpt_Null_ThrowsException() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(null, null)) + .Returns(null); + + // Execute + Assert.Throws(() => mapperMock.Object.MaybeMap(null, null)); + } + [Fact] public void MaybeMap_SourceDestination_Success() { From 070a652778599c22eb87c56644ed518b694578c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 13:12:50 -0500 Subject: [PATCH 09/10] Added MaybeMapOpt tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- test/MapperExtensions.Test.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/MapperExtensions.Test.cs b/test/MapperExtensions.Test.cs index baedd6f..69db7db 100644 --- a/test/MapperExtensions.Test.cs +++ b/test/MapperExtensions.Test.cs @@ -149,5 +149,33 @@ public void MaybeMap_SourceDestination_Null_ThrowsException() // Execute Assert.Throws(() => mapperMock.Object.MaybeMap(null, new object())); } + + [Fact] + public void MaybeMapOpt_SourceDestination_Success() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map("1", 0.2, null)) + .Returns(1.2); + + // Execute + var result = mapperMock.Object.MaybeMap("1", 0.2, null); + + // Verify + Assert.IsType>(result); + Assert.Equal(1.2, result.Match(x => x, 0)); + } + + [Fact] + public void MaybeMapOpt_SourceDestination_Null_ThrowsException() + { + // Prepare + var mapperMock = new Mock(); + mapperMock.Setup(x => x.Map(null, null, null)) + .Returns(null); + + // Execute + Assert.Throws(() => mapperMock.Object.MaybeMap(null, new object(), null)); + } } } From fe8e96d6d5a3727d5c254f6b4d155aaa0c1da0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ca=C3=B1izares=20Corrales?= Date: Sun, 30 Jun 2019 13:18:48 -0500 Subject: [PATCH 10/10] Updating package version to 0.1.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Juan Felipe Cañizares Corrales --- appveyor.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 44fe9c6..2012f95 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,13 @@ -version: 0.1.0.{build} +version: 0.1.1.{build} image: Visual Studio 2019 dotnet_csproj: patch: true file: '**\*.csproj' - version: '0.1.0' - package_version: '0.1.0-alpha' - assembly_version: '0.1.0' - file_version: '0.1.0' - informational_version: '0.1.0' + version: '0.1.1' + package_version: '0.1.1-alpha' + assembly_version: '0.1.1' + file_version: '0.1.1' + informational_version: '0.1.1' before_build: - cmd: nuget restore build: