Ejemplo n.º 1
0
        public async Task GetRankingShouldReturnRankedList()
        {
            var object1Guid          = Guid.NewGuid();
            var object2Guid          = Guid.NewGuid();
            var object3Guid          = Guid.NewGuid();
            var objectForSaleService = new Mock <IObjectService>();
            var objectsForSale       = new List <ObjectForSale>();

            objectsForSale.AddRange(GetRandomObjectForSale(1, "Robin").Take(10));
            objectsForSale.AddRange(GetRandomObjectForSale(2, "Kristel").Take(15));
            objectsForSale.AddRange(GetRandomObjectForSale(3, "Yeti").Take(12));

            objectForSaleService.Setup(s => s.GetObjects(ListingType.Sale, "Test", "Tweede")).ReturnsAsync(objectsForSale);

            var sut = new SimpleRealtorRanker(objectForSaleService.Object);

            var rank = await sut.GetRankedList(ListingType.Sale, "Test", "Tweede");

            var immutableRank = rank.ToImmutableList();

            Assert.AreEqual(immutableRank[0].Key, new Realtor(2, "Kristel"));
            Assert.AreEqual(immutableRank[1].Key, new Realtor(3, "Yeti"));
            Assert.AreEqual(immutableRank[2].Key, new Realtor(1, "Robin"));
            Assert.AreEqual(immutableRank[0].Value, 15);
            Assert.AreEqual(immutableRank[1].Value, 12);
            Assert.AreEqual(immutableRank[2].Value, 10);
        }
Ejemplo n.º 2
0
        public async Task GetRankingShouldCallIntoObjectForSaleServiceWithCorrectParameters()
        {
            var objectForSaleService = new Mock <IObjectService>();
            var sut = new SimpleRealtorRanker(objectForSaleService.Object);

            await sut.GetRankedList(ListingType.Sale, "Test", "Tweede");

            objectForSaleService.Verify(s => s.GetObjects(ListingType.Sale, "Test", "Tweede"));
        }