diff --git a/appveyor.yml b/appveyor.yml index c21ba9d..5a87313 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,15 +7,4 @@ pull_requests: build_script: - ps: .\build.ps1 -experimental -test: off - -deploy: -- provider: NuGet - on: - branch: master - api_key: - secure: liSTqN52OJQy9fZJk6gubSgYBAy4EXcEPCDSCLJ/3T9cZufzpTwvBlGPLX+iP2n9 - -artifacts: -- path: nupkg\*.nupkg - name: nuget-packages +test: off \ No newline at end of file diff --git a/common.props b/common.props index 9ee3ea5..3e31449 100644 --- a/common.props +++ b/common.props @@ -1,6 +1,6 @@ - 1.1.1 + 1.1.2 $(NoWarn);CS1591 https://raw.githubusercontent.com/osoykan/Stove/master/stove.png https://github.com/osoykan/Stove diff --git a/src/Stove.EntityFramework/Stove.EntityFramework.csproj b/src/Stove.EntityFramework/Stove.EntityFramework.csproj index 797b587..e3831c1 100644 --- a/src/Stove.EntityFramework/Stove.EntityFramework.csproj +++ b/src/Stove.EntityFramework/Stove.EntityFramework.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/Stove.HangFire/Stove.HangFire.csproj b/src/Stove.HangFire/Stove.HangFire.csproj index 9f271a2..989d8b7 100644 --- a/src/Stove.HangFire/Stove.HangFire.csproj +++ b/src/Stove.HangFire/Stove.HangFire.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/src/Stove.Mapster/Stove.Mapster.csproj b/src/Stove.Mapster/Stove.Mapster.csproj index 8fd75b7..0061ae4 100644 --- a/src/Stove.Mapster/Stove.Mapster.csproj +++ b/src/Stove.Mapster/Stove.Mapster.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/Stove.NLog/Stove.NLog.csproj b/src/Stove.NLog/Stove.NLog.csproj index 77d7df7..c67b97c 100644 --- a/src/Stove.NLog/Stove.NLog.csproj +++ b/src/Stove.NLog/Stove.NLog.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/Stove.Redis/Stove.Redis.csproj b/src/Stove.Redis/Stove.Redis.csproj index 39aeec3..c4f4d95 100644 --- a/src/Stove.Redis/Stove.Redis.csproj +++ b/src/Stove.Redis/Stove.Redis.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/Stove/Domain/Entities/AggregateRoot.cs b/src/Stove/Domain/Entities/AggregateRoot.cs index 892f75d..8ead55c 100644 --- a/src/Stove/Domain/Entities/AggregateRoot.cs +++ b/src/Stove/Domain/Entities/AggregateRoot.cs @@ -8,17 +8,21 @@ namespace Stove.Domain.Entities { public class AggregateRoot : AggregateRoot, IAggregateRoot { - } public class AggregateRoot : Entity, IAggregateRoot { + public AggregateRoot() + { + DomainEvents = new Collection(); + } + [NotMapped] public virtual ICollection DomainEvents { get; } - public AggregateRoot() + protected void Raise(IEventData @event) { - DomainEvents = new Collection(); + DomainEvents.Add(@event); } } -} \ No newline at end of file +} diff --git a/src/Stove/Stove.csproj b/src/Stove/Stove.csproj index 62fa05e..c6e87d2 100644 --- a/src/Stove/Stove.csproj +++ b/src/Stove/Stove.csproj @@ -24,7 +24,7 @@ - + diff --git a/test/Stove.Tests.SampleApplication/AggregateRoot_Tests.cs b/test/Stove.Tests.SampleApplication/AggregateRoot_Tests.cs new file mode 100644 index 0000000..9552308 --- /dev/null +++ b/test/Stove.Tests.SampleApplication/AggregateRoot_Tests.cs @@ -0,0 +1,38 @@ +using Autofac.Extras.IocManager; + +using Stove.Domain.Repositories; +using Stove.Domain.Uow; +using Stove.Events.Bus.Handlers; +using Stove.Tests.SampleApplication.Domain.Entities; +using Stove.Tests.SampleApplication.Domain.Events; + +using Xunit; + +namespace Stove.Tests.SampleApplication +{ + public class AggregateRoot_Tests : SampleApplicationTestBase + { + public AggregateRoot_Tests() + { + Building(builder => { }).Ok(); + } + + [Fact] + public void AggreateRoot_event_should_raise_when_Added() + { + using (IUnitOfWorkCompleteHandle uow = The().Begin()) + { + The>().Insert(new Campaign("selam")); + uow.Complete(); + } + } + } + + public class CampaignCreatedEventHandler : IEventHandler, ITransientDependency + { + public void HandleEvent(CampaignCreatedEvent eventData) + { + string name = eventData.Name; + } + } +} diff --git a/test/Stove.Tests.SampleApplication/Domain/Entities/Campaign.cs b/test/Stove.Tests.SampleApplication/Domain/Entities/Campaign.cs new file mode 100644 index 0000000..09c6163 --- /dev/null +++ b/test/Stove.Tests.SampleApplication/Domain/Entities/Campaign.cs @@ -0,0 +1,17 @@ +using Stove.Domain.Entities; +using Stove.Tests.SampleApplication.Domain.Events; + +namespace Stove.Tests.SampleApplication.Domain.Entities +{ + public class Campaign : AggregateRoot + { + public Campaign(string name) + { + Name = name; + + Raise(new CampaignCreatedEvent { Name = Name }); + } + + public string Name { get; set; } + } +} diff --git a/test/Stove.Tests.SampleApplication/Domain/Events/CampaignCreatedEvent.cs b/test/Stove.Tests.SampleApplication/Domain/Events/CampaignCreatedEvent.cs new file mode 100644 index 0000000..8ec43b1 --- /dev/null +++ b/test/Stove.Tests.SampleApplication/Domain/Events/CampaignCreatedEvent.cs @@ -0,0 +1,9 @@ +using Stove.Events.Bus; + +namespace Stove.Tests.SampleApplication.Domain.Events +{ + public class CampaignCreatedEvent : EventData + { + public string Name { get; set; } + } +} diff --git a/test/Stove.Tests.SampleApplication/Domain/SampleApplicationDbContext.cs b/test/Stove.Tests.SampleApplication/Domain/SampleApplicationDbContext.cs index bcb5950..db777db 100644 --- a/test/Stove.Tests.SampleApplication/Domain/SampleApplicationDbContext.cs +++ b/test/Stove.Tests.SampleApplication/Domain/SampleApplicationDbContext.cs @@ -47,5 +47,7 @@ public SampleApplicationDbContext(DbConnection connection) public virtual IDbSet ProductDetails { get; set; } public virtual IDbSet Messages { get; set; } + + public virtual IDbSet Campaigns { get; set; } } }