public void testSetValue()
 {
     IPreferenceArray prefs = new BooleanUserPreferenceArray(3);
     Assert.AreEqual(1.0f, prefs.GetValue(2), EPSILON);
     Assert.AreEqual(3, prefs.Length());
     prefs.SetValue(0, 1.0f);
 }
예제 #2
0
        public void testSetValue()
        {
            IPreferenceArray prefs = new BooleanUserPreferenceArray(3);

            Assert.AreEqual(1.0f, prefs.GetValue(2), EPSILON);
            Assert.AreEqual(3, prefs.Length());
            prefs.SetValue(0, 1.0f);
        }
 public void testHasPref()
 {
     IPreferenceArray prefs = new BooleanUserPreferenceArray(3);
     prefs.Set(0, new GenericPreference(1L, 3L, 5.0f));
     Assert.True(prefs.HasPrefWithItemID(3L));
     Assert.True(prefs.HasPrefWithUserID(1L));
     Assert.False(prefs.HasPrefWithItemID(2L));
     Assert.False(prefs.HasPrefWithUserID(2L));
 }
예제 #4
0
        public void testHasPref()
        {
            IPreferenceArray prefs = new BooleanUserPreferenceArray(3);

            prefs.Set(0, new GenericPreference(1L, 3L, 5.0f));
            Assert.True(prefs.HasPrefWithItemID(3L));
            Assert.True(prefs.HasPrefWithUserID(1L));
            Assert.False(prefs.HasPrefWithItemID(2L));
            Assert.False(prefs.HasPrefWithUserID(2L));
        }
예제 #5
0
        public void testUserID()
        {
            IPreferenceArray prefs = new BooleanUserPreferenceArray(3);

            Assert.AreEqual(3, prefs.Length());
            prefs.SetUserID(0, 1L);
            Assert.AreEqual(1L, prefs.GetUserID(0));
            Assert.AreEqual(1L, prefs.GetUserID(1));
            Assert.AreEqual(1L, prefs.GetUserID(2));
        }
 public void testClone()
 {
     BooleanUserPreferenceArray prefs = new BooleanUserPreferenceArray(3);
     prefs.Set(0, new BooleanPreference(1L, 3L));
     prefs.Set(1, new BooleanPreference(1L, 1L));
     prefs.Set(2, new BooleanPreference(1L, 2L));
     prefs = (BooleanUserPreferenceArray)prefs.Clone();
     Assert.AreEqual(3L, prefs.GetItemID(0));
     Assert.AreEqual(1L, prefs.GetUserID(1));
 }
예제 #7
0
        public void testClone()
        {
            BooleanUserPreferenceArray prefs = new BooleanUserPreferenceArray(3);

            prefs.Set(0, new BooleanPreference(1L, 3L));
            prefs.Set(1, new BooleanPreference(1L, 1L));
            prefs.Set(2, new BooleanPreference(1L, 2L));
            prefs = (BooleanUserPreferenceArray)prefs.Clone();
            Assert.AreEqual(3L, prefs.GetItemID(0));
            Assert.AreEqual(1L, prefs.GetUserID(1));
        }
 public void testItemID()
 {
     IPreferenceArray prefs = new BooleanUserPreferenceArray(3);
     Assert.AreEqual(3, prefs.Length());
     prefs.SetItemID(0, 1L);
     prefs.SetItemID(1, 2L);
     prefs.SetItemID(2, 3L);
     Assert.AreEqual(1L, prefs.GetItemID(0));
     Assert.AreEqual(2L, prefs.GetItemID(1));
     Assert.AreEqual(3L, prefs.GetItemID(2));
 }
 public void testSort()
 {
     IPreferenceArray prefs = new BooleanUserPreferenceArray(3);
     prefs.Set(0, new BooleanPreference(1L, 3L));
     prefs.Set(1, new BooleanPreference(1L, 1L));
     prefs.Set(2, new BooleanPreference(1L, 2L));
     prefs.SortByItem();
     Assert.AreEqual(1L, prefs.GetItemID(0));
     Assert.AreEqual(2L, prefs.GetItemID(1));
     Assert.AreEqual(3L, prefs.GetItemID(2));
 }
예제 #10
0
        public void testSort()
        {
            IPreferenceArray prefs = new BooleanUserPreferenceArray(3);

            prefs.Set(0, new BooleanPreference(1L, 3L));
            prefs.Set(1, new BooleanPreference(1L, 1L));
            prefs.Set(2, new BooleanPreference(1L, 2L));
            prefs.SortByItem();
            Assert.AreEqual(1L, prefs.GetItemID(0));
            Assert.AreEqual(2L, prefs.GetItemID(1));
            Assert.AreEqual(3L, prefs.GetItemID(2));
        }
        /// @throws NoSuchUserException
        ///           if there is no such user
        public override IPreferenceArray GetPreferencesFromUser(long userID)
        {
            FastIDSet itemIDs = preferenceFromUsers.Get(userID);

            if (itemIDs == null)
            {
                throw new NoSuchUserException(userID);
            }
            IPreferenceArray prefArray = new BooleanUserPreferenceArray(itemIDs.Count());
            int i  = 0;
            var it = itemIDs.GetEnumerator();

            while (it.MoveNext())
            {
                prefArray.SetUserID(i, userID);
                prefArray.SetItemID(i, it.Current);
                i++;
            }
            return(prefArray);
        }
    internal PreferenceView(BooleanUserPreferenceArray arr, int i) {
      this.i = i;
	  this.arr = arr;
    }
  /// @throws NoSuchUserException
  ///           if there is no such user
 public override IPreferenceArray GetPreferencesFromUser(long userID) {
   FastIDSet itemIDs = preferenceFromUsers.Get(userID);
   if (itemIDs == null) {
     throw new NoSuchUserException(userID);
   }
   IPreferenceArray prefArray = new BooleanUserPreferenceArray(itemIDs.Count() );
   int i = 0;
   var it = itemIDs.GetEnumerator();
   while (it.MoveNext()) {
     prefArray.SetUserID(i, userID);
     prefArray.SetItemID(i, it.Current);
     i++;
   }
   return prefArray;
 }
 internal PreferenceView(BooleanUserPreferenceArray arr, int i)
 {
     this.i   = i;
     this.arr = arr;
 }