You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSystem;usingMarten.Integration.Tests.TestsInfrasructure;usingSharpTestsEx;usingXunit;namespaceMarten.Integration.Tests.EventStore.Aggregate{publicclassTaskCreated{publicGuidTaskId{get;set;}publicstringDescription{get;set;}}publicclassTaskUpdated{publicGuidTaskId{get;set;}publicstringDescription{get;set;}}namespaceOldVersion{publicclassTask{publicGuidId{get;set;}publicstringDescription{get;set;}publicvoidApply(TaskCreated@event){Id=@event.TaskId;Description=@event.Description;}publicvoidApply(TaskUpdated@event){Description=@event.Description;}}}namespaceNewVersion{publicclassTask{publicGuidId{get;set;}publicstringDescription{get;set;}publicvoidApply(TaskCreated@event){Id=@event.TaskId;Description=$"New Logic: {@event.Description}";}publicvoidApply(TaskUpdated@event){Description=$"New Logic: {@event.Description}";}}}publicclassReaggregation:MartenTest{publicReaggregation():base(false){}publicIDocumentSessionCreateSessionWithInlineAggregationFor<TTask>()whereTTask:class,new(){returnbase.CreateSession(options =>{options.Events.AddEventTypes(new[]{typeof(TaskCreated),typeof(TaskUpdated)});//It's needed to manualy set that inline aggegation should be appliedoptions.Events.InlineProjections.AggregateStreamsWith<TTask>();});}[Fact]publicvoidGiven_When_Then(){vartaskId=Guid.NewGuid();varevents=newobject[]{newTaskCreated{TaskId=taskId,Description="Task 1"},newTaskUpdated{TaskId=taskId,Description="Task 1 Updated"},};OldVersion.TasktaskFromV1InlineAggregation;OldVersion.TasktaskFromV1OnlineAggregation;using(varsession=CreateSessionWithInlineAggregationFor<OldVersion.Task>()){//1. Publish eventssession.Events.StartStream<OldVersion.Task>(taskId,events);session.SaveChanges();taskFromV1InlineAggregation=session.Load<OldVersion.Task>(taskId);taskFromV1OnlineAggregation=session.Events.AggregateStream<OldVersion.Task>(taskId);}//2. Both inline and online aggregation for the same type should be the sametaskFromV1InlineAggregation.Description.Should().Be.EqualTo("Task 1 Updated");taskFromV1InlineAggregation.Description.Should().Be.EqualTo(taskFromV1OnlineAggregation.Description);//3. Simulate change to aggregation logicNewVersion.TasktaskFromV2InlineAggregation;NewVersion.TasktaskFromV2OnlineAggregation;using(varsession=CreateSessionWithInlineAggregationFor<NewVersion.Task>()){taskFromV2InlineAggregation=session.Load<NewVersion.Task>(taskId);taskFromV2OnlineAggregation=session.Events.AggregateStream<NewVersion.Task>(taskId);}//4. Inline aggregated snapshot won't change automaticallytaskFromV2InlineAggregation.Description.Should().Be.EqualTo(taskFromV1InlineAggregation.Description);taskFromV2InlineAggregation.Description.Should().Not.Be.EqualTo("New Logic: Task 1 Updated");//5. But online aggregation is being applied automaticallytaskFromV2OnlineAggregation.Description.Should().Not.Be.EqualTo(taskFromV1OnlineAggregation.Description);taskFromV2OnlineAggregation.Description.Should().Be.EqualTo("New Logic: Task 1 Updated");//6. Reagregationusing(varsession=CreateSessionWithInlineAggregationFor<NewVersion.Task>()){//7. Get online aggregation//8. Store manually online aggregation as inline aggregationsession.Store(taskFromV2OnlineAggregation);session.SaveChanges();vartaskFromV2AfterReaggregation=session.Load<NewVersion.Task>(taskId);taskFromV2AfterReaggregation.Description.Should().Not.Be.EqualTo(taskFromV1OnlineAggregation.Description);taskFromV2AfterReaggregation.Description.Should().Be.EqualTo(taskFromV2OnlineAggregation.Description);taskFromV2AfterReaggregation.Description.Should().Be.EqualTo("New Logic: Task 1 Updated");//9. Check if next event would be properly applied to inline aggregationsession.Events.Append(taskId,newTaskUpdated{TaskId=taskId,Description="Completely New text"});session.SaveChanges();vartaskFromV2NewInlineAggregation=session.Load<NewVersion.Task>(taskId);taskFromV2NewInlineAggregation.Description.Should().Be.EqualTo("New Logic: Completely New text");}}}}
results with compilation error for 4.0.0-alpha.4:
CS0104: 'Task' is an ambiguous reference between 'Marten.Integration.Tests.EventStore.Aggregate.OldVersion.Task' and 'System.Threading.Tasks.Task'
CS0104: 'Task' is an ambiguous reference between 'Marten.Integration.Tests.EventStore.Aggregate.OldVersion.Task' and 'System.Threading.Tasks.Task'
CS0104: 'Task' is an ambiguous reference between 'Marten.Integration.Tests.EventStore.Aggregate.OldVersion.Task' and 'System.Threading.Tasks.Task'
CS0104: 'Task' is an ambiguous reference between 'Marten.Integration.Tests.EventStore.Aggregate.OldVersion.Task' and 'System.Threading.Tasks.Task'
CS0161: 'UpdateTaskOperation.PostprocessAsync(DbDataReader, IList<Exception>, CancellationToken)': not all code paths return a value
CS0104: 'Task' is an ambiguous reference between 'Marten.Integration.Tests.EventStore.Aggregate.OldVersion.Task' and 'System.Threading.Tasks.Task'
CS0104: 'Task' is an ambiguous reference between 'Marten.Integration.Tests.EventStore.Aggregate.OldVersion.Task' and 'System.Threading.Tasks.Task'
Eventhough it's not the smartest to name class as Task I think that it's the common name in the codebase and it might be too big restriction for the users.
Having such code
results with compilation error for
4.0.0-alpha.4
:Eventhough it's not the smartest to name class as
Task
I think that it's the common name in the codebase and it might be too big restriction for the users.See more in the Gitter dicscussion: https://gitter.im/JasperFx/marten?at=5fcbe8214b6e8f2d3c7f9051
The text was updated successfully, but these errors were encountered: