private static async Task SignalRClientTestAsync() { string url = "http://localhost:5000/hubs/orders"; // add package Microsoft.AspNetCore.SignalR.Client HubConnection connection = new HubConnectionBuilder() .WithUrl(url) .Build(); Console.WriteLine("Connecting..."); await connection.StartAsync(); Console.WriteLine("Connected."); var orderFaker = new OrderFaker(); while (true) { Order order = orderFaker.Generate(); await connection.SendAsync("AddedOrder", order); Console.WriteLine("Sent order"); // Task.Delay(10); await Task.Delay(TimeSpan.FromSeconds(1)); } }
public void Using_FakerT_Inheritance() { var orderFaker = new OrderFaker(); var o = orderFaker.Generate(); o.Dump(); }
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); }
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)); }
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(); } }
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(); } }
public void Configure(EntityTypeBuilder <Order> builder) { builder.HasData(orderFaker.Generate(100)); }