public async Task Validate_Recipient_ValidatesProperty(string value, bool isValid) { // Arrange const string propertyName = "Notifications[0]." + nameof(DataAvailableNotificationDto.Recipient); var target = new InsertDataAvailableNotificationsCommandRuleSet(); var dto = new DataAvailableNotificationDto( ValidUuid, value, ValidContentType, ValidOrigin, false, ValidWeight, ValidSequenceNumber, ValidDocumentType); // Act var items = new[] { dto }; var result = await target.ValidateAsync(new InsertDataAvailableNotificationsCommand(items)).ConfigureAwait(false); // Assert if (isValid) { Assert.True(result.IsValid); Assert.DoesNotContain(propertyName, result.Errors.Select(x => x.PropertyName)); } else { Assert.False(result.IsValid); Assert.Contains(propertyName, result.Errors.Select(x => x.PropertyName)); } }
public async Task Validate_NullNotifications_ValidatesProperty() { // Arrange const string propertyName = nameof(InsertDataAvailableNotificationsCommand.Notifications); var target = new InsertDataAvailableNotificationsCommandRuleSet(); var command = new InsertDataAvailableNotificationsCommand(null !); // Act var result = await target.ValidateAsync(command).ConfigureAwait(false); // Assert Assert.False(result.IsValid); Assert.Contains(propertyName, result.Errors.Select(x => x.PropertyName)); }