public static Func <StrategyAssignedEvent> WhenExtractingEvent(
     this AssignIsBeforeStrategyToFeatureCommand command,
     ISystemClock clock,
     IStrategySettingsSerializer serializer)
 {
     return(() => command.ExtractStrategyAssignedEvent(
                clock,
                serializer));
 }
Exemplo n.º 2
0
        public static async Task ThenWePublish(
            this Func <Task> funk,
            Mock <IFeaturesAggregate> featuresAggregate,
            AssignIsBeforeStrategyToFeatureCommand command)
        {
            await funk();

            featuresAggregate.Verify(_ => _.Publish(
                                         It.Is <StrategyAssignedEvent>(e => e.Name.Equals(
                                                                           command.Name,
                                                                           StringComparison.InvariantCultureIgnoreCase))),
                                     Times.Once);
        }
Exemplo n.º 3
0
        public async Task GivenAValidCommand_WhenPublishingAFeature_ThenWePublishPathAndFeature()
        {
            var featuresAggregate = this.GivenIFeaturesAggregate();

            var command = new AssignIsBeforeStrategyToFeatureCommand
            {
                AssignedBy = "meeee",
                Name       = "bob",
                Path       = "let/me/show/you",
                Value      = this._clock.UtcNow
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenWePublish(featuresAggregate, command);
        }
Exemplo n.º 4
0
        public async Task GivenACommand_WhenPublishingThrows_ThenWeThrow()
        {
            var featuresAggregate = this.GivenIFeaturesAggregate()
                                    .WithPublishingThrows <NotImplementedException>();

            var command = new AssignIsBeforeStrategyToFeatureCommand
            {
                AssignedBy = "😎",
                Name       = "🌲/🦝",
                Value      = this._clock.UtcNow
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenExceptionIsThrown <NotImplementedException>();
        }
        public static void ThenWeGetAFeaturePublishedEvent(
            this Func <StrategyAssignedEvent> featFunc,
            AssignIsBeforeStrategyToFeatureCommand command,
            ISystemClock clock)
        {
            var feat = featFunc();

            feat.AssignedBy.Should().Be(command.AssignedBy);
            feat.AssignedOn.Should().Be(clock.UtcNow);
            feat.Name.Should().Be(command.Name);
            feat.Path.Should().Be(command.Path);
            feat.StrategyName.Should().Be(StrategyNames.IsBefore);
            feat.Settings.Should().Be(JsonSerializer.Serialize(new DateTimeOffsetStrategySettings
            {
                Value = clock.UtcNow
            }));
        }
Exemplo n.º 6
0
        public async Task GivenAnInvalidCommand_WhenPublishingAFeature_ThenWeThrow()
        {
            var featuresAggregate = this
                                    .GivenIFeaturesAggregate()
                                    .WithPublishing();

            var command = new AssignIsBeforeStrategyToFeatureCommand
            {
                AssignedBy = "😎",
                Path       = "🌲/🦝",
                Value      = this._clock.UtcNow
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenExceptionIsThrown <ArgumentValidationException>();
        }
 public static Action WhenValidating(this AssignIsBeforeStrategyToFeatureCommand command)
 {
     return(() => command.Validate());
 }
Exemplo n.º 8
0
 public static Func <Task> WhenPublishingAFeature(
     this IHandleCommand <AssignIsBeforeStrategyToFeatureCommand> handler,
     AssignIsBeforeStrategyToFeatureCommand command)
 {
     return(() => handler.Handle(command));
 }