public Subnet GetSubnetByName(string name, ref IOpenStackMember os)
 {
     var subnets = (os ?? new OpenStackMember(UserName, Password, TenantName, TenantId))
         .ListSubnets().Where<Subnet>(n => n.Name == name);
     if (subnets != null && subnets.Count() > 0)
         return subnets.First<Subnet>();
     else
         throw new ArgumentException("no subnet found");
 }
        public Subnet GetSubnetByName(string name, ref IOpenStackMember os)
        {
            var subnets = (os ?? new OpenStackMember(UserName, Password, TenantName, TenantId))
                          .ListSubnets().Where <Subnet>(n => n.Name == name);

            if (subnets != null && subnets.Count() > 0)
            {
                return(subnets.First <Subnet>());
            }
            else
            {
                throw new ArgumentException("no subnet found");
            }
        }
Ejemplo n.º 3
0
        public void OpenstackMemberTest_ShouldFail()
        {
            IOpenStackMember os = null;

            // it should throw ArgumentNullException when UserName and Password are null.
            AssertCatch <ArgumentNullException>(() => os = new OpenStackMember(null, null));

            // it should throw ArgumentNullException when UserName is null.
            AssertCatch <ArgumentNullException>(() => os = new OpenStackMember(null, Password));

            // it should throw ArgumentNullException when password is null.
            AssertCatch <ArgumentNullException>(() => os = new OpenStackMember(UserName, null));

            // os.UserId should be null when UserName or Password doesn't match.
            AssertCatch <ArgumentException>(() => os = new OpenStackMember(UserName, string.Empty));

            // what if os.UserId will be? when tenantId is not match.
            AssertCatch <ArgumentException>(() => os = new OpenStackMember(UserName, Password, null, string.Empty));
        }