コード例 #1
0
ファイル: Tests.cs プロジェクト: cDoru/Amanda
        public static void Should_Verify_Simple_Params()
        {
            dynamic client = new AmandaClient("http://localhost:15534/api");

            Action doNothingForFactor = () => client.DoNothingFor(1, 2.5);

            doNothingForFactor.ShouldThrow <ArgumentException>();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Initialize an AmandaClient pointing to an Amanda webservice located at a given uri
            dynamic client = new AmandaClient("http://localhost:15534/api");

            // To call a method through the API, just call it as you would locally
            client.DoNothing();

            // Methods that take complex parameters can be given anonymous types with
            // the correct properties
            var res = client.SpliceUsers(new { ID = 1, Username = "******", Password = "******" },
                                         new { ID = 2, Username = "******", Password = "******" });

            // Returned results are either a simple type like int or string or an ExpandoObject
            // if the returned type is complex
            Console.WriteLine(res.ID);
            Console.WriteLine(res.Username);
            Console.WriteLine(res.Password);
        }
コード例 #3
0
ファイル: Tests.cs プロジェクト: cDoru/Amanda
        public static void Should_Succed_On_Exposed_Methods()
        {
            dynamic client = new AmandaClient("http://localhost:15534/api");

            var actions = new Action[]
            {
                () => client.DoNothing(),
                () => client.DoNothingFor(1),
                () => client.DoNothingForFactor(1.5, 2),
                () => client.GetWastedTime(),
                () => client.GetUsersUsername(new { ID = 1, Username = "******", Password = "******" }),
                () =>
                client.SpliceUsers(new { ID = 1, Username = "******", Password = "******" },
                                   new { ID = 2, Username = "******", Password = "******" })
            };

            foreach (var action in actions)
            {
                action.ShouldNotThrow();
            }
        }