Exemplo n.º 1
0
        private static void AddRangeOrdersTest()
        {
            ShopContextFactory shopContextFactory = new ShopContextFactory();
            ShopContext        context            = shopContextFactory.Create();

            ICustomerRepository customerRepository = new DbCustomerRepository(context);

            var customers = customerRepository.Get();

            ProductFaker productFaker = new ProductFaker();
            var          products     = productFaker.Generate(50);

            ServiceFaker serviceFaker = new ServiceFaker();
            var          services     = serviceFaker.Generate(10);

            // Union - suma zbiorów
            var items = products.OfType <Item>().Union(services);

            OrderFaker orderFaker = new OrderFaker(customers, new OrderDetailFaker(items));

            var orders = orderFaker.Generate(10);

            IOrderRepository orderRepository = new DbOrderRepository(context);

            orderRepository.AddRange(orders);
        }
Exemplo n.º 2
0
        public void Using_FakerT_Inheritance()
        {
            var orderFaker = new OrderFaker();
            var o          = orderFaker.Generate();

            o.Dump();
        }
Exemplo n.º 3
0
        public static IEnumerable <Order> GetOrders(int count)
        {
            var customers = GetCustomers(100).ToList();

            var products = GetProducts(50);
            var services = GetServices(20);

            IList <Item> items = products.Cast <Item>().Concat(services).ToList();

            var orderFaker = new OrderFaker(customers, new OrderDetailFaker(items));

            return(orderFaker.Generate(count));
        }
Exemplo n.º 4
0
        private static async Task AddOrderTestAsync()
        {
            var orderFaker = new OrderFaker();

            var order = orderFaker.Generate();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:5001");

                client.DefaultRequestHeaders.Add("key", "Hello");

                var response = await client.PostAsJsonAsync <Order>("api/orders", order);

                response.EnsureSuccessStatusCode();
            }
        }
Exemplo n.º 5
0
        private static async Task AddOrderTest()
        {
            //var order = new OrderFaker

            var orderFaker = new OrderFaker();

            var order = orderFaker.Generate();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("Https://localhost:5001");

                var response = await client.PostAsJsonAsync <Order>("api/orders", order);

                response.EnsureSuccessStatusCode();
            }
        }
Exemplo n.º 6
0
        private static List <Domain.App.OrderRow> CreateDomainOrderRows(List <Product> products,
                                                                        int count)
        {
            var rand      = new Random();
            var orderRows = new List <OrderRow>();

            for (var i = 0; i < count; i++)
            {
                var insertProducts = products.OrderBy(p => Guid.NewGuid())
                                     .Take(rand.Next(1, 4))
                                     .ToList();
                var order         = new OrderFaker().Generate();
                var tempOrderRows = new List <OrderRow>();

                foreach (var product in insertProducts)
                {
                    tempOrderRows.Add(CreateOrderRow(product, order, rand.Next(1, 10)));
                }
                AddOrderTotalPrice(order, tempOrderRows.Sum(x => x.SubTotal));
                orderRows.AddRange(tempOrderRows);
            }

            return(orderRows);
        }
 public OrderConfiguration()
 {
     orderFaker = new OrderFaker();
 }