-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…endpoint Feature/#39 implement client endpoint
- Loading branch information
Showing
34 changed files
with
1,166 additions
and
2,125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2,093 changes: 0 additions & 2,093 deletions
2,093
src/Evelyn.Client.Rest/Generated/OpenApiClasses.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateAddedSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents | ||
{ | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Evelyn.Core.ReadModel.Projections.ClientEnvironmentState; | ||
using Evelyn.Core.WriteModel.Project.Events; | ||
using FluentAssertions; | ||
using NSubstitute; | ||
using TestStack.BDDfy; | ||
using Xunit; | ||
|
||
public class EnvironmentStateAddedSpecs : ProjectionBuilderHarness<EnvironmentStateAdded> | ||
{ | ||
[Fact] | ||
public void Nominal() | ||
{ | ||
this.Given(_ => GivenThereIsNoProjection()) | ||
.When(_ => WhenWeHandleAnEnvironmentStateAddedEvent()) | ||
.Then(_ => ThenTheProjectionAuditIsSet()) | ||
.And(_ => ThenTheProjectionContainsTheEnvironmentState()) | ||
.BDDfy(); | ||
} | ||
|
||
protected override async Task HandleEventImplementation() | ||
{ | ||
await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); | ||
} | ||
|
||
private async Task WhenWeHandleAnEnvironmentStateAddedEvent() | ||
{ | ||
Event = DataFixture.Build<EnvironmentStateAdded>() | ||
.With(ar => ar.Id, ProjectId) | ||
.With(esa => esa.EnvironmentKey, EnvironmentKey) | ||
.Create(); | ||
|
||
await WhenTheEventIsHandled(); | ||
} | ||
|
||
private void ThenTheProjectionContainsTheEnvironmentState() | ||
{ | ||
ProjectionStore.Received().Create(Projection.StoreKey(ProjectId, EnvironmentKey), UpdatedProjection); | ||
|
||
UpdatedProjection.EnvironmentState.ToggleStates.Should().BeEquivalentTo(Event.ToggleStates); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...eadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateDeletedSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents | ||
{ | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Evelyn.Core.ReadModel.Projections.ClientEnvironmentState; | ||
using Evelyn.Core.WriteModel.Project.Events; | ||
using NSubstitute; | ||
using TestStack.BDDfy; | ||
using Xunit; | ||
|
||
public class EnvironmentStateDeletedSpecs : ProjectionBuilderHarness<EnvironmentStateDeleted> | ||
{ | ||
[Fact] | ||
public void Nominal() | ||
{ | ||
this.Given(_ => GivenTheProjectionExists()) | ||
.When(_ => WhenWeHandleAnEnvironmentStateDeletedEvent()) | ||
.Then(_ => ThenTheProjectionIsDeleted()) | ||
.BDDfy(); | ||
} | ||
|
||
protected override async Task HandleEventImplementation() | ||
{ | ||
await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); | ||
} | ||
|
||
private async Task WhenWeHandleAnEnvironmentStateDeletedEvent() | ||
{ | ||
Event = DataFixture.Build<EnvironmentStateDeleted>() | ||
.With(pc => pc.Id, ProjectId) | ||
.With(pc => pc.EnvironmentKey, EnvironmentKey) | ||
.Create(); | ||
|
||
await WhenTheEventIsHandled(); | ||
} | ||
|
||
private void ThenTheProjectionIsDeleted() | ||
{ | ||
ProjectionStore.Received().Delete(Projection.StoreKey(ProjectId, EnvironmentKey)); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateAddedSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents | ||
{ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Evelyn.Core.WriteModel.Project.Events; | ||
using FluentAssertions; | ||
using TestStack.BDDfy; | ||
using Xunit; | ||
using Projections = Evelyn.Core.ReadModel.Projections; | ||
|
||
public class ToggleStateAddedSpecs : ProjectionBuilderHarness<ToggleStateAdded> | ||
{ | ||
[Fact] | ||
public void ProjectionDoesNotExist() | ||
{ | ||
this.Given(_ => GivenThereIsNoProjection()) | ||
.When(_ => WhenWeHandleAToggleStateAddedEvent()) | ||
.Then(_ => ThenAnExceptionIsThrown()) | ||
.BDDfy(); | ||
} | ||
|
||
[Fact] | ||
public void Nominal() | ||
{ | ||
this.Given(_ => GivenTheProjectionExists()) | ||
.And(_ => GivenTheProjectAlreadyHasAToggleState()) | ||
.When(_ => WhenWeHandleAToggleStateAddedEvent()) | ||
.Then(_ => ThenTheNewToggleStateIsAdded()) | ||
.And(_ => ThenTheProjectionAuditIsSet()) | ||
.BDDfy(); | ||
} | ||
|
||
protected override async Task HandleEventImplementation() | ||
{ | ||
await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); | ||
} | ||
|
||
private void GivenTheProjectAlreadyHasAToggleState() | ||
{ | ||
OriginalProjection.EnvironmentState.AddToggleState( | ||
DataFixture.Create<Projections.EventAudit>(), | ||
DataFixture.Create<string>(), | ||
DataFixture.Create<string>()); | ||
} | ||
|
||
private async Task WhenWeHandleAToggleStateAddedEvent() | ||
{ | ||
Event = DataFixture.Build<ToggleStateAdded>() | ||
.With(pc => pc.Id, ProjectId) | ||
.With(pc => pc.EnvironmentKey, EnvironmentKey) | ||
.Create(); | ||
|
||
await WhenTheEventIsHandled(); | ||
} | ||
|
||
private void ThenTheNewToggleStateIsAdded() | ||
{ | ||
var toggleStates = UpdatedProjection.EnvironmentState.ToggleStates.ToList(); | ||
toggleStates.Count.Should().Be(OriginalProjection.EnvironmentState.ToggleStates.Count() + 1); | ||
|
||
foreach (var toggleState in OriginalProjection.EnvironmentState.ToggleStates) | ||
{ | ||
toggleStates.Should().Contain(ts => | ||
ts.Key == toggleState.Key && | ||
ts.Value == toggleState.Value); | ||
} | ||
|
||
toggleStates.Should().Contain(ts => | ||
ts.Key == Event.ToggleKey && | ||
ts.Value == Event.Value); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...sts/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateChangedSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents | ||
{ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Evelyn.Core.WriteModel.Project.Events; | ||
using FluentAssertions; | ||
using TestStack.BDDfy; | ||
using Xunit; | ||
|
||
public class ToggleStateChangedSpecs : ProjectionBuilderHarness<ToggleStateChanged> | ||
{ | ||
[Fact] | ||
public void ProjectionDoesNotExist() | ||
{ | ||
this.Given(_ => GivenThereIsNoProjection()) | ||
.When(_ => WhenWeHandleAToggleStateChangedEvent()) | ||
.Then(_ => ThenAnExceptionIsThrown()) | ||
.BDDfy(); | ||
} | ||
|
||
[Fact] | ||
public void Nominal() | ||
{ | ||
this.Given(_ => GivenTheProjectionExists()) | ||
.And(_ => GivenOurToggleStateIsOnTheProjection()) | ||
.And(_ => GivenTheProjectionHasOtherToggleStates()) | ||
.When(_ => WhenWeHandleAToggleStateChangedEvent()) | ||
.Then(_ => ThenOurToggleStateIsChanged()) | ||
.And(_ => ThenTheProjectionAuditIsSet()) | ||
.BDDfy(); | ||
} | ||
|
||
protected override async Task HandleEventImplementation() | ||
{ | ||
await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); | ||
} | ||
|
||
private async Task WhenWeHandleAToggleStateChangedEvent() | ||
{ | ||
Event = DataFixture.Build<ToggleStateChanged>() | ||
.With(pc => pc.Id, ProjectId) | ||
.With(pc => pc.EnvironmentKey, EnvironmentKey) | ||
.With(pc => pc.ToggleKey, ToggleKey) | ||
.Create(); | ||
|
||
await WhenTheEventIsHandled(); | ||
} | ||
|
||
private void ThenOurToggleStateIsChanged() | ||
{ | ||
var updatedToggleStates = UpdatedProjection.EnvironmentState.ToggleStates.ToList(); | ||
updatedToggleStates.Count.Should().Be(OriginalProjection.EnvironmentState.ToggleStates.Count()); | ||
|
||
foreach (var originalToggleState in OriginalProjection.EnvironmentState.ToggleStates) | ||
{ | ||
var expectedToggleStateValue = | ||
(originalToggleState.Key == Event.ToggleKey) | ||
? Event.Value | ||
: originalToggleState.Value; | ||
|
||
updatedToggleStates.Should().Contain(ts => | ||
ts.Key == originalToggleState.Key && | ||
ts.Value == expectedToggleStateValue); | ||
} | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...sts/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateDeletedSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents | ||
{ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Evelyn.Core.WriteModel.Project.Events; | ||
using FluentAssertions; | ||
using TestStack.BDDfy; | ||
using Xunit; | ||
|
||
public class ToggleStateDeletedSpecs : ProjectionBuilderHarness<ToggleStateDeleted> | ||
{ | ||
[Fact] | ||
public void Nominal() | ||
{ | ||
this.Given(_ => GivenTheProjectionExists()) | ||
.And(_ => GivenOurToggleStateIsOnTheProjection()) | ||
.When(_ => WhenWeHandleAToggleStateDeletedEvent()) | ||
.Then(_ => ThenOurToggleStateIsRemoved()) | ||
.And(_ => ThenTheProjectionAuditIsSet()) | ||
.BDDfy(); | ||
} | ||
|
||
[Fact] | ||
public void ProjectionDoesNotExist() | ||
{ | ||
this.Given(_ => GivenThereIsNoProjection()) | ||
.When(_ => WhenWeHandleAToggleStateDeletedEvent()) | ||
.Then(_ => ThenAnExceptionIsThrown()) | ||
.BDDfy(); | ||
} | ||
|
||
protected override async Task HandleEventImplementation() | ||
{ | ||
await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); | ||
} | ||
|
||
private async Task WhenWeHandleAToggleStateDeletedEvent() | ||
{ | ||
Event = DataFixture.Build<ToggleStateDeleted>() | ||
.With(pc => pc.Id, ProjectId) | ||
.With(pc => pc.EnvironmentKey, EnvironmentKey) | ||
.With(pc => pc.ToggleKey, ToggleKey) | ||
.Create(); | ||
|
||
await WhenTheEventIsHandled(); | ||
} | ||
|
||
private void ThenOurToggleStateIsRemoved() | ||
{ | ||
var updatedToggleStates = UpdatedProjection.EnvironmentState.ToggleStates.ToList(); | ||
updatedToggleStates.Count.Should().Be(OriginalProjection.EnvironmentState.ToggleStates.Count() - 1); | ||
|
||
foreach (var originalToggleState in OriginalProjection.EnvironmentState.ToggleStates) | ||
{ | ||
if (originalToggleState.Key != Event.ToggleKey) | ||
{ | ||
updatedToggleStates.Should().Contain(ts => | ||
ts.Key == originalToggleState.Key && | ||
ts.Value == originalToggleState.Value); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.