Beispiel #1
0
        public void NoBooks()
        {
            var ratingSystem = new RatingSystem();
            var results      = ratingSystem.ComputeRating(new RatingInput[] { });

            Assert.AreEqual(0, results.Count());
        }
Beispiel #2
0
        public void SimpleRatings()
        {
            var tests = new[]
            {
                new RatingInput {
                    BookId = Guid.NewGuid(), Title = "abc", IsForeign = false
                },
                new RatingInput {
                    BookId = Guid.NewGuid(), Title = "abc", IsForeign = true
                },
                new RatingInput {
                    BookId = Guid.NewGuid(), Title = "super abc", IsForeign = false
                },
                new RatingInput {
                    BookId = Guid.NewGuid(), Title = "super abc", IsForeign = true
                },
            };

            var ratingSystem = new RatingSystem();
            var ratings      = ratingSystem.ComputeRating(tests);

            Assert.AreEqual(
                "0.00, 0.00, 100.00, 120.00",
                string.Join(", ", ratings.Select(r => r.Value.ToString("f2", CultureInfo.InvariantCulture))));
        }
Beispiel #3
0
        public void UnknownTitle()
        {
            var bookWithoutTitle = new RatingInput
            {
                BookId    = Guid.NewGuid(),
                Title     = null,
                IsForeign = false
            };

            var ratingSystem = new RatingSystem();
            var result       = ratingSystem.ComputeRating(new[] { bookWithoutTitle }).Single();

            Assert.AreEqual(bookWithoutTitle.BookId, result.BookId);
            Assert.AreEqual(0, result.Value);
        }