Ejemplo n.º 1
0
        public void Run(BussinesService service)
        {
            Random rand = new Random();

            for (int i = 0; i < rand.Next() % 8; i++)
            {/*/
              * Task.Run(() =>
              * {*/
                List <Client> ClientsList = context.Clients.ToList();

                int Buyer = rand.Next() % context.Clients.Count(), Seller = (Buyer + rand.Next() % context.Clients.Count()) % context.Clients.Count();

                service.CreateDeal(ClientsList[Buyer], ClientsList[Seller]);
                //});

                /*
                 * DealHistory deal = new DealHistory();
                 *
                 * List<Client> ClientsList = context.Clients.ToList();
                 * deal.BuyerId = ClientsList[rand.Next() % context.Clients.Count()].Id;
                 * deal.SellerId = (deal.BuyerId + ClientsList[rand.Next() % context.Clients.Count()].Id) % context.Clients.Count();
                 * deal.ShareId = context.Shares.ToList()[rand.Next() % context.Shares.Count()].ShareId;
                 * deal.Amount = rand.Next() % context.ClientsShares.First(s => s.ClientId == deal.SellerId && s.ShareId == deal.ShareId).Amount;
                 *
                 * context.Add(deal);
                 * context.SaveChanges();
                 */
            }
        }
Ejemplo n.º 2
0
        public void CanCreateDeal()
        {
            bussinesService.CreateDeal(client1, client2);

            Received.InOrder(() =>
            {
                dataContext.Received(1).Add(Arg.Any <DealHistory>());
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).SaveChanges();
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).SaveChanges();
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).Update(Arg.Any <ClientShare>());
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).Update(Arg.Any <ClientShare>());
                dataContext.Received(1).SaveChanges();
                dataContext.Received(1).Add(Arg.Any <DealHistory>());
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).SaveChanges();
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).SaveChanges();
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).Update(Arg.Any <ClientShare>());
                dataContext.Received(1).Update(Arg.Any <Client>());
                dataContext.Received(1).Update(Arg.Any <ClientShare>());
                dataContext.Received(1).SaveChanges();
            });
        }