public void AddingCategoriesTest()
        {
            IStorage    storage     = new MockStorage();
            Preferences preferences = new Preferences(storage);

            List <string> categories = new List <string>();

            categories.Add("gardening");
            categories.Add("electronics");
            categories.Add("test category");

            foreach (string category in categories)
            {
                Assert.True(preferences.AddCategory(category));
            }

            // Ensure these categories have been added to the mock storage
            List <UserPreference> mockPreferences = storage.GetUserPreferences();

            foreach (string category in categories)
            {
                bool found = false;
                foreach (UserPreference pref in mockPreferences)
                {
                    if (pref._category == category)
                    {
                        found = true;
                    }
                }

                Assert.True(found);
            }

            // Ensure these categories have been added to the cache storage
            foreach (string category in categories)
            {
                bool           found = false;
                UserPreference userPref;
                found = preferences.FindUserPreferenceFromCache(category, out userPref);
                Assert.True(found);
                Assert.NotNull(userPref);
            }
        }
        public void RemovingCategoriesTest()
        {
            IStorage    storage     = new MockStorage();
            Preferences preferences = new Preferences(storage);

            // Add some categories to the mock storage
            List <string> categories = new List <string>();

            categories.Add("gardening");
            categories.Add("electronics");
            categories.Add("test category");
            categories.Add("policeman");
            categories.Add("policewoman");

            foreach (string category in categories)
            {
                preferences.AddCategory(category);
            }

            // Remove some categories
            Assert.True(preferences.RemoveCategory("policeman"));
            Assert.True(preferences.RemoveCategory("policewoman"));

            // Ensure these filters are removed from the persistence storage
            List <UserPreference> mockPreferences = storage.GetUserPreferences();

            foreach (UserPreference pref in mockPreferences)
            {
                Assert.False(pref._category == "policeman");
                Assert.False(pref._category == "policewoman");
            }

            UserPreference userPrefOne, userPrefTwo;

            Assert.False(preferences.FindUserPreferenceFromCache("policeman", out userPrefOne));
            Assert.False(preferences.FindUserPreferenceFromCache("policewoman", out userPrefTwo));
        }