import source from 1.3.40
[external/swig.git] / Examples / test-suite / csharp / li_attribute_runme.cs
1 // Ported from Python li_attribute_runme.py
2
3 using System;
4 using li_attributeNamespace;
5
6 public class li_attribute_runme {
7
8   public static void Main() {
9                 A aa = new A(1,2,3);
10
11                 if (aa.a != 1)
12                         throw new ApplicationException("error");
13                 aa.a = 3;
14                 if (aa.a != 3)
15                         throw new ApplicationException("error");
16
17                 if (aa.b != 2)
18                         throw new ApplicationException("error");
19                 aa.b = 5;
20                 if (aa.b != 5)
21                         throw new ApplicationException("error");
22
23                 if (aa.d != aa.b)
24                         throw new ApplicationException("error");
25
26                 if (aa.c != 3)
27                         throw new ApplicationException("error");
28                 //aa.c = 5;
29                 //if (aa.c != 3)
30                 //  throw new ApplicationException("error");
31
32                 Param_i pi = new Param_i(7);
33                 if (pi.value != 7)
34                         throw new ApplicationException("error");
35
36                 pi.value=3;
37                 if (pi.value != 3)
38                         throw new ApplicationException("error");
39
40                 B b = new B(aa);
41
42                 if (b.a.c != 3)
43                         throw new ApplicationException("error");
44
45                 // class/struct attribute with get/set methods using return/pass by reference
46                 MyFoo myFoo = new MyFoo();
47                 myFoo.x = 8;
48                 MyClass myClass = new MyClass();
49                 myClass.Foo = myFoo;
50                 if (myClass.Foo.x != 8)
51                         throw new ApplicationException("error");
52
53                 // class/struct attribute with get/set methods using return/pass by value
54                 MyClassVal myClassVal = new MyClassVal();
55                 if (myClassVal.ReadWriteFoo.x != -1)
56                         throw new ApplicationException("error");
57                 if (myClassVal.ReadOnlyFoo.x != -1)
58                         throw new ApplicationException("error");
59                 myClassVal.ReadWriteFoo = myFoo;
60                 if (myClassVal.ReadWriteFoo.x != 8)
61                         throw new ApplicationException("error");
62                 if (myClassVal.ReadOnlyFoo.x != 8)
63                         throw new ApplicationException("error");
64
65     // string attribute with get/set methods using return/pass by value
66                 MyStringyClass myStringClass = new MyStringyClass("initial string");
67                 if (myStringClass.ReadWriteString != "initial string")
68                         throw new ApplicationException("error");
69                 if (myStringClass.ReadOnlyString != "initial string")
70                         throw new ApplicationException("error");
71                 myStringClass.ReadWriteString = "changed string";
72                 if (myStringClass.ReadWriteString != "changed string")
73                         throw new ApplicationException("error");
74                 if (myStringClass.ReadOnlyString != "changed string")
75                         throw new ApplicationException("error");
76   }
77 }
78