Ejemplo n.º 1
0
    protected static void test(FeatureTest.Client conn)
    {
        conn.AssertServiceCompatibility();

        var eve = conn.Person.init("eve", null,	null);
        var adam = conn.Person.init("adam", null, null);
        eve.marry(adam);
        var cain = conn.Person.init("cain", adam, eve);
        if (cain.name != "cain") {
            throw new Exception("cain is not the name");
        }

        bool succ = true;
        try {
            adam.marry(eve);
        } catch (FeatureTest.MartialStatusError) {
            // okay
            succ = false;
        }

        if (succ) {
            throw new Exception("an exception should have been thrown!");
        }

        double thought = adam.think(17, 3.0);
        if (thought != (17/3.0)) {
            throw new Exception("adam thinks wrong: " + thought);
        }

        try {
            adam.think(17, 0);
        } catch (Agnos.GenericException) {
            // okay
        }

        var info = conn.GetServiceInfo(Agnos.Protocol.INFO_SERVICE);
        if ((String)info["SERVICE_NAME"] != "FeatureTest") {
            throw new Exception("wrong service name: " + info["SERVICE_NAME"]);
        }

        info = conn.GetServiceInfo(Agnos.Protocol.INFO_FUNCTIONS);
        foreach (DictionaryEntry e in info) {
            System.Console.WriteLine("{0} = {1}", e.Key, e.Value);
        }

        byte[] barr = {(byte)0xff, (byte)0xee, (byte)0xaa, (byte)0xbb};
        IList<double> lst = new List<double>();
        lst.Add(1.3);
        lst.Add(FeatureTest.pi);
        lst.Add(4.4);
        ICollection<int> hs = new HashSet<int>();
        hs.Add(18);
        hs.Add(19);
        hs.Add(20);
        IDictionary<int, string> hm = new Dictionary<int, string>();
        hm[34] = "foo";
        hm[56] = "bar";
        FeatureTest.Address adr = new FeatureTest.Address(FeatureTest.State.NY, "albany", "foobar drive", 1772);

        FeatureTest.Everything everything = conn.func_of_everything(
                (byte)1, (short)2, 3, (long)4, 5.5, true, new DateTime(), barr,
                "hello world", lst, hs, hm, adr, eve, FeatureTest.MyEnum.C);

        if (everything.some_int32 != 3) {
            throw new Exception("expected 'some_int32' to be 3" + everything.some_int32);
        }

        HeteroMap hm1 = new HeteroMap();
        hm1["x"] = "y";
        HeteroMap hm2 = conn.hmap_test(1999, hm1);
        if ((int)hm2["a"] != 1999) {
            throw new Exception("expected 'a' to be 1999; " + hm2["a"]);
        }

        System.Console.WriteLine("test passed!");
    }
Ejemplo n.º 2
0
        public Person(string name, FeatureTest.IPerson father,
				FeatureTest.IPerson mother)
        {
            this._name = name;
            this._father = (Person) father;
            this._mother = (Person) mother;
            this._address = new FeatureTest.Address(
                    FeatureTest.State.TX, "nashville", "woldorf", 1772);
            this._date_of_birth = new DateTime();
        }
Ejemplo n.º 3
0
 // methods
 public void marry(FeatureTest.IPerson partner)
 {
     if (spouse != null) {
         throw new FeatureTest.MartialStatusError(
                 "already married", this);
     }
     if (partner.spouse != null) {
         throw new FeatureTest.MartialStatusError(
                 "already married", partner);
     }
     if ((mother != null && mother == partner.mother)
             || (father != null && father == partner.father)) {
         throw new FeatureTest.MartialStatusError(
                 "siblings cannot marry", partner);
     }
     _spouse = (Person) partner;
     _spouse._spouse = this;
 }
Ejemplo n.º 4
0
        public FeatureTest.IPerson Person_init(string name,
				FeatureTest.IPerson father,
				FeatureTest.IPerson mother)
        {
            return new Person(name, father, mother);
        }
Ejemplo n.º 5
0
        public FeatureTest.Everything func_of_everything(Byte a,
				short b, int c, long d, double e, bool f, DateTime g,
				byte[] h, string i, IList<double> j, ICollection<int> k, IDictionary<int, string> l,
				FeatureTest.Address m, FeatureTest.IPerson n, FeatureTest.MyEnum o)
        {
            return new FeatureTest.Everything(a, b, c, d, e, f, g, h,
                    i, j, k, l, m, n);
        }
Ejemplo n.º 6
0
        public void BasicRpcStsTokenConnectionsTest()
        {
            if (FeatureTest.RoleArn.Equals("FakeRoleArn"))
            {
                return;
            }

            var basciCredential =
                new BasicSessionCredentials(FeatureTest.BasicAccessKeyId, FeatureTest.BasicAccessKeySecret, FeatureTest.GetToken());
            var profile = DefaultProfile.GetProfile(FeatureTest.RegionId, FeatureTest.BasicAccessKeyId, FeatureTest.BasicAccessKeySecret);
            var client  = new DefaultAcsClient(profile, basciCredential);

            var request  = new DescribeAccessControlListsRequest();
            var response = client.GetAcsResponse(request);

            Assert.NotNull(response);
        }
Ejemplo n.º 7
0
        public void BasicRoaTokenConnection()
        {
            if (FeatureTest.RoleArn.Equals("FakeRoleArn"))
            {
                return;
            }

            var basciCredential =
                new BasicSessionCredentials(FeatureTest.BasicAccessKeyId, FeatureTest.BasicAccessKeySecret, FeatureTest.GetToken());
            var profile = DefaultProfile.GetProfile(FeatureTest.RegionId, FeatureTest.BasicAccessKeyId, FeatureTest.BasicAccessKeySecret);
            var client  = new DefaultAcsClient(profile, basciCredential);

            var request = new CommonRequest();

            request.Domain     = "ros.aliyuncs.com";
            request.Version    = "2015-09-01";
            request.Action     = "DescribeResourceTypes";
            request.UriPattern = "/resource_types";
            request.Method     = MethodType.GET;

            var response = client.GetCommonResponse(request);

            Assert.Equal(200, response.HttpStatus);
            Assert.NotNull(response.Data);
        }
Ejemplo n.º 8
0
        public void UnicodeAndQueryTest()
        {
            if (FeatureTest.RoleArn.Equals("FakeRoleArn"))
            {
                return;
            }

            var basciCredential =
                new BasicSessionCredentials(FeatureTest.BasicAccessKeyId, FeatureTest.BasicAccessKeySecret, FeatureTest.GetToken());
            var profile = DefaultProfile.GetProfile(FeatureTest.RegionId, FeatureTest.BasicAccessKeyId, FeatureTest.BasicAccessKeySecret);
            var client  = new DefaultAcsClient(profile, basciCredential);

            var request = new CommonRequest();

            request.TimeoutInMilliSeconds = 30000;
            request.Domain     = "ros.aliyuncs.com";
            request.Version    = "2015-09-01";
            request.Action     = "DescribeResourceTypes";
            request.UriPattern = "/resource_types";
            request.Method     = MethodType.GET;
            request.QueryParameters.Add("testParams", "SDFSDFSAetTEWTEWQO(∩_∩)O哈哈~");

            var response = client.GetCommonResponse(request);

            Assert.Equal(200, response.HttpStatus);
            Assert.NotNull(response.Data);
        }