public void CreateProductMappingTest()
        {
            var options = new DbContextOptionsBuilder <FundstradingContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            int channelId;

            // Insert seed data into the database using one instance of the context
            using (var ctx = new FundstradingContext(options))
            {
                ctx.Channel.Add(new Channel {
                    Description = "Description", Appid = "Appid", Apikey = "Apikey", Userid = "Userid", Baseurl = "Baseurl"
                });
                ctx.SaveChanges();

                channelId = ctx.Channel.FirstOrDefault().Id;

                Assert.AreEqual(1, ctx.Channel.Count());
                Assert.AreEqual(0, ctx.Productmapping.Count());
            }

            // Use a clean instance of the context to run the test
            using (var ctx = new FundstradingContext(options))
            {
                ProductMappingRepository repo = new ProductMappingRepository(ctx);
                ProductMappingService    productMappingservice = new ProductMappingService(repo);

                Productmapping productMapping = new Productmapping()
                {
                    Incoming  = "Incoming",
                    Outgoing  = "Outgoing",
                    Channelid = channelId
                };

                productMappingservice.CreateProductMapping(productMapping);

                var task = productMappingservice.ProductMappingList();
                task.Wait();
                var results = task.Result.ToList();
                Assert.AreEqual(1, results.Count);                // got row
                Assert.AreEqual("Incoming", results[0].Incoming); // got field value
                Assert.IsNotNull(results[0].Channel);
            }
        }
        public void ProductMappingListTest()
        {
            Task.Run(async() =>
            {
                DateTime now = DateTime.Now;

                var options = new DbContextOptionsBuilder <FundstradingContext>()
                              .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                              .Options;

                // Insert seed data into the database using one instance of the context
                using (var ctx = new FundstradingContext(options))
                {
                    ctx.Channel.Add(new Channel {
                        Description = "Description", Appid = "Appid", Apikey = "Apikey", Userid = "Userid", Baseurl = "Baseurl"
                    });
                    ctx.SaveChanges();
                    ctx.Productmapping.Add(new Productmapping {
                        Incoming = "Incoming", Outgoing = "Outgoing", Channelid = ctx.Channel.FirstOrDefault().Id
                    });
                    ctx.SaveChanges();

                    Assert.AreEqual(1, ctx.Channel.Count());
                    Assert.AreEqual(1, ctx.Productmapping.Count());
                }

                // Use a clean instance of the context to run the test
                using (var ctx = new FundstradingContext(options))
                {
                    ProductMappingRepository repo = new ProductMappingRepository(ctx);
                    ProductMappingService productMappingservice = new ProductMappingService(repo);

                    var results            = await productMappingservice.ProductMappingList();
                    var productMappingRows = results.ToList();

                    Assert.AreEqual(1, productMappingRows.Count);                // got row
                    Assert.AreEqual("Incoming", productMappingRows[0].Incoming); // got field value
                    Assert.IsNotNull(productMappingRows[0].Channel);
                }
            }).GetAwaiter().GetResult();
        }