Exemplo n.º 1
0
        public async Task GetEstateAgentsByHighestSaleOrder_Returns_Some_Agents()
        {
            var result = await offerFilter.GetEstateAgentsByHighestSaleOrder("amsterdam", "tuin");

            result.Where(x =>
            {
                return
                (x.Name.Equals("Hoekstra en van Eck Amsterdam West")
                 ||
                 x.Name.Equals("Fransen & Kroes Makelaars"));
            }).Should().HaveCount(2);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Print agents having most offers into console
        /// </summary>
        /// <param name="args">Arguments to call the service</param>
        /// <param name="numberOfItemsToShow">Number of items to display into the console</param>
        internal static void PrintData(string[] args, int numberOfItemsToShow)
        {
            ILogger     logger      = serviceProvider.GetService <ILogger <Program> >();
            OfferFilter offerFilter = serviceProvider.GetService <OfferFilter>();

            "Funda offer finder started..."
            .SendTo(Console.WriteLine);
            $"Searching offers by {string.Join(',', args)}"
            .SendTo(Console.WriteLine)
            .SendTo(objects: null, method: logger.LogInformation);
            $"Fetching Top {numberOfItemsToShow} selling agents, Please wait..."
            .SendTo(Console.WriteLine);

            string[]  headers   = new string[] { "Estate Agent Name", "Offer Count" };
            ConsoleUI consoleUI = new ConsoleUI(TableStart, ConsoleUI.Align.Left, headers);

            offerFilter.UpdateProgress(PrintProgress);

            try
            {
                var topAgents = offerFilter.GetEstateAgentsByHighestSaleOrder(args)
                                .GetAwaiter()
                                .GetResult()
                                .Take(numberOfItemsToShow);

                ArrayList tableData = new ArrayList(topAgents.Select(x => new string[] { x.Name, x.OfferCount.ToString() }).ToList());
                consoleUI.RePrint(tableData);
            }
            catch (NotCompletedException ncEx)
            {
                Console.WriteLine("\r\nAn error occured, please try again later");
                Console.WriteLine($"Reason: {ncEx.Message}");
            }
        }
Exemplo n.º 3
0
        public async Task GetEstateAgentsByHighestSaleOrder_Returns_Three_Offers()
        {
            SetupApiClientGetData(OfferFilterResponse.ThreeOffersOnePage);

            var result = await offerFilter.GetEstateAgentsByHighestSaleOrder(It.IsAny <string>());

            result.Single(x => x.Name.Equals("Hoekstra en van Eck Amsterdam West"))
            .OfferCount
            .Should()
            .Be(2);

            result.Single(x => x.Name.Equals("Fransen & Kroes Makelaars"))
            .OfferCount
            .Should()
            .Be(1);

            result.Select(x => x.OfferCount)
            .Aggregate((prev, next) => prev + next)
            .Should()
            .Be(3);
        }