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_GetLatestPriceYahoo" value="false"/>
<add key="proxy_GetLatestPriceFidelity" value="true"/> <add key="proxy_GetLatestPriceFidelity" value="true"/>
<add key="proxy_GetLatestPriceBigCharts" value="false"/> <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_GetAnalystPriceTargetYahoo" value="true"/>
<add key="proxy_GetDailyPrices" value="false"/> <add key="proxy_GetDailyPrices" value="false"/>
<add key="proxy_GetCompanyHeadlines" value="true"/> <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_GetDividendHistory" value="false"/>
<!--<add key="proxy_GetAnalystPriceTargetMarketBeat" value="false"/>--> <!--<add key="proxy_GetAnalystPriceTargetMarketBeat" value="false"/>-->
</appSettings> </appSettings>

View File

@@ -6,6 +6,8 @@ using MarketData.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace MarketDataUnitTests namespace MarketDataUnitTests
{ {
@@ -13,19 +15,35 @@ namespace MarketDataUnitTests
public class MarketDataFeedTests public class MarketDataFeedTests
{ {
// This test is for the TOT Feed
[TestMethod] [TestMethod]
public void ETFHoldsingsYahooRetrieval() public void TORFeedRetrieval()
{ {
String etfSymbol="ACWX"; bool result = MarketDataHelper.GetWorldTime();
ETFHoldings etfHoldings=MarketDataHelper.GetETFHoldings(etfSymbol); Assert.IsTrue(result,"TORFeedFailed");
Assert.IsTrue(null!=etfHoldings && etfHoldings.Count>0); }
[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] [TestMethod]
public void ConsumerPriceIndexBureauOfLaborStatisticsRetrieval() public void LatestPriceXXXRetrieval()
{ {
PriceIndices priceIndices = MarketDataHelper.GetConsumerPriceIndices(); String symbol="ACWX";
Assert.IsTrue(null!=priceIndices && priceIndices.Count>0); Price price=MarketDataHelper.GetLatestPriceGoogle(symbol);
Assert.IsTrue(null!=price && price.IsValid);
} }
[TestMethod] [TestMethod]
@@ -37,8 +55,23 @@ namespace MarketDataUnitTests
Assert.IsTrue(price.IsValid,"Invalid Price"); 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. // Yahoo Fundamental feed is very poor quality and lots of misses. It's a last resort.
[TestMethod] [TestMethod]
public void FundamentalYahooRetrieval() public void FundamentalYahooRetrieval()
@@ -46,7 +79,7 @@ namespace MarketDataUnitTests
String symbol = "AAPL"; String symbol = "AAPL";
Fundamental fundamental=MarketDataHelper.GetFundamental(symbol); Fundamental fundamental=MarketDataHelper.GetFundamental(symbol);
Assert.IsTrue(null!=fundamental); 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.Beta),"Beta");
Assert.IsTrue(!double.IsNaN(fundamental.Low52),"Low52"); Assert.IsTrue(!double.IsNaN(fundamental.Low52),"Low52");
Assert.IsTrue(!double.IsNaN(fundamental.High52),"High52"); 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.TotalDebt),"TotalDebt");
// Assert.IsTrue(!double.IsNaN(fundamental.SharesOutstanding),"SharesOutstanding"); // Assert.IsTrue(!double.IsNaN(fundamental.SharesOutstanding),"SharesOutstanding");
// Assert.IsTrue(!double.IsNaN(fundamental.Revenue),"Revenue"); // 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.QtrlyRevenueGrowth),"QtrlyRevenueGrowth");
// Assert.IsTrue(!double.IsNaN(fundamental.GrossProfit),"GrossProfit"); // Assert.IsTrue(!double.IsNaN(fundamental.GrossProfit),"GrossProfit");
Assert.IsTrue(!double.IsNaN(fundamental.EBITDA),"EBITDA"); Assert.IsTrue(!double.IsNaN(fundamental.EBITDA),"EBITDA");
@@ -237,7 +270,7 @@ namespace MarketDataUnitTests
} }
[TestMethod] [TestMethod]
public void IncomeStatementNASDAQRetrievsl() public void IncomeStatementNASDAQRetrieval()
{ {
String symbol="MIDD"; String symbol="MIDD";
List<IncomeStatement> incomeStatements=MarketDataHelper.GetIncomeStatementNASDAQ(symbol,IncomeStatement.PeriodType.Annual); List<IncomeStatement> incomeStatements=MarketDataHelper.GetIncomeStatementNASDAQ(symbol,IncomeStatement.PeriodType.Annual);
@@ -339,14 +372,6 @@ namespace MarketDataUnitTests
Assert.IsTrue(!double.IsNaN(fundamental.DebtToEquity),"DebtToEquity"); 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] [TestMethod]
public void GetPriceAsOfBigChartsRetrieval() public void GetPriceAsOfBigChartsRetrieval()