public async Task NotAcceptedNullableValue_Should_Execute_When_ParameterIsValid(string timeSpanString) { var value = TimeSpan.Parse(timeSpanString); var thing = new TimeSpanActionThing(); 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(TimeSpanActionThing.NotAcceptedNullableValue)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""value"": ""{value}"" }} }} }}").GetProperty("action"); context.Actions[nameof(TimeSpanActionThing.NotAcceptedNullableValue)].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 TimeSpanActionThing(); 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(TimeSpanActionThing.NotAcceptedNullableValue)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""value"": null }} }} }}").GetProperty("action"); context.Actions[nameof(TimeSpanActionThing.NotAcceptedNullableValue)].TryAdd(jsonElement, out _).Should().BeFalse(); }
public void Enum_Should_ReturnError_When_ParameterIsInvalid(string timeSpanString) { var value = TimeSpan.Parse(timeSpanString); var thing = new TimeSpanActionThing(); 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(TimeSpanActionThing.Enum)); var jsonElement = JsonSerializer.Deserialize <JsonElement>( $@"{{ ""action"": {{ ""input"": {{ ""value"": ""{value}"" }} }} }}").GetProperty("action"); context.Actions[nameof(TimeSpanActionThing.Enum)].TryAdd(jsonElement, out _).Should().BeFalse(); thing.Value.Should().NotBe(value); }