Skip to content

Commit

Permalink
null refs have "cause"
Browse files Browse the repository at this point in the history
  • Loading branch information
freels committed Jan 11, 2024
1 parent 585cbc9 commit 5e45036
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Fauna.Test/Serialization/Deserializer.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ public void DeserializeNullRef()
""id"":""123"",
""coll"":{""@mod"":""MyColl""},
""exists"":false,
""reason"":""not found""
""cause"":""not found""
}
}";

var actual = Deserialize<NullDocumentRef>(given);
Assert.AreEqual("123", actual.Id);
Assert.AreEqual(new Module("MyColl"), actual.Collection);
Assert.AreEqual("not found", actual.Reason);
Assert.AreEqual("not found", actual.Cause);
}

[Test]
Expand Down Expand Up @@ -263,14 +263,14 @@ public void DeserializeNullNamedRef()
""name"":""RefName"",
""coll"":{""@mod"":""MyColl""},
""exists"":false,
""reason"":""not found""
""cause"":""not found""
}
}";

var actual = Deserialize<NullNamedDocumentRef>(given);
Assert.AreEqual("RefName", actual.Name);
Assert.AreEqual(new Module("MyColl"), actual.Collection);
Assert.AreEqual("not found", actual.Reason);
Assert.AreEqual("not found", actual.Cause);
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions Fauna.Test/Types/NullDocumentRef.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class NullDocumentRefTests
{

[Test]
public void ReasonDefaultTest()
public void CauseDefaultTest()
{
var doc = new NullDocumentRef();
Assert.IsNull(doc.Reason);
Assert.IsNull(doc.Cause);
}
}
}
6 changes: 3 additions & 3 deletions Fauna.Test/Types/NullNamedDocumentRef.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class NullNamedDocumentRefTests
{

[Test]
public void ExistsAndReasonDefaultTest()
public void ExistsAndCauseDefaultTest()
{
var doc = new NullNamedDocumentRef();
Assert.IsNull(doc.Reason);
Assert.IsNull(doc.Cause);
}
}
}
12 changes: 6 additions & 6 deletions Fauna/Serialization/Deserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static T Deserialize<T>(SerializationContext context, ref Utf8FaunaReader
string? name = null;
Module? coll = null;
var exists = true;
string? reason = null;
string? cause = null;
var allProps = new Dictionary<string, object?>();


Expand Down Expand Up @@ -76,9 +76,9 @@ public static T Deserialize<T>(SerializationContext context, ref Utf8FaunaReader
exists = Deserialize<bool>(context, ref reader);
allProps["exists"] = exists;
break;
case "reason":
reason = Deserialize<string>(context, ref reader);
allProps["reason"] = reason;
case "cause":
cause = Deserialize<string>(context, ref reader);
allProps["cause"] = cause;
break;
default:
allProps[fieldName] = Deserialize(context, ref reader);
Expand Down Expand Up @@ -106,7 +106,7 @@ public static T Deserialize<T>(SerializationContext context, ref Utf8FaunaReader
{
Id = id,
Collection = coll,
Reason = reason
Cause = cause
};
}

Expand All @@ -125,7 +125,7 @@ public static T Deserialize<T>(SerializationContext context, ref Utf8FaunaReader
{
Name = name,
Collection = coll,
Reason = reason
Cause = cause
};
}

Expand Down
8 changes: 4 additions & 4 deletions Fauna/Types/NullDocumentRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ namespace Fauna.Types;
public class NullDocumentRef : DocumentRef
{
/// <summary>
/// Gets or sets the reason that the document is null.
/// Gets or sets the cause that the document is null.
/// </summary>
/// <value>
/// A string representing the reason that the document is null.
/// A string representing the cause that the document is null.
/// </value>
public string? Reason { get; set; } = null;
}
public string? Cause { get; set; } = null;
}
8 changes: 4 additions & 4 deletions Fauna/Types/NullNamedDocumentRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ namespace Fauna.Types;
public class NullNamedDocumentRef : NamedDocumentRef
{
/// <summary>
/// Gets or sets the reason that the document is null.
/// Gets or sets the cause that the document is null.
/// </summary>
/// <value>
/// A string representing the reason that the document is null.
/// A string representing the cause that the document is null.
/// </value>
public string? Reason { get; set; } = null;
}
public string? Cause { get; set; } = null;
}

0 comments on commit 5e45036

Please sign in to comment.