public void TestSimpleUnion() { TestUnion arg = new TestUnion(); short case0Val = 11; arg.Setval0(case0Val); TestUnion result = m_testService.EchoTestUnion(arg); Assert.AreEqual(case0Val, result.Getval0()); Assert.AreEqual(0, result.Discriminator); TestUnion arg2 = new TestUnion(); int case1Val = 12; arg2.Setval1(case1Val, 2); TestUnion result2 = m_testService.EchoTestUnion(arg2); Assert.AreEqual(case1Val, result2.Getval1()); Assert.AreEqual(2, result2.Discriminator); TestUnion arg3 = new TestUnion(); bool case2Val = true; arg3.Setval2(case2Val, 7); TestUnion result3 = m_testService.EchoTestUnion(arg3); Assert.AreEqual(case2Val, result3.Getval2()); Assert.AreEqual(7, result3.Discriminator); }
public void TestPassingUnionsAsAny() { TestUnion arg = new TestUnion(); short case0Val = 11; arg.Setval0(case0Val); TestUnion result = (TestUnion)m_testService.EchoAny(arg); Assert.AreEqual(case0Val, result.Getval0()); Assert.AreEqual(0, result.Discriminator); TestUnionE arg2 = new TestUnionE(); TestEnumForU case1Val = TestEnumForU.A; arg2.SetvalE1(case1Val, TestEnumForU.B); TestUnionE result2 = (TestUnionE)m_testService.EchoAny(arg2); Assert.AreEqual(case1Val, result2.GetvalE1()); Assert.AreEqual(TestEnumForU.B, result2.Discriminator); }
public void TestUnionExceptions() { try { TestUnion arg = new TestUnion(); arg.Getval0(); Assert.Fail("exception not thrown for getting value from non-initalized union"); } catch (omg.org.CORBA.BAD_OPERATION) { } try { TestUnion arg = new TestUnion(); arg.Setval0(11); arg.Getval1(); Assert.Fail("exception not thrown for getting value from non-initalized union"); } catch (omg.org.CORBA.BAD_OPERATION) { } try { TestUnion arg1 = new TestUnion(); arg1.Setval1(11, 7); Assert.Fail("exception not thrown on wrong discriminator value."); } catch (omg.org.CORBA.BAD_PARAM) { } try { TestUnion arg2 = new TestUnion(); arg2.Setval2(false, 0); Assert.Fail("exception not thrown on wrong discriminator value."); } catch (omg.org.CORBA.BAD_PARAM) { } }