Unit test for TOR

This commit is contained in:
2024-03-07 22:56:00 -05:00
parent c52e5a0a9d
commit 8a7cd8fcf8
4 changed files with 46 additions and 21 deletions

View File

@@ -12,11 +12,11 @@
<add key="proxy_GetLatestPriceYahoo" value="false"/>
<add key="proxy_GetLatestPriceFidelity" value="true"/>
<add key="proxy_GetLatestPriceBigCharts" value="false"/>
<add key="proxy_GetETFHoldings" value="false"/>
<add key="proxy_GetETFHoldings" value="true"/>
<add key="proxy_GetAnalystPriceTargetYahoo" value="true"/>
<add key="proxy_GetDailyPrices" value="false"/>
<add key="proxy_GetCompanyHeadlines" value="true"/>
<!--<add key="proxy_GetFundamentalEx" value="true"/>-->
<add key="proxy_GetFundamentalEx" value="false"/>
<add key="proxy_GetDividendHistory" value="false"/>
<!--<add key="proxy_GetAnalystPriceTargetMarketBeat" value="false"/>-->
</appSettings>

View File

@@ -6,6 +6,8 @@ using MarketData.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace MarketDataUnitTests
{
@@ -13,19 +15,35 @@ namespace MarketDataUnitTests
public class MarketDataFeedTests
{
// This test is for the TOT Feed
[TestMethod]
public void ETFHoldsingsYahooRetrieval()
public void TORFeedRetrieval()
{
String etfSymbol="ACWX";
ETFHoldings etfHoldings=MarketDataHelper.GetETFHoldings(etfSymbol);
Assert.IsTrue(null!=etfHoldings && etfHoldings.Count>0);
bool result = MarketDataHelper.GetWorldTime();
Assert.IsTrue(result,"TORFeedFailed");
}
[TestMethod]
public void ETFHoldingsYahooRetrieval()
{
String[] etfSymbols={"JFNNX","ACWX","ACES","BBH"};
List<ETFHoldings> results = new List<ETFHoldings>();
foreach(String etfSymbol in etfSymbols)
{
results.Add(MarketDataHelper.GetETFHoldings(etfSymbol));
try{Thread.Sleep(500);}catch(Exception){;}
}
Assert.IsTrue(results.Any(x => x!=null),String.Format("{0} items failed.",etfSymbols.Length));
}
[TestMethod]
public void ConsumerPriceIndexBureauOfLaborStatisticsRetrieval()
public void LatestPriceXXXRetrieval()
{
PriceIndices priceIndices = MarketDataHelper.GetConsumerPriceIndices();
Assert.IsTrue(null!=priceIndices && priceIndices.Count>0);
String symbol="ACWX";
Price price=MarketDataHelper.GetLatestPriceGoogle(symbol);
Assert.IsTrue(null!=price && price.IsValid);
}
[TestMethod]
@@ -37,8 +55,23 @@ namespace MarketDataUnitTests
Assert.IsTrue(price.IsValid,"Invalid Price");
}
[TestMethod]
public void LatestPriceBigChartsRetrieval()
{
String symbol="AAPL";
Price price=MarketDataHelper.GetLatestPriceBigCharts(symbol);
Assert.IsTrue(null!=price,"No Price");
Assert.IsTrue(price.IsValid,"Invalid Price");
}
[TestMethod]
public void ConsumerPriceIndexBureauOfLaborStatisticsRetrieval()
{
PriceIndices priceIndices = MarketDataHelper.GetConsumerPriceIndices();
Assert.IsTrue(null!=priceIndices && priceIndices.Count>0);
}
// This test only passes when the web proxy is bypassed
// Yahoo Fundamental feed is very poor quality and lots of misses. It's a last resort.
[TestMethod]
public void FundamentalYahooRetrieval()
@@ -46,7 +79,7 @@ namespace MarketDataUnitTests
String symbol = "AAPL";
Fundamental fundamental=MarketDataHelper.GetFundamental(symbol);
Assert.IsTrue(null!=fundamental);
// Assert.IsTrue(!Utility.IsEpoch(fundamental.NextEarningsDate),"NextEarningsDate");
Assert.IsTrue(!Utility.IsEpoch(fundamental.NextEarningsDate),"NextEarningsDate");
// Assert.IsTrue(!double.IsNaN(fundamental.Beta),"Beta");
Assert.IsTrue(!double.IsNaN(fundamental.Low52),"Low52");
Assert.IsTrue(!double.IsNaN(fundamental.High52),"High52");
@@ -61,7 +94,7 @@ namespace MarketDataUnitTests
// Assert.IsTrue(!double.IsNaN(fundamental.TotalDebt),"TotalDebt");
// Assert.IsTrue(!double.IsNaN(fundamental.SharesOutstanding),"SharesOutstanding");
// Assert.IsTrue(!double.IsNaN(fundamental.Revenue),"Revenue");
Assert.IsTrue(!double.IsNaN(fundamental.RevenuePerShare),"RevenuePerShare");
// Assert.IsTrue(!double.IsNaN(fundamental.RevenuePerShare),"RevenuePerShare");
Assert.IsTrue(!double.IsNaN(fundamental.QtrlyRevenueGrowth),"QtrlyRevenueGrowth");
// Assert.IsTrue(!double.IsNaN(fundamental.GrossProfit),"GrossProfit");
Assert.IsTrue(!double.IsNaN(fundamental.EBITDA),"EBITDA");
@@ -237,7 +270,7 @@ namespace MarketDataUnitTests
}
[TestMethod]
public void IncomeStatementNASDAQRetrievsl()
public void IncomeStatementNASDAQRetrieval()
{
String symbol="MIDD";
List<IncomeStatement> incomeStatements=MarketDataHelper.GetIncomeStatementNASDAQ(symbol,IncomeStatement.PeriodType.Annual);
@@ -339,14 +372,6 @@ namespace MarketDataUnitTests
Assert.IsTrue(!double.IsNaN(fundamental.DebtToEquity),"DebtToEquity");
}
[TestMethod]
public void LatestPriceBigChartsRetrieval()
{
String symbol="MIDD";
Price price=MarketDataHelper.GetLatestPriceBigCharts(symbol);
Assert.IsTrue(null!=price,"No Price");
Assert.IsTrue(price.IsValid,"Invalid Price");
}
[TestMethod]
public void GetPriceAsOfBigChartsRetrieval()