public async Task NonNullableValue_Should_Execute_When_ParameterIsValid() { var value = CreateValue(); var thing = new CharActionThing(); 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(CharActionThing.NonNullableValue)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""value"": ""{value}"" }} }} }}").GetProperty("action"); context.Actions[nameof(CharActionThing.NonNullableValue)].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.Value.Should().Be(value); }
public void NotAcceptedNullableValue_Should_ReturnError_When_ParameterIsNull() { var thing = new CharActionThing(); 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(CharActionThing.NotAcceptedNullableValue)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""value"": null }} }} }}").GetProperty("action"); context.Actions[nameof(CharActionThing.NotAcceptedNullableValue)].TryAdd(jsonElement, out _).Should().BeFalse(); }
public void Enum_Should_ReturnError_When_ParameterIsInvalid(char value) { var thing = new CharActionThing(); 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(CharActionThing.Enum)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""value"": ""{value}"" }} }} }}").GetProperty("action"); context.Actions[nameof(CharActionThing.Enum)].TryAdd(jsonElement, out _).Should().BeFalse(); thing.Value.Should().NotBe(value); }