コード例 #1
0
        public void TestMethod1()
        {
            string stockCode = "600036";
            var insertData = ExampleParticipation_600036(DateTime.Now);

            string dataFile = DataFiles.GetParticipationFile(stockCode);
            if (File.Exists(dataFile))
            {
                File.Delete(dataFile);
            }

            var appService = new ParticipationAppService();

            // 测试插入数据
            appService.Add(stockCode, insertData);
            Assert.IsTrue(appService.Exists(stockCode, insertData));

            // 测试更新数据
            insertData.CostPrice1Day = 100.00;
            appService.Update(stockCode, insertData);

            insertData.CostPrice20Day = 200.00;
            appService.Update(stockCode, insertData);

            Assert.IsTrue(appService.Exists(stockCode, insertData));

            // 测试读取数据
            var participations = appService.Get(stockCode).ToList();
            Assert.IsNotNull(participations);
            Assert.IsTrue(participations.Count == 1);
            Assert.AreEqual(insertData.Time, participations[0].Time);
            Assert.AreEqual(insertData.CostPrice1Day, participations[0].CostPrice1Day);
            Assert.AreEqual(insertData.CostPrice20Day, participations[0].CostPrice20Day);
        }
コード例 #2
0
 public IEnumerable<ParticipationDto> Get(string stockCode)
 {
     #if DEBUG
     /*test code for communication*************************************/
     var dto = new ParticipationDto()
     {
         CostPrice1Day = 20,
         CostPrice20Day = 30,
         Time = new System.DateTime(1999, 9, 9, 9, 9, 9)
     };
     var result = new List<ParticipationDto>();
     result.Add(dto);
     return result;
     /*test code for communication*************************************/
     #else
     var appService = new ParticipationAppService();
     return appService.Get(stockCode).ToDto();
     #endif
 }