public void Test()
        {
            string root   = System.IO.Path.GetDirectoryName(Environment.CurrentDirectory);
            string token  = System.Environment.GetEnvironmentVariable("SACLOUD_TOKEN");
            string secret = System.Environment.GetEnvironmentVariable("SACLOUD_SECRET");
            string zone   = System.Environment.GetEnvironmentVariable("SACLOUD_ZONE");
            API    api    = API.Authorize(token, secret, zone);


            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // should be CRUDed
            {
                string name        = "!cs_nunit-" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "-" + (new Regex(@"-.+")).Replace(System.Guid.NewGuid().ToString(), "");
                string description = "This instance was created by saklient.cs NUnit";

                //
                Console.WriteLine("スイッチを作成しています...");
                Swytch swytch = api.Swytch.Create();
                swytch.Name        = name;
                swytch.Description = description;
                swytch.Save();
                Assert.Greater(Convert.ToInt64(swytch.Id), 0);

                //
                Console.WriteLine("サーバを作成しています...");
                Server server = api.Server.Create();
                server.Name        = name;
                server.Description = description;
                server.Plan        = api.Product.Server.GetBySpec(1, 1);
                server.Save();
                Assert.Greater(Convert.ToInt64(server.Id), 0);

                //
                Console.WriteLine("インタフェースを増設しています...");
                Iface iface = server.AddIface();
                Assert.Greater(Convert.ToInt64(iface.Id), 0);
                Assert.AreEqual(server.Id, iface.ServerId);
                server.Reload();
                Assert.AreEqual(iface.Id, server.Ifaces[0].Id);
                Assert.AreEqual(server.Id, server.Ifaces[0].ServerId);
                iface.Reload();
                Assert.IsNull(iface.SwytchId);

                //
                Console.WriteLine("インタフェースをスイッチに接続しています...");
                iface.ConnectToSwytch(swytch);
                Assert.AreEqual(swytch.Id, iface.SwytchId);
                Assert.AreEqual(swytch.Id, api.Swytch.GetById(iface.SwytchId).Id);

                //
                Console.WriteLine("インタフェースをスイッチから切断しています...");
                iface.DisconnectFromSwytch();

                //
                Console.WriteLine("サーバを削除しています...");
                server.Destroy();

                //
                Console.WriteLine("スイッチを削除しています...");
                swytch.Destroy();
            }
        }
        public void Test()
        {
            string root   = System.IO.Path.GetDirectoryName(Environment.CurrentDirectory);
            string token  = System.Environment.GetEnvironmentVariable("SACLOUD_TOKEN");
            string secret = System.Environment.GetEnvironmentVariable("SACLOUD_SECRET");
            string zone   = System.Environment.GetEnvironmentVariable("SACLOUD_ZONE");
            API    api    = API.Authorize(token, secret, zone);

            string name        = "!cs_nunit-" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "-" + (new Regex(@"-.+")).Replace(System.Guid.NewGuid().ToString(), "");
            string description = "This instance was created by saklient.cs NUnit";
            long   maskLen     = 28;

            Swytch swytch = null;

            if (!USE_STATIC_RESOURCE)
            {
                Console.WriteLine("ルータ+スイッチの帯域プランを検索しています...");
                List <RouterPlan> plans = api.Product.Router.Find();
                long minMbps            = 0x7FFFFFFF;
                foreach (RouterPlan plan in plans)
                {
                    Assert.Greater((long)plan.BandWidthMbps, 0);
                    minMbps = Math.Min((long)plan.BandWidthMbps, minMbps);
                }

                Console.WriteLine("ルータ+スイッチを作成しています...");
                Router router = api.Router.Create();
                router.Name           = name;
                router.Description    = description;
                router.BandWidthMbps  = minMbps;
                router.NetworkMaskLen = maskLen;
                router.Save();

                Console.WriteLine("ルータ+スイッチの作成完了を待機しています...");
                if (!router.SleepWhileCreating())
                {
                    Assert.Fail("ルータが正常に作成されません");
                }
                swytch = router.GetSwytch();
            }
            else
            {
                Console.WriteLine("既存のルータ+スイッチを取得しています...");
                List <Swytch> swytches = api.Swytch.WithNameLike("saklient-static-1").Limit(1).Find();
                Assert.AreEqual(swytches.Count, 1);
                swytch = swytches[0];
            }
            Assert.Greater(swytch.Ipv4Nets.Count, 0);

            //
            Console.WriteLine("ルータ+スイッチの帯域プランを変更しています...");
            string routerIdBefore = swytch.Router.Id;

            swytch.ChangePlan(swytch.Router.BandWidthMbps == 100 ? 500 : 100);
            Assert.AreNotEqual(routerIdBefore, swytch.Router.Id);

            //
            if (0 < swytch.Ipv6Nets.Count)
            {
                Console.WriteLine("ルータ+スイッチからIPv6ネットワークの割当を解除しています...");
                swytch.RemoveIpv6Net();
            }
            Console.WriteLine("ルータ+スイッチにIPv6ネットワークを割り当てています...");
            Ipv6Net v6net = swytch.AddIpv6Net();

            Assert.AreEqual(1, swytch.Ipv6Nets.Count);

            //
            for (int i = swytch.Ipv4Nets.Count - 1; 1 <= i; i--)
            {
                Console.WriteLine("ルータ+スイッチからスタティックルートの割当を解除しています...");
                Ipv4Net net = swytch.Ipv4Nets[i];
                swytch.RemoveStaticRoute(net);
            }

            Console.WriteLine("ルータ+スイッチにスタティックルートを割り当てています...");
            Ipv4Net net0    = swytch.Ipv4Nets[0];
            string  nextHop = long2ip(ip2long(net0.Address) + 4);
            Ipv4Net sroute  = swytch.AddStaticRoute(28, nextHop);

            Assert.AreEqual(2, swytch.Ipv4Nets.Count);
        }