private async Task TestNonAuthenticatedOdooRpcCall <T>(OdooRpcCallTestParameters <T> testParams) { this.RpcClient.SessionInfo.Reset(); Assert.False(RpcClient.SessionInfo.IsLoggedIn); await Assert.ThrowsAsync( typeof(InvalidOperationException), () => testParams.ExecuteRpcCall() ); }
private async Task TestAuthenticatedOdooRpcCall <T>(OdooRpcCallTestParameters <T> testParams) { long userId = 1; var validatorCalled = false; this.JsonRpcClient.SetNextRequestValidator((req) => { validatorCalled = true; Assert.Equal("call", req.Method); var p = req.Params as OdooRpcRequest; Assert.NotNull(p); Assert.Equal("object", p.service); Assert.Equal("execute_kw", p.method); Assert.NotNull(p.context); Assert.Equal(this.ConnectionInfo.Database, p.args[0]); Assert.Equal(userId, p.args[1]); Assert.Equal(this.ConnectionInfo.Password, p.args[2]); Assert.Equal(testParams.Model, p.args[3]); Assert.Equal(testParams.Method, p.args[4]); Assert.IsAssignableFrom(typeof(object[]), p.args[5]); testParams.Validator(p); }); this.JsonRpcClient.SetNextResponse(testParams.TestResponse); RpcClient.SetUserId(userId); var result = await testParams.ExecuteRpcCall(); Assert.True(validatorCalled); Assert.True(this.JsonRpcClient.WasCalled); Assert.Equal(testParams.TestResponse.Result, result); }
private async Task TestOdooRpcCall <T>(OdooRpcCallTestParameters <T> testParams) { await TestNonAuthenticatedOdooRpcCall(testParams); await TestAuthenticatedOdooRpcCall(testParams); }