public void ProductMappingListTest()
        {
            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);
                var task = repo.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 ChannelListTest()
        {
            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();

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

            // Use a clean instance of the context to run the test
            using (var ctx = new FundstradingContext(options))
            {
                ProductMappingRepository repo = new ProductMappingRepository(ctx);
                var results = repo.ChannelList().ToList();
                Assert.AreEqual(1, results.Count);                      // got row
                Assert.AreEqual("Description", results[0].Description); // got field value
            }
        }
        public void UpdateProductMappingTest()
        {
            var options = new DbContextOptionsBuilder <FundstradingContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            Productmapping productMapping;
            Channel        channel2;

            // Insert seed data into the database using one instance of the context
            using (var ctx = new FundstradingContext(options))
            {
                Channel channel1 = new Channel {
                    Id = 1, Description = "Description", Appid = "Appid", Apikey = "Apikey", Userid = "Userid", Baseurl = "Baseurl"
                };
                channel2 = new Channel {
                    Id = 2, Description = "Description2", Appid = "Appid2", Apikey = "Apikey2", Userid = "Userid2", Baseurl = "Baseurl2"
                };

                ctx.Channel.Add(channel1);
                ctx.Channel.Add(channel2);
                ctx.SaveChanges();

                productMapping = new Productmapping {
                    Id = 1, Incoming = "Incoming", Outgoing = "Outgoing", Channelid = 1
                };

                ctx.Productmapping.Add(productMapping);
                ctx.SaveChanges();

                Assert.AreEqual(2, 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);

                productMapping.Incoming = "I";
                productMapping.Outgoing = "O";
                productMapping.Channel  = channel2;

                repo.UpdateProductMapping(productMapping);
            }

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

                var task = repo.FindProductMapping(1);
                task.Wait();
                Assert.IsNotNull(task.Result);
                Assert.AreEqual("I", task.Result.Incoming); // got field value
                Assert.AreEqual("O", task.Result.Outgoing); // got field value
                Assert.IsNotNull(task.Result.Channel);
                Assert.AreEqual(2, task.Result.Channelid);  // got field value
            }
        }
예제 #4
0
        public void ChannelListTest()
        {
            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();

                    Assert.AreEqual(1, ctx.Channel.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     = productMappingservice.ChannelList();
                    var channelRows = results.ToList();

                    Assert.AreEqual(1, channelRows.Count);                      // got row
                    Assert.AreEqual("Description", channelRows[0].Description); // got field value
                }
            }).GetAwaiter().GetResult();
        }
예제 #5
0
        public void SearchAsyncTest()
        {
            Task.Run(async() =>
            {
                const int TAKE = 10;

                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))
                {
                    for (int i = 0; i < TAKE * 2; i++)
                    {
                        ctx.Fixmessage.Add(new Fixmessage {
                            Datetime = DateTime.Now.AddSeconds(i)
                        });
                        ctx.SaveChanges();
                    }
                    Assert.AreEqual(TAKE * 2, ctx.Fixmessage.Count());
                }

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

                    SearchFixMessageService searchFixMessageService = new SearchFixMessageService(repo);
                    IEnumerable <Fixmessage> searchResult           = await searchFixMessageService.SearchAsync(TAKE);

                    Assert.AreEqual(TAKE, searchResult.Count());
                }
            }).GetAwaiter().GetResult();
        }
예제 #6
0
        public void SearchOrderAndRegistIdTest()
        {
            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.Fixmessage.Add(new Fixmessage {
                    Datetime = now.AddSeconds(0), Raw = Constants.SOH + Constants.TAG11 + "orderId" + Constants.SOH
                });
                ctx.Fixmessage.Add(new Fixmessage {
                    Datetime = now.AddSeconds(1), Raw = Constants.SOH + Constants.TAG513 + "registId" + Constants.SOH
                });
                ctx.SaveChanges();

                Assert.AreEqual(2, ctx.Fixmessage.Count());
            }

            // Use a clean instance of the context to run the test
            using (var ctx = new FundstradingContext(options))
            {
                FixMessageRepository repo = new FixMessageRepository(ctx);
                var task = repo.SearchOrderAndRegistIdAsync(now, "orderId", "registId", 0);
                task.Wait();
                var results = task.Result.ToList();
                Assert.AreEqual(2, results.Count);                                                              // test where
                Assert.IsTrue(results[0].Datetime < results[1].Datetime);                                       // test ascending sort
                Assert.AreEqual(Constants.SOH + Constants.TAG11 + "orderId" + Constants.SOH, results[0].Raw);   // found by orderId
                Assert.AreEqual(Constants.SOH + Constants.TAG513 + "registId" + Constants.SOH, results[1].Raw); // found by registId
            }
        }
예제 #7
0
        public void SearchTest()
        {
            const int TAKE = 10;

            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))
            {
                for (int i = 0; i < TAKE * 2; i++)
                {
                    ctx.Fixmessage.Add(new Fixmessage {
                        Datetime = DateTime.Now.AddSeconds(i)
                    });
                    ctx.SaveChanges();
                }
                Assert.AreEqual(TAKE * 2, ctx.Fixmessage.Count());
            }

            // Use a clean instance of the context to run the test
            using (var ctx = new FundstradingContext(options))
            {
                FixMessageRepository repo = new FixMessageRepository(ctx);
                var task = repo.SearchAsync(TAKE);
                task.Wait();
                var results = task.Result.ToList();
                Assert.AreEqual(TAKE, results.Count);                     // test take
                Assert.IsTrue(results[0].Datetime > results[1].Datetime); // test descending sort
            }
        }
예제 #8
0
        public void FindProductMappingTest()
        {
            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 {
                    Id = 1, 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 task = productMappingservice.FindProductMapping(1);
                task.Wait();
                Productmapping productMapping = task.Result;
                Assert.IsNotNull(productMapping);
                Assert.AreEqual(1, productMapping.Id);
                Assert.IsNotNull(productMapping.Channel);

                task = productMappingservice.FindProductMapping(2);
                task.Wait();
                productMapping = task.Result;
                Assert.IsNull(productMapping);
            }
        }
예제 #9
0
        public void SearchOrderAsyncTest()
        {
            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.Fixmessage.Add(new Fixmessage {
                        Datetime = now.AddSeconds(0), Raw = Constants.SOH + Constants.TAG11 + "orderId" + Constants.SOH
                    });
                    ctx.Fixmessage.Add(new Fixmessage {
                        Datetime = now.AddSeconds(1), Raw = Constants.SOH + Constants.TAG11 + "orderId" + Constants.SOH
                    });
                    ctx.Fixmessage.Add(new Fixmessage {
                        Datetime = now.AddSeconds(2), Raw = Constants.SOH + Constants.TAG11 + "orderId2" + Constants.SOH
                    });
                    ctx.SaveChanges();

                    Assert.AreEqual(3, ctx.Fixmessage.Count());
                }

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

                    SearchFixMessageService searchFixMessageService = new SearchFixMessageService(repo);
                    IEnumerable <Fixmessage> searchResult           = await searchFixMessageService.SearchOrderAsync(now, "orderId", 0);

                    Assert.AreEqual(2, searchResult.Count());
                }
            }).GetAwaiter().GetResult();
        }
예제 #10
0
 public ApiRequestRepository(FundstradingContext context) : base(context)
 {
 }
예제 #11
0
 public BaseRepository(FundstradingContext context)
 {
     _context = context;
 }
예제 #12
0
 public FixMessageRepository(FundstradingContext context) : base(context)
 {
 }
예제 #13
0
 public ProductMappingRepository(FundstradingContext context) : base(context)
 {
 }
예제 #14
0
 public ApiResponseRepository(FundstradingContext context) : base(context)
 {
 }