Beispiel #1
0
        public void WhenGettingAnInvalidBookItShouldThrow()
        {
            // Arrange
            var fakeHandler = new TestDelegatingHandler <Customer>(HttpStatusCode.NotFound);
            var fakeServer  = new HttpServer(new HttpConfiguration(), fakeHandler);
            var service     = new CustomerBetService(new HttpClient(fakeServer));

            // Act
            var result = service.GetCustomers();

            // Assert
            Assert.Fail();
        }
Beispiel #2
0
        public void WhenGettingAllCustomersTheyShouldBeReturned()
        {
            // Arrange
            var customers = new[] {
                new Customer {
                    Id = 1, Name = "Customer 1"
                },
                new Customer {
                    Id = 2, Name = "Customer 2"
                }
            };

            var fakehandler = new TestDelegatingHandler <Customer[]>(customers);
            var fakeServer  = new HttpServer(new HttpConfiguration(), fakehandler);
            var service     = new CustomerBetService(new HttpClient(fakeServer));

            // Act
            var result = service.GetCustomers();

            // Assert
            Assert.AreEqual(2, result.Count);
        }
Beispiel #3
0
        public PagedResult <CustomerBetVM> CustomerBets(BetTableSortBy sortBy, bool isAscending)
        {
            var service   = new CustomerBetService(new HttpClient());
            var customers = service.GetCustomers();
            var bets      = service.GetBets();

            var result = customers
                         .Join(bets, cust => cust.Id, bet => bet.CustomerId,
                               (cust, bet) => new CustomerBetVM()
            {
                CustomerName = cust.Name,
                RaceNumber   = bet.RaceId,
                ReturnStake  = bet.ReturnStake,
                Won          = bet.Won
            })
                         .OrderBy(sortBy.ToString(), isAscending).ToList();

            return(new PagedResult <CustomerBetVM>
            {
                Data = result,
                TotalCount = result.Count()
            });
        }