public void TestFunctions() { r.f1(); r.f2(247); bool thrown1 = false; try { r.err_func(); } catch (InvalidOperationException) { thrown1 = true; } RRAssert.IsTrue(thrown1); bool thrown2 = false; try { r.err_func2(); } catch (com.robotraconteur.testing.TestService5.asynctestexp) { thrown2 = true; } RRAssert.IsTrue(thrown2); }
public void TestProperties() { RRAssert.AreEqual(r.d1, 8.5515); r.d1 = 3.0819; bool thrown1 = false; try { var res = r.err; } catch (ArgumentException err) { thrown1 = true; RRAssert.AreEqual(err.Message, "Test message 1"); } RRAssert.IsTrue(thrown1); bool thrown2 = false; try { r.err = 10; } catch (InvalidOperationException err) { thrown2 = true; RRAssert.AreEqual(err.Message, ""); } RRAssert.IsTrue(thrown2); }
public uint NextDist(uint min_, uint max_) { RRAssert.IsTrue(max_ > min_); uint lfsr2 = lfsr_next(); return((lfsr2 % ((max_ - min_) + 1)) + min_); }
private void TestExceptionParams() { bool exp1_caught = false; try { r.test_exception_params1(); } catch (InvalidOperationException exp) { exp1_caught = true; RRAssert.AreEqual(exp.Message, "test error"); RRAssert.AreEqual((string)exp.Data["ErrorSubName"], "my_error"); RRAssert.AreNotEqual(exp.Data["ErrorParam"], null); var param_map = (Dictionary <string, object>)(exp.Data["ErrorParam"]); RRAssert.AreEqual(param_map.Count, 2); RRAssert.AreEqual(((int[])param_map["param1"])[0], 10); RRAssert.AreEqual((string)param_map["param2"], "20"); } RRAssert.IsTrue(exp1_caught); bool exp2_caught = false; try { r.test_exception_params2(); } catch (com.robotraconteur.testing.TestService3.test_exception4 exp) { exp2_caught = true; RRAssert.AreEqual(exp.Message, "test error2"); RRAssert.AreEqual((string)exp.ErrorSubName, "my_error2"); RRAssert.AreNotEqual(exp.ErrorParam, null); var param_map = (Dictionary <string, object>)(exp.ErrorParam); RRAssert.AreEqual(param_map.Count, 2); RRAssert.AreEqual(((int[])param_map["param1"])[0], 30); RRAssert.AreEqual((string)param_map["param2"], "40"); } RRAssert.IsTrue(exp2_caught); }