public async Task DeleteRelationships() { Field left = NewField(); Field right = NewField(); string relationshipOne = NewRandomString(); string relationshipTwo = NewRandomString(); AmendRelationshipRequest requestOne = NewAmendRelationshipRequest(_ => _.WithA(left) .WithB(right) .WithType(relationshipOne)); AmendRelationshipRequest requestTwo = NewAmendRelationshipRequest(_ => _.WithA(left) .WithB(right) .WithType(relationshipTwo)); await WhenTheRelationshipsAreDeleted <Model, ModelWithImmutableProperties>(requestOne, requestTwo); string expectedQueryOne = $"g.V().hasLabel('model').has('{GremlinName(left.Name)}', '{left.Value}').bothE('{GremlinName(relationshipOne)}')" + $".where(otherV().hasLabel('modelwithimmutableproperties').has('{GremlinName(right.Name)}', '{right.Value}')).drop()"; string expectedQueryTwo = $"g.V().hasLabel('model').has('{GremlinName(left.Name)}', '{left.Value}').bothE('{GremlinName(relationshipTwo)}')" + $".where(otherV().hasLabel('modelwithimmutableproperties').has('{GremlinName(right.Name)}', '{right.Value}')).drop()"; ThenTheGremlinQueryWasExecuted(expectedQueryOne); AndTheGremlinQueryWasExecuted(expectedQueryTwo); AndTheClientWasDisposed(); }
public async Task UpsertRelationships() { Field left = NewField(); Field right = NewField(); string relationshipOne = NewRandomString(); string relationshipTwo = NewRandomString(); AmendRelationshipRequest requestOne = NewAmendRelationshipRequest(_ => _.WithA(left) .WithB(right) .WithType(relationshipOne)); AmendRelationshipRequest requestTwo = NewAmendRelationshipRequest(_ => _.WithA(left) .WithB(right) .WithType(relationshipTwo)); await WhenTheRelationshipsAreUpserted <Model, ModelWithImmutableProperties>(requestOne, requestTwo); string expectedQueryOne = $"g.V().hasLabel('model').has('{GremlinName(left.Name)}', '{left.Value}').as('A')" + $".V().hasLabel('modelwithimmutableproperties').has('{GremlinName(right.Name)}', '{right.Value}')" + $".coalesce(__.inE('{GremlinName(relationshipOne)}').where(outV().as('A'))," + $"addE('{GremlinName(relationshipOne)}').from('A'))"; string expectedQueryTwo = $"g.V().hasLabel('model').has('{GremlinName(left.Name)}', '{left.Value}').as('A')" + $".V().hasLabel('modelwithimmutableproperties').has('{GremlinName(right.Name)}', '{right.Value}')" + $".coalesce(__.inE('{GremlinName(relationshipTwo)}').where(outV().as('A'))," + $"addE('{GremlinName(relationshipTwo)}').from('A'))"; ThenTheGremlinQueryWasExecuted(expectedQueryOne); AndTheGremlinQueryWasExecuted(expectedQueryTwo); }