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

            Assert.AreEqual(3, prefs.Length());
            Assert.AreEqual(1.0f, prefs.GetValue(2), EPSILON);
            prefs.SetValue(0, 1.0f);
        }
 public void testHasPref()
 {
     IPreferenceArray prefs = new BooleanItemPreferenceArray(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));
 }
 public void testClone()
 {
     BooleanItemPreferenceArray prefs = new BooleanItemPreferenceArray(3);
     prefs.Set(0, new BooleanPreference(3L, 1L));
     prefs.Set(1, new BooleanPreference(1L, 1L));
     prefs.Set(2, new BooleanPreference(2L, 1L));
     prefs = (BooleanItemPreferenceArray)prefs.Clone();
     Assert.AreEqual(3L, prefs.GetUserID(0));
     Assert.AreEqual(1L, prefs.GetItemID(1));
 }
Example #5
0
        public void testHasPref()
        {
            IPreferenceArray prefs = new BooleanItemPreferenceArray(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));
        }
Example #6
0
        public void testUserID()
        {
            IPreferenceArray prefs = new BooleanItemPreferenceArray(3);

            Assert.AreEqual(3, prefs.Length());
            prefs.SetItemID(0, 1L);
            Assert.AreEqual(1L, prefs.GetItemID(0));
            Assert.AreEqual(1L, prefs.GetItemID(1));
            Assert.AreEqual(1L, prefs.GetItemID(2));
        }
Example #7
0
        public override bool Equals(Object other)
        {
            if (!(other is BooleanItemPreferenceArray))
            {
                return(false);
            }
            BooleanItemPreferenceArray otherArray = (BooleanItemPreferenceArray)other;

            return(id == otherArray.id && Enumerable.SequenceEqual(ids, otherArray.ids));
        }
 public void testItemID()
 {
     IPreferenceArray prefs = new BooleanItemPreferenceArray(3);
     Assert.AreEqual(3, prefs.Length());
     prefs.SetUserID(0, 1L);
     prefs.SetUserID(1, 2L);
     prefs.SetUserID(2, 3L);
     Assert.AreEqual(1L, prefs.GetUserID(0));
     Assert.AreEqual(2L, prefs.GetUserID(1));
     Assert.AreEqual(3L, prefs.GetUserID(2));
 }
 public void testSort()
 {
     IPreferenceArray prefs = new BooleanItemPreferenceArray(3);
     prefs.Set(0, new GenericPreference(3L, 1L, 5.0f));
     prefs.Set(1, new GenericPreference(1L, 1L, 5.0f));
     prefs.Set(2, new GenericPreference(2L, 1L, 5.0f));
     prefs.SortByUser();
     Assert.AreEqual(1L, prefs.GetUserID(0));
     Assert.AreEqual(2L, prefs.GetUserID(1));
     Assert.AreEqual(3L, prefs.GetUserID(2));
 }
Example #10
0
        public void testClone()
        {
            BooleanItemPreferenceArray prefs = new BooleanItemPreferenceArray(3);

            prefs.Set(0, new BooleanPreference(3L, 1L));
            prefs.Set(1, new BooleanPreference(1L, 1L));
            prefs.Set(2, new BooleanPreference(2L, 1L));
            prefs = (BooleanItemPreferenceArray)prefs.Clone();
            Assert.AreEqual(3L, prefs.GetUserID(0));
            Assert.AreEqual(1L, prefs.GetItemID(1));
        }
Example #11
0
        public void testSort()
        {
            IPreferenceArray prefs = new BooleanItemPreferenceArray(3);

            prefs.Set(0, new GenericPreference(3L, 1L, 5.0f));
            prefs.Set(1, new GenericPreference(1L, 1L, 5.0f));
            prefs.Set(2, new GenericPreference(2L, 1L, 5.0f));
            prefs.SortByUser();
            Assert.AreEqual(1L, prefs.GetUserID(0));
            Assert.AreEqual(2L, prefs.GetUserID(1));
            Assert.AreEqual(3L, prefs.GetUserID(2));
        }
        public override IPreferenceArray GetPreferencesForItem(long itemID)
        {
            FastIDSet userIDs = preferenceForItems.Get(itemID);

            if (userIDs == null)
            {
                throw new NoSuchItemException(itemID);
            }
            IPreferenceArray prefArray = new BooleanItemPreferenceArray(userIDs.Count());
            int i  = 0;
            var it = userIDs.GetEnumerator();

            while (it.MoveNext())
            {
                prefArray.SetUserID(i, it.Current);
                prefArray.SetItemID(i, itemID);
                i++;
            }
            return(prefArray);
        }
 public override IPreferenceArray GetPreferencesForItem(long itemID) {
   FastIDSet userIDs = preferenceForItems.Get(itemID);
   if (userIDs == null) {
     throw new NoSuchItemException(itemID);
   }
   IPreferenceArray prefArray = new BooleanItemPreferenceArray(userIDs.Count());
   int i = 0;
   var it = userIDs.GetEnumerator();
   while (it.MoveNext()) {
     prefArray.SetUserID(i, it.Current);
     prefArray.SetItemID(i, itemID);
     i++;
   }
   return prefArray;
 }
Example #14
0
 internal PreferenceView(BooleanItemPreferenceArray arr, int i)
 {
     this.i   = i;
     this.arr = arr;
 }
    internal PreferenceView(BooleanItemPreferenceArray arr, int i) {
      this.i = i;
		this.arr = arr;
    }