Exemplo n.º 1
0
        public void UpdateOnePreferenceTest()
        {
            SqliteStorage storage = _storage;

            Assert.True(_storage.CreatePreferenceTable());

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

            // When is the primary key set, at inserion or object creation?
            UserPreference u1 = new UserPreference("movies", 0.0, 0.0);
            UserPreference u2 = new UserPreference("games", 0.0, 100.0);

            preferences.Add(u1);
            preferences.Add(u2);

            bool result = storage.InsertUserPreferences(preferences);

            Assert.True(result);

            u1._category = "gardening";
            u1._minPrice = 95.0;
            u1._maxPrice = 165.75;
            result       = storage.UpdateUserPreference(u1);
            Assert.True(result);

            UserPreference updatedPref = storage.GetUserPreference("gardening");

            Assert.NotNull(updatedPref);

            Assert.Equal(95.0, updatedPref._minPrice);
            Assert.Equal(165.75, updatedPref._maxPrice);
        }
Exemplo n.º 2
0
        public void GetUserPreferenceNullTest()
        {
            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);

            UserPreference userPreference = storage.GetUserPreference("garden");

            Assert.Null(userPreference);
        }
Exemplo n.º 3
0
        public void GetUserPreferenceTest()
        {
            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);

            UserPreference userPreference = storage.GetUserPreference("games");

            Assert.NotNull(userPreference);
            Assert.Equal("games", userPreference._category);
            Assert.True(userPreference._minPrice == 0.0);
            Assert.True(userPreference._maxPrice == 100.0);
        }