Beispiel #1
0
        public void Should_return_list_from_references_field_with_schema_id_for_referenced_ids_when_other_type()
        {
            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant,
                                          new ReferencesFieldProperties {
                SchemaId = schemaId
            });

            var result = sut.ExtractReferences("invalid").ToArray();

            Assert.Equal(new[] { schemaId }, result);
        }
Beispiel #2
0
        private static JToken Visit(ReferencesField field, JToken value, ICollection <Guid> oldReferences)
        {
            if (oldReferences.Contains(field.Properties.SchemaId))
            {
                return(new JArray());
            }

            var oldIds = field.ExtractReferences(value).ToList();
            var newIds = oldIds.Except(oldReferences).ToList();

            return(oldIds.Count != newIds.Count ? JToken.FromObject(newIds) : value);
        }
Beispiel #3
0
        public void Should_return_ids_from_references_field()
        {
            var id1 = Guid.NewGuid();
            var id2 = Guid.NewGuid();

            var sut = new ReferencesField(1, "my-refs", Partitioning.Invariant,
                                          new ReferencesFieldProperties {
                SchemaId = schemaId
            });

            var result = sut.ExtractReferences(CreateValue(id1, id2)).ToArray();

            Assert.Equal(new[] { id1, id2, schemaId }, result);
        }