public async Task GetValueAsync_Poco_ReturnsValue() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <Poco> rethinkDbValueBinder = PrepareRethinkDbValueBinder <Poco>(rethinkDbConnectionMock.Object); Poco value = (await rethinkDbValueBinder.GetValueAsync()) as Poco; Assert.NotNull(value); }
public async Task GetValueAsync_JObject_ReturnsValue() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <JObject> rethinkDbValueBinder = PrepareRethinkDbValueBinder <JObject>(rethinkDbConnectionMock.Object); JObject value = (await rethinkDbValueBinder.GetValueAsync()) as JObject; Assert.NotNull(value); }
public async Task GetValueAsync_Poco_RunsGetOnTable() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <Poco> rethinkDbValueBinder = PrepareRethinkDbValueBinder <Poco>(rethinkDbConnectionMock.Object); Poco value = (await rethinkDbValueBinder.GetValueAsync()) as Poco; rethinkDbConnectionMock.Verify(m => m.RunResultAsync <JObject>(It.Is <ReqlAst>(reql => GET_DOCUMENT_REQL_MATCH(reql)), It.IsAny <Object>(), It.IsAny <CancellationToken>()), Times.Once); }
public async Task GetValueAsync_String_ReturnsValue() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <String> rethinkDbValueBinder = PrepareRethinkDbValueBinder <String>(rethinkDbConnectionMock.Object); string value = (await rethinkDbValueBinder.GetValueAsync()) as String; Assert.NotNull(value); }
public async Task GetValueAsyncSetValueAsync_String_DoesNotUpdate() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <String> rethinkDbValueBinder = PrepareRethinkDbValueBinder <String>(rethinkDbConnectionMock.Object); String value = (await rethinkDbValueBinder.GetValueAsync()) as String; await rethinkDbValueBinder.SetValueAsync(DOCUMENT_PROPERTY_NEW_VALUE, default(CancellationToken)); rethinkDbConnectionMock.Verify(m => m.RunAsync <Object>(It.IsAny <ReqlAst>(), It.IsAny <Object>(), It.IsAny <CancellationToken>()), Times.Never); }
public async Task GetValueAsyncSetValueAsync_Poco_NoPropertyChange_DoesNotUpdate() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <Poco> rethinkDbValueBinder = PrepareRethinkDbValueBinder <Poco>(rethinkDbConnectionMock.Object); Poco value = (await rethinkDbValueBinder.GetValueAsync()) as Poco; await rethinkDbValueBinder.SetValueAsync(value, default(CancellationToken)); rethinkDbConnectionMock.Verify(m => m.RunAsync <Object>(It.IsAny <ReqlAst>(), It.IsAny <Object>(), It.IsAny <CancellationToken>()), Times.Never); }
public async Task GetValueAsyncSetValueAsync_Poco_PropertyChange_Updates() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <Poco> rethinkDbValueBinder = PrepareRethinkDbValueBinder <Poco>(rethinkDbConnectionMock.Object); Poco value = (await rethinkDbValueBinder.GetValueAsync()) as Poco; value.Property = DOCUMENT_PROPERTY_NEW_VALUE; await rethinkDbValueBinder.SetValueAsync(value, default(CancellationToken)); rethinkDbConnectionMock.Verify(m => m.RunAsync <Object>(It.Is <ReqlAst>(reql => UPDATE_DOCUMENT_REQL_MATCH(reql)), It.IsAny <Object>(), It.IsAny <CancellationToken>()), Times.Once); }
public async Task GetValueAsyncSetValueAsync_Poco_IdChange_ThrowsInvalidOperationException() { Mock <IConnection> rethinkDbConnectionMock = PrepareRethinkDbConnectionMock(); RethinkDbValueBinder <Poco> rethinkDbValueBinder = PrepareRethinkDbValueBinder <Poco>(rethinkDbConnectionMock.Object); Poco value = (await rethinkDbValueBinder.GetValueAsync()) as Poco; value.Id = OTHER_DOCUMENT_ID; InvalidOperationException invalidOperationException = await Assert.ThrowsAsync <InvalidOperationException>(() => rethinkDbValueBinder.SetValueAsync(value, default(CancellationToken))); Assert.Equal(UPDATE_ID_INVALID_OPERATION_EXCEPTION_MESSAGE, invalidOperationException.Message); }