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