AddKeypair() public method

public AddKeypair ( string name, string publickey = null ) : Keypair
name string
publickey string
return Keypair
        public void AddKeypairTest_Add_Same_Name()
        {
            var os = new OpenStackMember(UserName, Password, TenantName, TenantId);
            string keypairName = string.Format("keypair-key-{0}", TesterName);
            KeypairData[] keypairs = os.ListKeypairs().ToArray<KeypairData>();
            string name = (from b in keypairs where b.KeyPair.Name == keypairName select b.KeyPair.Name).FirstOrDefault();
            if (string.IsNullOrEmpty(name))
            {
                // add keypair
                Keypair kp = os.AddKeypair(keypairName);
                Assert.IsNotNull(kp);
                Assert.IsNotNull(kp.PublicKey);
                Assert.IsNotNull(kp.FingerPrint);
                Assert.IsNotNull(kp.UserId);
                Trace.WriteLine(String.Format("keypair added : {0}", DateTime.Now));
                Trace.WriteLine(String.Format("KeypairName : {0}", kp.Name));
            }

            // expect ServiceConflictException
            os.AddKeypair(keypairName);
        }
        public void AddKeypairTest()
        {
            var os = new OpenStackMember(UserName, Password, TenantName, TenantId);
            // decide keypair name which is not duplicated.
            IEnumerable<KeypairData> keypairs = os.ListKeypairs();
            IEnumerable<string> names = keypairs.GroupBy(s => s.KeyPair.Name, (key, g) => key);
            string[] data = Enumerable.Range(1, 100).Select(i => string.Format("keypair-key-{0}_{1}", TesterName, i)).ToArray<string>();
            string keypairName = (from b in data where !names.Contains<string>(b) select b).First();

            Keypair kp = os.AddKeypair(keypairName);
            Assert.IsNotNull(kp);
            Assert.IsNotNull(kp.PublicKey);
            Assert.IsNotNull(kp.FingerPrint);
            Assert.IsNotNull(kp.UserId);
            Trace.WriteLine(String.Format("keypair added : {0}", DateTime.Now));
            Trace.WriteLine(String.Format("KeypairName : {0}", kp.Name));

            // delete keypair
            Assert.IsTrue(os.DeleteKeypair(keypairName));
            Trace.WriteLine(String.Format("keypair deleted : {0}", DateTime.Now));
        }