예제 #1
0
        public void GetDealsOfDealer_RandomRange_ShouldBeIntegrated()
        {
            //init
            var dealersResult = dealerController.Dealers();
            var givenDealers  = dealersResult.GetObject <PagedResult <Dealer> >().Queryable.ToArray();
            var dealersArb    = ControllerHelper.ChooseFrom(givenDealers).ToArbitrary();

            Prop.ForAll(dealersArb, (dealer) =>
            {
                var deals     = sut.GetDealsOfDealer(dealer.Id, 1, int.MaxValue).Result.GetObject <PagedResult <Deal> >().Queryable.ToList();
                var sales     = sut.GetSalesOfDealer(dealer.Id, 1, int.MaxValue).GetObject <PagedResult <Deal> >().Queryable.ToList();
                var purchases = sut.GetPurchasesOfDealer(dealer.Id, 1, int.MaxValue).GetObject <PagedResult <Deal> >().Queryable.ToList();
                var union     = sales.Union(purchases).ToList();

                foreach (var item in deals)
                {
                    var u = union.Single(i => i.Id == item.Id);


                    Assert.AreEqual(u.SellerId, item.SellerId);
                    Assert.AreEqual(u.BuyerId, item.BuyerId);
                    Assert.AreEqual(u.DealPriceId, item.DealPriceId);
                    Assert.AreEqual(u.DealPaymentId, item.DealPaymentId);
                    Assert.AreEqual(u.DealTime, item.DealTime);
                    union.Remove(u);
                }

                Assert.IsEmpty(union);
            }).QuickCheckThrowOnFailure();
        }