从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YLErp.Modules.DataProviderModule
|
||||
{
|
||||
[TestClass]
|
||||
public class EodExchangeOptionPriceProviderTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void Test()
|
||||
{
|
||||
var optionCode = "DB00-C-7000";
|
||||
var provider = new EodExchangeOptionPriceProvider(new DateTime(2023,1,9), true);
|
||||
var price = provider.GetPrice(optionCode);
|
||||
Assert.AreEqual(price, 0);
|
||||
var bl = provider.TryGetPrice(optionCode, out price);
|
||||
Assert.IsFalse(bl);
|
||||
Assert.AreEqual(price, 0);
|
||||
bl = provider.TryGetPriceModel(optionCode, out var data);
|
||||
Assert.IsFalse(bl);
|
||||
Assert.AreEqual(data, null);
|
||||
|
||||
price = provider.GetPrice(null);
|
||||
Assert.AreEqual(price, 0);
|
||||
bl = provider.TryGetPrice(null, out price);
|
||||
Assert.IsFalse(bl);
|
||||
Assert.AreEqual(price, 0);
|
||||
bl = provider.TryGetPriceModel(null, out data);
|
||||
Assert.IsFalse(bl);
|
||||
Assert.AreEqual(data, null);
|
||||
|
||||
optionCode = "RB00-C-5000";
|
||||
provider.Initialize(new[] { optionCode });
|
||||
price = provider.GetPrice(optionCode);
|
||||
Assert.AreEqual(price, 520);
|
||||
bl = provider.TryGetPrice(optionCode, out price);
|
||||
Assert.IsTrue(bl);
|
||||
Assert.AreEqual(price, 520);
|
||||
bl = provider.TryGetPriceModel(optionCode, out data);
|
||||
Assert.IsTrue(bl);
|
||||
Assert.AreEqual(data.ClosePrice, 520);
|
||||
|
||||
provider = new EodExchangeOptionPriceProvider(new DateTime(2023, 1, 9), true).InitializeAll();
|
||||
optionCode = "RB00-C-5000";
|
||||
price = provider.GetPrice(optionCode);
|
||||
Assert.AreEqual(price, 520);
|
||||
bl = provider.TryGetPrice(optionCode, out price);
|
||||
Assert.IsTrue(bl);
|
||||
Assert.AreEqual(price, 520);
|
||||
bl = provider.TryGetPriceModel(optionCode, out data);
|
||||
Assert.IsTrue(bl);
|
||||
Assert.AreEqual(data.ClosePrice, 520);
|
||||
|
||||
optionCode = "DB00-C-7000";
|
||||
price = provider.GetPrice(optionCode);
|
||||
Assert.AreEqual(price, 0);
|
||||
bl = provider.TryGetPrice(optionCode, out price);
|
||||
Assert.IsFalse(bl);
|
||||
Assert.AreEqual(price, 0);
|
||||
bl = provider.TryGetPriceModel(optionCode, out data);
|
||||
Assert.IsFalse(bl);
|
||||
Assert.AreEqual(data, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user