public static void ThenWeGetAFeaturePublishedEvent( this Func <StrategyUnAssignedEvent> featFunc, UnAssignStrategyCommand command, ISystemClock clock) { var feat = featFunc(); feat.UnassignedBy.Should().Be(command.UnassignedBy); feat.UnassignedOn.Should().Be(clock.UtcNow); feat.Name.Should().Be(command.Name); feat.Path.Should().Be(command.Path); feat.StrategyName.Should().Be(command.StrategyName); }
public static async Task ThenWePublish( this Func <Task> funk, Mock <IFeaturesAggregate> featuresAggregate, UnAssignStrategyCommand command) { await funk(); featuresAggregate.Verify(_ => _.Publish( It.Is <StrategyUnAssignedEvent>(e => e.Name.Equals( command.Name, StringComparison.InvariantCultureIgnoreCase))), Times.Once); }
public async Task GivenAValidCommand_WhenPublishingAFeature_ThenWePublishPathAndFeature() { var featuresAggregate = this.GivenIFeaturesAggregate(); var command = new UnAssignStrategyCommand { UnassignedBy = "meeee", Name = "bob", Path = "let/me/show/you", StrategyName = "yay", }; await this.GivenCommandHandler(featuresAggregate.Object) .WhenPublishingAFeature(command) .ThenWePublish(featuresAggregate, command); }
public async Task GivenACommand_WhenPublishingThrows_ThenWeThrow() { var featuresAggregate = this.GivenIFeaturesAggregate() .WithPublishingThrows <NotImplementedException>(); var command = new UnAssignStrategyCommand { UnassignedBy = "😎", Name = "🌲/🦝", StrategyName = "charlie is depressed", }; await this.GivenCommandHandler(featuresAggregate.Object) .WhenPublishingAFeature(command) .ThenExceptionIsThrown <NotImplementedException>(); }
public async Task GivenAnInvalidCommand_WhenPublishingAFeature_ThenWeThrow() { var featuresAggregate = this .GivenIFeaturesAggregate() .WithPublishing(); var command = new UnAssignStrategyCommand { UnassignedBy = "😎", Path = "🌲/🦝", StrategyName = "patate", }; await this.GivenCommandHandler(featuresAggregate.Object) .WhenPublishingAFeature(command) .ThenExceptionIsThrown <ArgumentValidationException>(); }
public static Func <StrategyUnAssignedEvent> WhenExtractingEvent( this UnAssignStrategyCommand command, ISystemClock clock) { return(() => command.ExtractStrategyUnassignedEvent(clock)); }
public static Action WhenValidating(this UnAssignStrategyCommand command) { return(() => command.Validate()); }
public static Func <Task> WhenPublishingAFeature( this IHandleCommand <UnAssignStrategyCommand> handler, UnAssignStrategyCommand command) { return(() => handler.Handle(command)); }