From ae61f051b5da0f0061fb292a939409f26686e7d3 Mon Sep 17 00:00:00 2001 From: Oleg Rakhmatulin Date: Sun, 14 Apr 2024 15:10:18 +0200 Subject: [PATCH] Issue #472 - Code coverage increased for after latest changes in code. (cherry picked from commit 2e4dd434a1dfefe1402928ba9bd066557466c9ee) --- Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs | 5 ++++- Alpaca.Markets.Tests/RequestValidationTest.cs | 8 ++++++++ Alpaca.Markets/Parameters/PortfolioHistoryRequest.cs | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs index e60df5f0..bb80c021 100644 --- a/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs +++ b/Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs @@ -179,8 +179,11 @@ public async Task GetPortfolioHistoryAsyncWorks() var history = await mock.Client.GetPortfolioHistoryAsync( new PortfolioHistoryRequest { + Period = new HistoryPeriod(1, HistoryPeriodUnit.Week), + IntradayReporting = IntradayReporting.Continuous, + IntradayProfitLoss = IntradayProfitLoss.PerDay, TimeFrame = TimeFrame.FifteenMinutes - }.WithInterval(new Interval(today, today))); + }); Assert.Equal(Price, history.BaseValue); diff --git a/Alpaca.Markets.Tests/RequestValidationTest.cs b/Alpaca.Markets.Tests/RequestValidationTest.cs index 9946a5fa..e51b6aad 100644 --- a/Alpaca.Markets.Tests/RequestValidationTest.cs +++ b/Alpaca.Markets.Tests/RequestValidationTest.cs @@ -91,6 +91,14 @@ public void OrderBaseNegativeQuantityValidationWorks() => public void ListOrdersRequestEmptySymbolValidationWorks() => validate(new ListOrdersRequest().WithSymbol(String.Empty)); + [Fact] + public void PortfolioHistoryRequestEmptySymbolValidationWorks() => + validate(new PortfolioHistoryRequest + { + Period = new HistoryPeriod(1, HistoryPeriodUnit.Week) + } + .WithInterval(new Interval(DateTime.Today, DateTime.Today))); + [Fact] public void CalendarRequestConstructorWorks() { diff --git a/Alpaca.Markets/Parameters/PortfolioHistoryRequest.cs b/Alpaca.Markets/Parameters/PortfolioHistoryRequest.cs index bcb2b3ac..670cbd5f 100644 --- a/Alpaca.Markets/Parameters/PortfolioHistoryRequest.cs +++ b/Alpaca.Markets/Parameters/PortfolioHistoryRequest.cs @@ -50,6 +50,7 @@ public sealed class PortfolioHistoryRequest : Validation.IRequest /// This is effective only for time frame less than 1 day. /// [UsedImplicitly] + [ExcludeFromCodeCoverage] [Obsolete("Use the DateInterval property instead of this one.", false)] public Boolean? ExtendedHours { get; set; } @@ -89,6 +90,7 @@ public PortfolioHistoryRequest WithInterval( /// New filtering interval. /// Request with applied filtering. [UsedImplicitly] + [ExcludeFromCodeCoverage] [MethodImpl(MethodImplOptions.AggressiveInlining)] [Obsolete("Use the override that gets Interval instead of this one.", true)] public PortfolioHistoryRequest WithInterval(