public void FindItemByAttributeOnlyFindsMatchingIDs()
        {
            string keyringName = "keyring1";

            List <int> correct_ids   = new List <int> ();
            List <int> incorrect_ids = new List <int> ();

            Hashtable correctAttr = new Hashtable();

            correctAttr["banana"] = "a fruit";
            Hashtable incorrectAttr = new Hashtable();

            incorrectAttr["banana"] = "a fish";

            correct_ids.Add(Ring.CreateItem(keyringName, ItemType.Note, "a note", correctAttr, "secret", false));
            incorrect_ids.Add(Ring.CreateItem(keyringName, ItemType.GenericSecret, "not a note", incorrectAttr, "secret", false));
            correct_ids.Add(Ring.CreateItem(keyringName, ItemType.Note, "another note", correctAttr, "notsecret", false));
            correct_ids.Add(Ring.CreateItem(keyringName, ItemType.Note, "a third note", correctAttr, "reallysecret", false));
            incorrect_ids.Add(Ring.CreateOrModifyNetworkPassword(keyringName, "use4r", "domain", "server", "object", "protocol", "authtype", 42, "password"));

            CollectionAssert.IsSubsetOf(Ring.Find(ItemType.Note, correctAttr).
                                        Where((data) => data.Keyring == keyringName).
                                        Select((data) => data.ItemID).ToList(), correct_ids);
            foreach (var id in incorrect_ids)
            {
                CollectionAssert.DoesNotContain(Ring.Find(ItemType.Note, correctAttr).
                                                Where((data) => data.Keyring == keyringName).
                                                Select((data) => data.ItemID), id);
            }
        }
        public void CreatedNetworkPasswordSetsAppropriateData()
        {
            string keyringName = "keyring";

            Ring.CreateKeyring(keyringName, "password");

            try {
                Hashtable data = new Hashtable();
                data["user"]     = "******";
                data["domain"]   = "divination";
                data["server"]   = "jeeves";
                data["object"]   = "subject";
                data["protocol"] = "droid";
                data["authtype"] = "smtp";
                data["port"]     = 42;

                //Password is stored in the secret.
                int id = Ring.CreateOrModifyNetworkPassword(keyringName, (string)data["user"], (string)data["domain"], (string)data["server"],
                                                            (string)data["object"], (string)data["protocol"], (string)data["authtype"], (int)data["port"], "password");

                CollectionAssert.IsSubsetOf(data, Ring.GetItemAttributes(keyringName, id));
            } finally {
                Ring.DeleteKeyring(keyringName);
            }
        }
        public void FindNetworkPasswordByDomainFindsAppropriateIDs()
        {
            string keyringName = "keyring";

            Ring.CreateKeyring(keyringName, "password");
            List <int> ids = new List <int> ();

            try {
                ids.Add(Ring.CreateOrModifyNetworkPassword(keyringName, "user", "domain", "server", "object", "protocol", "authtype", 42, "password"));
                Ring.CreateOrModifyNetworkPassword(keyringName, "user2", "d3omain", "4server", "o5bject", "proto6col", "3authtype", 49, "password");
                Ring.CreateItem(keyringName, ItemType.Note, "I'm not a network password", new Hashtable(), "secret", false);
                ids.Add(Ring.CreateOrModifyNetworkPassword(keyringName, "u3ser", "domain", "server", "object", "protocol", "authtype", 42, "password"));
                ids.Add(Ring.CreateOrModifyNetworkPassword(keyringName, "use4r", "domain", "server", "object", "protocol", "authtype", 42, "password"));

                CollectionAssert.AreEquivalent(ids, Ring.FindNetworkPassword(null, "domain", null, null, null, null, 0).
                                               Where((NetItemData data) => data.Keyring == keyringName).
                                               Select((NetItemData data) => data.ItemID).ToList());
            } finally {
                Ring.DeleteKeyring(keyringName);
            }
        }