public static Func <StrategyAssignedEvent> WhenExtractingEvent(
     this AssignIsLowerThanStrategyToFeatureCommand command,
     ISystemClock clock,
     IStrategySettingsSerializer serializer)
 {
     return(() => command.ExtractStrategyAssignedEvent(
                clock,
                serializer));
 }
Пример #2
0
        public static async Task ThenWePublish(
            this Func <Task> funk,
            Mock <IFeaturesAggregate> featuresAggregate,
            AssignIsLowerThanStrategyToFeatureCommand command)
        {
            await funk();

            featuresAggregate.Verify(_ => _.Publish(
                                         It.Is <StrategyAssignedEvent>(e => e.Name.Equals(
                                                                           command.Name,
                                                                           StringComparison.InvariantCultureIgnoreCase))),
                                     Times.Once);
        }
Пример #3
0
        public async Task GivenAValidCommand_WhenPublishingAFeature_ThenWePublishPathAndFeature()
        {
            var featuresAggregate = this.GivenIFeaturesAggregate();

            var command = new AssignIsLowerThanStrategyToFeatureCommand
            {
                AssignedBy = "meeee",
                Name       = "bob",
                Path       = "let/me/show/you",
                Value      = 09
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenWePublish(featuresAggregate, command);
        }
Пример #4
0
        public async Task GivenACommand_WhenPublishingAFeatureThatDoesNotExist_ThenWeDoNotThrow()
        {
            var featuresAggregate = this.GivenIFeaturesAggregate()
                                    .WithPublishing();

            var command = new AssignIsLowerThanStrategyToFeatureCommand
            {
                AssignedBy = "meeee",
                Name       = "bob",
                Path       = "let/me/show/you",
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenWePublish(featuresAggregate, command);
        }
Пример #5
0
        public async Task GivenACommand_WhenPublishingThrows_ThenWeThrow()
        {
            var featuresAggregate = this.GivenIFeaturesAggregate()
                                    .WithPublishingThrows <NotImplementedException>();

            var command = new AssignIsLowerThanStrategyToFeatureCommand
            {
                AssignedBy = "😎",
                Name       = "🌲/🦝",
                Value      = 91L
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenExceptionIsThrown <NotImplementedException>();
        }
Пример #6
0
        public async Task GivenAnInvalidCommand_WhenPublishingAFeature_ThenWeThrow()
        {
            var featuresAggregate = this
                                    .GivenIFeaturesAggregate()
                                    .WithPublishing();

            var command = new AssignIsLowerThanStrategyToFeatureCommand
            {
                AssignedBy = "😎",
                Path       = "🌲/🦝"
            };

            await this.GivenCommandHandler(featuresAggregate.Object)
            .WhenPublishingAFeature(command)
            .ThenExceptionIsThrown <ArgumentValidationException>();
        }
        public static void ThenWeGetAFeaturePublishedEvent(this Func <StrategyAssignedEvent> featFunc, AssignIsLowerThanStrategyToFeatureCommand 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.IsLowerThan);
            feat.Settings.Should().Be(JsonSerializer.Serialize(new NumericalStrategySettings()
            {
                Value = command.Value
            }));
        }
 public static Action WhenValidating(this AssignIsLowerThanStrategyToFeatureCommand command)
 {
     return(() => command.Validate());
 }
Пример #9
0
 public static Func <Task> WhenPublishingAFeature(
     this IHandleCommand <AssignIsLowerThanStrategyToFeatureCommand> handler,
     AssignIsLowerThanStrategyToFeatureCommand command)
 {
     return(() => handler.Handle(command));
 }