public async Task Should_not_add_error_if_tags_are_null_and_valid() { var sut = new TagsField(1, "my-tags", Partitioning.Invariant); await sut.ValidateAsync(CreateValue(null), errors); Assert.Empty(errors); }
public void Should_get_default_value_from_tags_field() { var field = new TagsField(1, "1", Partitioning.Invariant, new TagsFieldProperties()); Assert.Equal(new JArray(), DefaultValueFactory.CreateDefaultValue(field, Now)); }
public async Task Should_add_errors_if_value_is_not_valid() { var sut = new TagsField(1, "my-tags", Partitioning.Invariant); await sut.ValidateAsync("invalid", errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is not a valid value." }); }
/// <summary> /// Adds a field with the tags the log writer attached when writing the log message. /// </summary> /// <param name="jsonKey">Key of the field in the JSON document (null to use the default key).</param> public void AddTagsField(string jsonKey = null) { if (jsonKey == null) { jsonKey = JsonMessageFieldNames.Default.Tags; } var field = new TagsField(this, jsonKey); AppendField(field); }
public async Task Should_not_add_error_if_tags_are_valid() { var referenceId = Guid.NewGuid(); var sut = new TagsField(1, "my-tags", Partitioning.Invariant); await sut.ValidateAsync(CreateValue(referenceId), errors, ValidationTestExtensions.ValidContext); Assert.Empty(errors); }
public async Task Should_add_errors_if_value_has_not_enough_items() { var sut = new TagsField(1, "my-tags", Partitioning.Invariant, new TagsFieldProperties { MinItems = 3 }); await sut.ValidateAsync(CreateValue(Guid.NewGuid(), Guid.NewGuid()), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> must have at least 3 item(s)." }); }
public async Task Should_add_errors_if_tags_are_required_and_empty() { var sut = new TagsField(1, "my-tags", Partitioning.Invariant, new TagsFieldProperties { IsRequired = true }); await sut.ValidateAsync(CreateValue(), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is required." }); }
public JsonProperty Visit(TagsField field) { return(CreateProperty(field, jsonProperty => { var itemSchema = schemaResolver("TagsItem", new JsonSchema4 { Type = JsonObjectType.String }); jsonProperty.Type = JsonObjectType.Array; jsonProperty.Item = itemSchema; })); }
public void it_returns_full_build_field_2() { var tempBuildConfig = m_client.BuildConfigs.All().First(); ItemsField itemsField = ItemsField.WithFields(item: true); BuildsField buildsField = BuildsField.WithFields(); RelatedField relatedField = RelatedField.WithFields(builds: buildsField); RelatedIssuesField relatedIssuesField = RelatedIssuesField.WithFields(href: true); ArtifactDependenciesField artifactDependenciesField = ArtifactDependenciesField.WithFields(); BuildArtifactDependenciesField buildArtifactDependenciesField = BuildArtifactDependenciesField.WithFields(); BuildSnapshotDependenciesField buildSnapshotDependenciesField = BuildSnapshotDependenciesField.WithFields(); DatasField datasField = DatasField.WithFields(); StatisticsField statisticsField = StatisticsField.WithFields(); EntriesField entriesField = EntriesField.WithFields(); PropertiesField propertiesField = PropertiesField.WithFields(); ArtifactsField artifactsField = ArtifactsField.WithFields(href: true); ProblemOccurrencesField problemOccurrences = ProblemOccurrencesField.WithFields(); TestOccurrencesField testOccurrencesField = TestOccurrencesField.WithFields(); AgentField agentField = AgentField.WithFields(id: true); CompatibleAgentsField compatibleAgentsField = CompatibleAgentsField.WithFields(agent: agentField, href: true); BuildField buildField1 = BuildField.WithFields(id: true); BuildChangeField buildChangeField = BuildChangeField.WithFields(nextBuild: buildField1, prevBuild: buildField1); BuildChangesField buildChangesField = BuildChangesField.WithFields(buildChange: buildChangeField); RevisionField revisionField = RevisionField.WithFields(version: true); RevisionsField revisionsField = RevisionsField.WithFields(); LastChangesField lastChangesField = LastChangesField.WithFields(); ChangesField changesField = ChangesField.WithFields(); TriggeredField triggeredField = TriggeredField.WithFields(type: true); ProgressInfoField progressInfoField = ProgressInfoField.WithFields(currentStageText: true); TagsField tagsField = TagsField.WithFields(); UserField userField = UserField.WithFields(id: true); CommentField commentField = CommentField.WithFields(text: true); BuildTypeField buildTypeField = BuildTypeField.WithFields(id: true); BuildTypeWrapperField buildTypeWrapperField = BuildTypeWrapperField.WithFields(buildType: buildTypeField); LinkField linkField = LinkField.WithFields(type: true); LinksField linksField = LinksField.WithFields(link: linkField); var buildField = BuildField.WithFields(links: linksField, buildType: buildTypeField, comment: commentField, tags: tagsField, pinInfo: commentField, user: userField, running_info: progressInfoField, canceledInfo: commentField, triggered: triggeredField, lastChanges: lastChangesField, changes: changesField, revisions: revisionsField, versionedSettingsRevision: revisionField, artifactDependencyChanges: buildChangesField, agent: agentField, compatibleAgents: compatibleAgentsField, testOccurrences: testOccurrencesField, problemOccurrences: problemOccurrences, artifacts: artifactsField, properties: propertiesField, resultingProperties: propertiesField, attributes: entriesField, statistics: statisticsField, metadata: datasField, snapshotDependencies: buildSnapshotDependenciesField, artifactDependencies: buildArtifactDependenciesField, customArtifactDependencies: artifactDependenciesField, statusChangeComment: commentField, relatedIssues: relatedIssuesField, replacementIds: itemsField, related: relatedField); var tempBuild = m_client.Builds.LastBuildByBuildConfigId(tempBuildConfig.Id); var build = m_client.Builds.GetFields(buildField.ToString()).ById(tempBuild.Id); Assert.IsNotNull(build); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { object retVal = new Object(); if (reader.TokenType == JsonToken.StartObject) { TagsField instance = (TagsField)serializer.Deserialize(reader, typeof(TagsField)); if (instance.Id == null) { retVal = null; } else { retVal = instance; } } else if (reader.TokenType == JsonToken.StartArray) { retVal = serializer.Deserialize(reader, objectType); } return(retVal); }
public IEdmTypeReference Visit(TagsField field) { return(CreatePrimitive(EdmPrimitiveTypeKind.String, field)); }
public object Visit(TagsField field) { return(Value.ToObject <List <string> >()); }
public void Should_instantiate_field() { var sut = new TagsField(1, "my-tags", Partitioning.Invariant); Assert.Equal("my-tags", sut.Name); }