33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using YLErp.DBModels;
|
|
using YLErp.Models;
|
|
using YLErp.QdpModule.Constants;
|
|
|
|
namespace YLErp.Modules.VolatilityModule
|
|
{
|
|
[TestClass]
|
|
public class VolatilityBasicTest
|
|
{
|
|
[TestMethod("测试波动率数据序列化")]
|
|
public void TestSerialize()
|
|
{
|
|
var date = new DateTime(2020, 4, 23);
|
|
|
|
var vola = VolatilityBuilder.CreateMoneynessVolBuilder(date)
|
|
.SetUnderlying(111, "RB2005").SetData(0.25533333).Build();
|
|
|
|
Assert.AreEqual(vola.QuotationDate, date);
|
|
Assert.AreEqual(vola.VolType, ConsVolInfos.defVolType);
|
|
Assert.AreEqual(vola.VolSurfaceMode, ConsVolInfos.defVolMode);
|
|
Assert.AreEqual(vola.UnderlyingId, 111);
|
|
Assert.AreEqual(vola.ContractCode, "RB2005");
|
|
|
|
var list = JsonHelper.Deserialize<List<SingleVol>>(vola.Data);
|
|
|
|
Assert.AreEqual(0.255333, list[0].Vol);
|
|
}
|
|
}
|
|
}
|