Add() public method

public Add ( int user_id, int item_id, double rating ) : void
user_id int
item_id int
rating double
return void
Ejemplo n.º 1
0
		public void TestFull()
		{
			var ratings = new StaticRatings(2);
			Assert.AreEqual(0, ratings.Count);
			ratings.Add(1, 4, 0.3f);
			Assert.AreEqual(1, ratings.Count);
			ratings.Add(1, 8, 0.2f);
			Assert.AreEqual(2, ratings.Count);
			ratings.Add(2, 4, 0.2f);
		}
Ejemplo n.º 2
0
		[Test()] public void TestMaxUserIDMaxItemID()
		{
			var ratings = new StaticRatings(7);
			ratings.Add(1, 4, 0.3f);
			ratings.Add(1, 8, 0.2f);
			ratings.Add(2, 4, 0.2f);
			ratings.Add(2, 2, 0.6f);
			ratings.Add(2, 5, 0.4f);
			ratings.Add(3, 7, 0.2f);
			ratings.Add(6, 3, 0.3f);

			Assert.AreEqual(6, ratings.MaxUserID);
			Assert.AreEqual(8, ratings.MaxItemID);
		}
Ejemplo n.º 3
0
		[Test()] public void TestMinRatingMaxRating()
		{
			var ratings = new StaticRatings(7);
			ratings.Add(1, 4, 0.3f);
			ratings.Add(1, 8, 0.2f);
			ratings.Add(2, 4, 0.2f);
			ratings.Add(2, 2, 0.6f);
			ratings.Add(2, 5, 0.4f);
			ratings.Add(3, 7, 0.2f);
			ratings.Add(6, 3, 0.3f);

			Assert.AreEqual(0.6f, ratings.Scale.Max);
			Assert.AreEqual(0.2f, ratings.Scale.Min);
		}
Ejemplo n.º 4
0
        public void TestAdd()
        {
            var ratings = new StaticRatings(7);
            ratings.Add(1, 4, 0.3f);
            Assert.AreEqual(1, ratings.Count);
            ratings.Add(1, 8, 0.2f);
            Assert.AreEqual(2, ratings.Count);
            ratings.Add(2, 4, 0.2f);
            ratings.Add(2, 2, 0.6f);
            ratings.Add(2, 5, 0.4f);
            ratings.Add(3, 7, 0.2f);
            ratings.Add(6, 3, 0.3f);

            Assert.AreEqual(0.4f, ratings[2, 5]);
            Assert.AreEqual(0.3f, ratings[1, 4]);
            Assert.AreEqual(0.3f, ratings[6, 3]);
            Assert.AreEqual(7, ratings.Count);
        }
Ejemplo n.º 5
0
        public void TestRemoveUser()
        {
            var ratings = new StaticRatings(7);
            ratings.Add(1, 4, 0.3f);
            ratings.Add(1, 8, 0.2f);
            ratings.Add(2, 4, 0.2f);
            ratings.Add(2, 2, 0.6f);
            ratings.Add(2, 5, 0.4f);
            ratings.Add(3, 7, 0.2f);
            ratings.Add(3, 3, 0.3f);

            Assert.AreEqual(7, ratings.Count);
            ratings.RemoveUser(2);
        }
Ejemplo n.º 6
0
        public void TestRemoveAt()
        {
            var ratings = new StaticRatings(8);
            ratings.Add(1, 4, 0.3f);
            ratings.Add(1, 8, 0.2f);
            ratings.Add(2, 4, 0.2f);
            ratings.Add(2, 2, 0.6f);
            ratings.Add(2, 5, 0.4f);
            ratings.Add(3, 7, 0.2f);
            ratings.Add(3, 3, 0.3f);
            ratings.Add(6, 3, 0.3f);

            Assert.AreEqual(8, ratings.Count);
            ratings.RemoveAt(ratings.GetIndex(2, 5));
        }
Ejemplo n.º 7
0
        public void TestIndex()
        {
            var ratings = new StaticRatings(8);
            ratings.Add(1, 4, 0.3f);
            ratings.Add(1, 8, 0.2f);
            ratings.Add(2, 4, 0.2f);
            ratings.Add(2, 2, 0.6f);
            ratings.Add(2, 5, 0.4f);
            ratings.Add(3, 4, 0.2f);
            ratings.Add(3, 3, 0.3f);
            ratings.Add(6, 3, 0.3f);

            // test index[,]
            Assert.AreEqual(0.3f, ratings[1, 4]);
            Assert.AreEqual(0.2f, ratings[1, 8]);
            Assert.AreEqual(0.6f, ratings[2, 2]);
        }