示例#1
0
        public void RemovingPreferencesTest()
        {
            SqliteStorage storage = _storage;

            Assert.True(_storage.CreateTables());

            List <UserPreference> preferences = new List <UserPreference>();

            preferences.Add(new UserPreference("electronics"));
            preferences.Add(new UserPreference("books", 10.0, 1900.0));
            preferences.Add(new UserPreference("gardening", 50.0, 100.0));

            bool result = storage.InsertUserPreferences(preferences);

            Assert.True(result);

            result = storage.DeleteUserPreferences(preferences);
            Assert.True(result);
        }
示例#2
0
        public void RemovingNullPreferenceTest()
        {
            SqliteStorage storage = _storage;

            Assert.True(_storage.CreatePreferenceTable());

            bool result = storage.InsertUserPreference(new UserPreference("headphones"));

            Assert.True(result);

            Assert.Throws <ArgumentNullException>(() =>
            {
                storage.DeleteUserPreference(null);
            });

            Assert.Throws <ArgumentNullException>(() =>
            {
                storage.DeleteUserPreferences(null);
            });
        }
示例#3
0
        public void GetNumberOfRowsTest()
        {
            SqliteStorage storage = _storage;

            Assert.True(_storage.CreateTables());

            List <UserPreference> preferences = new List <UserPreference>();

            preferences.Add(new UserPreference("movies", 0.0, 0.0));
            preferences.Add(new UserPreference("games", 0.0, 100.0));
            preferences.Add(new UserPreference("tools", 0.0, 100.0));

            bool result = storage.InsertUserPreferences(preferences);

            Assert.True(result);
            Assert.True(storage.GetNumberOfRows() == preferences.Count);

            int numItems = preferences.Count;

            preferences.RemoveAt(2);
            result = storage.DeleteUserPreferences(preferences);
            Assert.True(result);
            Assert.True(storage.GetNumberOfRows() == (numItems - preferences.Count));
        }