Ejemplo n.º 1
0
        public IEnumerable <Suggestion> GetTop3([FromQuery] int?topBestRated = null)
        {
            s8.boostRateForTesting(1);
            s9.boostRateForTesting(123);
            s10.boostRateForTesting(134);
            s11.boostRateForTesting(332);

            if (topBestRated == null)
            {
                return(Get());
            }
            return(Get().OrderBy(x => x.GetAvgRate()).Take(topBestRated.Value));
        }
        public void TestSearch()
        {
            Suggestion s31 = new Suggestion("improv1", "sol1");
            Suggestion s32 = new Suggestion("improv2", "sol2");
            Suggestion s33 = new Suggestion("improv3", "sol3");

            s31.boostRateForTesting(4);
            s32.boostRateForTesting(4);
            s33.boostRateForTesting(5);

            s31.Categories = new List <String> {
                "cat1", "cat2", "cat3"
            };
            s32.Categories = new List <String> {
                "cat1", "cat2", "cat3"
            };
            s33.Categories = new List <String> {
                "cat1", "cat2"
            };

            repository.Add(s31);
            repository.Add(s32);
            repository.Add(s33);


            List <Suggestion> testList = repository.Search(new List <String> {
                "cat1", "cat2", "cat3"
            }, 4);

            Assert.AreEqual(3, testList.Count());

            List <Suggestion> list = new List <Suggestion> {
                s31, s32, s33
            };

            for (var i = 0; i < list.Count(); i++)
            {
                Assert.AreEqual(testList[i], list[i]);
            }

            repository.RemoveAll();
            testList.Clear();
            list.Clear();
        }