Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #33 from osoykan/dev
Browse files Browse the repository at this point in the history
master
  • Loading branch information
osoykan authored May 18, 2017
2 parents ce81cf2 + 83fc92e commit 60122be
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 15 deletions.
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ image: Visual Studio 2017
pull_requests:
do_not_increment_build_number: true

init:
- git config --global core.autocrlf input

assembly_info:
patch: true
file: '**\AssemblyInfo.*'
Expand Down
7 changes: 6 additions & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.0.2</VersionPrefix>
<VersionPrefix>1.0.3</VersionPrefix>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<PackageIconUrl>https://raw.githubusercontent.com/osoykan/Stove/master/stove.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/osoykan/Stove</PackageProjectUrl>
Expand All @@ -18,4 +18,9 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions nupkg/packs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $projects = (

# Rebuild solution
Set-Location $slnPath
& dotnet msbuild /t:Rebuild /p:Configuration=Release
& dotnet restore

# Copy all nuget packages to the pack folder
foreach($project in $projects) {
Expand All @@ -28,7 +28,8 @@ foreach($project in $projects) {

# Create nuget pack
Set-Location $projectFolder
& dotnet msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true
# Remove-Item -Recurse (Join-Path $projectFolder "bin/Release")
& dotnet msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true /p:SourceLinkCreate=true

# Copy nuget package
$projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $project + ".*.nupkg")
Expand Down
12 changes: 9 additions & 3 deletions src/Stove.Mapster/Mapster/MapsterObjectMapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Mapster;
using System;

using Mapster;

using Stove.ObjectMapping;

Expand All @@ -10,12 +12,16 @@ public class MapsterObjectMapper : IObjectMapper

public MapsterObjectMapper(IStoveMapsterConfiguration mapsterConfiguration)
{
this._mapsterConfiguration = mapsterConfiguration;
_mapsterConfiguration = mapsterConfiguration;
}

public TDestination Map<TDestination>(object source)
{
return source.Adapt<TDestination>(_mapsterConfiguration.Configuration);
Type sourceType = source.GetType().Namespace == "System.Data.Entity.DynamicProxies"
? source.GetType().BaseType
: source.GetType();

return (TDestination)source.Adapt(sourceType, typeof(TDestination), _mapsterConfiguration.Configuration);
}

public TDestination Map<TSource, TDestination>(TSource source, TDestination destination)
Expand Down
6 changes: 3 additions & 3 deletions src/Stove/Stove.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="4.5.0" />
<PackageReference Include="Autofac.Extras.IocManager" Version="3.0.0" />
<PackageReference Include="Autofac.Extras.IocManager.DynamicProxy" Version="3.0.0" />
<PackageReference Include="Autofac" Version="4.6.0" />
<PackageReference Include="Autofac.Extras.IocManager" Version="3.0.1" />
<PackageReference Include="Autofac.Extras.IocManager.DynamicProxy" Version="3.0.1" />
<PackageReference Include="Castle.Core" Version="4.0.0" />
<PackageReference Include="FluentAssemblyScanner" Version="1.0.7" />
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NHibernateProfiler.Appender" Version="4.0.4040" />
<PackageReference Include="NHibernateProfiler.Appender" Version="4.0.4041" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.1.3" />
<PackageReference Include="EntityFrameworkProfiler.Appender" Version="4.0.4040" />
<PackageReference Include="EntityFrameworkProfiler.Appender" Version="4.0.4041" />
<PackageReference Include="LinqKit" Version="1.1.9" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion test/Stove.Demo.WebApi/Stove.Demo.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<ItemGroup>
<PackageReference Include="Autofac.WebApi2.Owin" Version="4.0.0" />
<PackageReference Include="EntityFrameworkProfiler.Appender" Version="4.0.4040" />
<PackageReference Include="EntityFrameworkProfiler.Appender" Version="4.0.4041" />
<PackageReference Include="Microsoft.AspNet.WebApi.Cors" Version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Owin" Version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.3" />
Expand Down
2 changes: 1 addition & 1 deletion test/Stove.NHibernate.Tests/Stove.NHibernate.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.105" />
<PackageReference Include="System.Data.SQLite" Version="1.0.105.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Stove.TestBase/Stove.TestBase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="FluentAssemblyScanner" Version="1.0.7" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="Autofac.Extras.IocManager" Version="3.0.0" />
<PackageReference Include="Autofac.Extras.IocManager" Version="3.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
Expand Down
54 changes: 53 additions & 1 deletion test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
using Shouldly;
using System.Collections.Generic;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Core.Objects.Internal;

using Shouldly;

using Stove.Configuration;
using Stove.Domain.Repositories;
using Stove.Domain.Uow;
using Stove.Mapster;
using Stove.ObjectMapping;
using Stove.Tests.SampleApplication.Domain.Entities;
using Stove.Tests.SampleApplication.Dtos;
using Stove.Timing;

using Xunit;

Expand All @@ -24,5 +34,47 @@ public void auto_object_mapping_should_work()
personDto.ShouldNotBeNull();
personEntity.ShouldNotBeNull();
}

[Fact]
public void proxied_object_can_mapped_through_objectmapper_with_required_explicit_mapping()
{
Building(builder => { }).Ok();

The<IModuleConfigurations>().StoveMapster().Configuration.RequireExplicitMapping = true;

var mapper = The<IObjectMapper>();

using (IUnitOfWorkCompleteHandle uow = The<IUnitOfWorkManager>().Begin())
{
for (int i = 0; i < 10; i++)
{
User user = The<IRepository<User>>().Insert(new User()
{
CreationTime = Clock.Now,
Name = $"Oğuzhan{i}",
Surname = $"Soykan{i}",
Email = $"[email protected]{i}"
});

var userDto = mapper.Map<UserDto>(user);
userDto.ShouldNotBeNull();
}

uow.Complete();
}

using (IUnitOfWorkCompleteHandle uow = The<IUnitOfWorkManager>().Begin())
{
List<User> users = The<IRepository<User>>().GetAllList();

users.ForEach(user =>
{
var userDto = mapper.Map<UserDto>(user);
userDto.ShouldNotBeNull();
});

uow.Complete();
}
}
}
}
3 changes: 3 additions & 0 deletions test/Stove.Tests.SampleApplication/Domain/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

using Stove.Domain.Entities;
using Stove.Domain.Entities.Auditing;
using Stove.Mapster;
using Stove.Tests.SampleApplication.Dtos;

namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table(nameof(User))]
[AutoMapFrom(typeof(UserDto))]
public class User : AggregateRoot, IHasCreationTime
{
[Required]
Expand Down
15 changes: 15 additions & 0 deletions test/Stove.Tests.SampleApplication/Dtos/UserDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace Stove.Tests.SampleApplication.Dtos
{
public class UserDto
{
public virtual string Name { get; set; }

public virtual string Surname { get; set; }

public virtual string Email { get; set; }

public virtual DateTime CreationTime { get; set; }
}
}

0 comments on commit 60122be

Please sign in to comment.