Closed oliverjanik closed 7 years ago
Hi Oliver, hope you're doing well.
I don't think it's a good idea to open them up for the following reasons:
TermType
, Args
, OptArgs
.R.Db("test").Table("foo") != R.Db("test").Table("foo")
What you are looking to do can be achieved in an alternative way using query.ToRawString
. Using the query serialization feature solves all the problems outlined above.
[Test]
public async Task can_test_using_mock()
{
var expectedQuery = R.Db(DbName).Table(TableName).ToRawString();
var testQuery = R.Db(DbName).Table(TableName);
var conn = A.Fake<IConnection>();
await testQuery.RunAtomAsync<Result>(conn);
A.CallTo(() =>
conn.RunAtomAsync<Result>(
A<ReqlAst>.That.Matches(test =>
ReqlRaw.ToRawString(test) == expectedQuery),
A<object>._,
A<CancellationToken>._))
.MustHaveHappened();
}
Hope that helps! :+1:
Thanks, Brian
:beach_umbrella: :trumpet: Beach Boys - Good Vibrations (Nick Warren bootleg)
Hmm, the string comparison will work for me I think.
I'm setting up some unit tests that make sure I'm assembling the queries to the DB correctly.
For that purpose I've set up a mock for IConnection, which can intercept calls to conn.Run* methods.
Here's an example:
I was about to test the ReqlAst where the ... is in the above examples but I can't access TermType, Arguments or OptArgs. They're all protected internal?
Any change you can make them public or otherwise accessible to tests?