public static Security ToDataObject(this ISecurity self) { Security outputData = new Security { Code = self.Code, ShortName = self.ShortName, Market = self.Market, Type = self.Type }; return outputData; }
public void TestWorkFlow() { var security = new Security { Code = "600036", Market = Market.XSHG, ShortName = "招商银行", Type = SecurityType.Sotck }; DateTime beginTime = DateTime.Now.AddDays(-15); DateTime endTime = DateTime.Now; var battleship = new SimulationBattleship(security, beginTime); var battlefield = new Battlefield(security); battlefield.Practice(battleship, beginTime, endTime); }
public void TestSecurityReadAndWrite() { Security insertData = new Security() { Code = "600036", ShortName = "招商银行招商银行招商银行", Market = Market.XSHG, Type = SecurityType.Sotck }; string fileName = "Security.sdf"; string fullPath = Path.Combine(directory, fileName); // Add using (IRepositoryContext context = ContextFactory.Create(ContextType.Security, fullPath)) { var repository = new Repository<Security>(context); repository.Add(insertData); repository.UnitOfWork.Commit(); } // Read Security readData; using (IRepositoryContext context = ContextFactory.Create(ContextType.Security, fullPath)) { var repository = new Repository<Security>(context); readData = repository.Get(insertData.Code); } Assert.IsNotNull(readData); Assert.AreEqual(insertData.ShortName, readData.ShortName); }
public void TestMethod_Security() { string filePath = Path.Combine(Environment.CurrentDirectory, "TestSecurity.sdf"); if (File.Exists(filePath)) { File.Delete(filePath); } List<ISecurity> securities = ExampleSecurities(); System.Diagnostics.Debug.Print(string.Format("Security data count is {0}", securities.Count)); SecurityRepository repository = new SecurityRepository(filePath); repository.AddRange(securities); ISecurity get = repository.Get(securities[0].Code); Assert.IsTrue(repository.Exists(securities[0])); Assert.IsFalse(repository.Exists(ExampleSecurity())); var updateData = new Security { Code = "600518", Market = Market.XSHG, ShortName = "康*美*药*业", Type = SecurityType.Unknown }; repository.UpdateRange(new ISecurity[] { updateData }); IList<ISecurity> result0 = repository.GetAll().ToList(); Assert.IsTrue(repository.Exists(updateData)); List<ISecurity> updateSecurities = GetUpdateSecurityDatas(securities).ToList(); repository.UpdateRange(updateSecurities); IList<ISecurity> result = repository.GetAll().ToList(); if (result != null && result.Count > 0) { System.Diagnostics.Debug.Print(string.Format("Security Data count is {0}", result.Count)); } Assert.AreEqual(securities.Count, result.Count); }