public async Task MultiOf_Should_Execute_When_ParameterIsValid(int value) { var thing = new NumberActionThing(); var context = Factory.Create(thing, new ThingOption()); thing.ThingContext = context; context.Events.Should().BeEmpty(); context.Properties.Should().BeEmpty(); context.Actions.Should().NotBeEmpty(); context.Actions.Should().ContainKey(nameof(NumberActionThing.MultiOf)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""number"": {value} }} }} }}").GetProperty("action"); context.Actions[nameof(NumberActionThing.MultiOf)].TryAdd(jsonElement, out var info).Should().BeTrue(); info.Should().NotBeNull(); info.Status.Should().Be(ActionStatus.Created); await info.ExecuteAsync(thing, Provider).ConfigureAwait(false); info.Status.Should().Be(ActionStatus.Completed); thing.Number.Should().Be(value); }
public void NotAcceptedNullableValue_Should_ReturnError_When_ParameterIsNull() { var thing = new NumberActionThing(); var context = Factory.Create(thing, new ThingOption()); thing.ThingContext = context; context.Events.Should().BeEmpty(); context.Properties.Should().BeEmpty(); context.Actions.Should().NotBeEmpty(); context.Actions.Should().ContainKey(nameof(NumberActionThing.NotAcceptedNullableValue)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""number"": null }} }} }}").GetProperty("action"); context.Actions[nameof(NumberActionThing.NotAcceptedNullableValue)].TryAdd(jsonElement, out _).Should().BeFalse(); }
public void ExclusiveMinAndMax_Should_ReturnError_When_ParameterIsInvalid(int value) { var thing = new NumberActionThing(); var context = Factory.Create(thing, new ThingOption()); thing.ThingContext = context; context.Events.Should().BeEmpty(); context.Properties.Should().BeEmpty(); context.Actions.Should().NotBeEmpty(); context.Actions.Should().ContainKey(nameof(NumberActionThing.ExclusiveMinAndMax)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""number"": {value} }} }} }}").GetProperty("action"); context.Actions[nameof(NumberActionThing.ExclusiveMinAndMax)].TryAdd(jsonElement, out _).Should().BeFalse(); thing.Number.Should().NotBe(value); }