Skip to content

Commit

Permalink
Fixed many issues found by the latest version of the R# tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegRa committed Apr 12, 2024
1 parent 361e0f0 commit ca07d55
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class AlpacaCryptoStreamingClientTest

private const String Other = "ETHUSD";

[Fact(Skip = "Temporary until Extensions package upgrade")]
[Fact]
public async Task WithReconnectWorks()
{
var client = createMockClient(
Expand Down Expand Up @@ -57,7 +57,6 @@ public async Task SubscribeOrderBookAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeDailyBarAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}

Expand Down Expand Up @@ -64,7 +63,6 @@ public async Task SubscribeMinuteBarAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}

Expand Down Expand Up @@ -97,7 +95,6 @@ public async Task SubscribeUpdatedBarAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeCancellationAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeCorrectionAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeLimitUpLimitDownAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeQuoteAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeStatusAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubscribeTradeAsyncWorks()
verifySubscriptions(subscriptionOne, subscriptionTwo);
verifySubscriptionEvents(subscription, ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public async Task SubscribeNewsAsyncWorks()
_symbols.VerifySubscriptionsStreams(subscriptionOne, subscriptionTwo);
subscription.VerifySubscriptionEventsNumber(ExpectedNumberOfEventsForOneSymbol);

await subscriptionOne.DisposeAsync();
client.VerifyAll();
}

Expand Down
1 change: 0 additions & 1 deletion Alpaca.Markets.Tests/AlpacaTradingClientTest.Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public async Task GetPortfolioHistoryAsyncWorks()
var history = await mock.Client.GetPortfolioHistoryAsync(
new PortfolioHistoryRequest
{
Period = new HistoryPeriod(5, HistoryPeriodUnit.Day),
TimeFrame = TimeFrame.FifteenMinutes
}.WithInterval(new Interval<DateTime>(today, today)));

Expand Down
2 changes: 1 addition & 1 deletion Alpaca.Markets/Enums/PositionIntent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ public enum PositionIntent
/// </summary>
[UsedImplicitly]
[EnumMember(Value = "sell_to_close")]
SellToClose,
SellToClose
}
22 changes: 11 additions & 11 deletions Alpaca.Markets/Helpers/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,79 +55,79 @@ public static TRequest Validate<TRequest>(

public static RequestValidationException? TryValidateSymbolName(
this String symbolName,
[CallerArgumentExpression("symbolName")] String propertyName = "") =>
[CallerArgumentExpression(nameof(symbolName))] String propertyName = "") =>
String.IsNullOrWhiteSpace(symbolName)
? new RequestValidationException(SymbolShouldNotBeEmptyMessage, propertyName)
: null;

public static RequestValidationException? TryValidateSymbolName(
this IEnumerable<String> symbolNames,
[CallerArgumentExpression("symbolNames")] String propertyName = "") =>
[CallerArgumentExpression(nameof(symbolNames))] String propertyName = "") =>
symbolNames.Any(String.IsNullOrWhiteSpace)
? new RequestValidationException(SymbolShouldNotBeEmptyMessage, propertyName)
: null;

public static RequestValidationException? TryValidateQuantity(
this OrderQuantity quantity,
[CallerArgumentExpression("quantity")] String propertyName = "") =>
[CallerArgumentExpression(nameof(quantity))] String propertyName = "") =>
quantity.Value <= 0M
? new RequestValidationException(OrderQuantityShouldBePositiveMessage, propertyName)
: null;

public static RequestValidationException? TryValidateQuantity(
this Int64? quantity,
[CallerArgumentExpression("quantity")] String propertyName = "") =>
[CallerArgumentExpression(nameof(quantity))] String propertyName = "") =>
quantity <= 0M
? new RequestValidationException(OrderQuantityShouldBePositiveMessage, propertyName)
: null;

public static RequestValidationException? TryValidatePageSize(
this Pagination pagination,
UInt32 maxPageSize,
[CallerArgumentExpression("pagination")] String propertyName = "") =>
[CallerArgumentExpression(nameof(pagination))] String propertyName = "") =>
pagination.Size < Pagination.MinPageSize || pagination.Size > maxPageSize
? new RequestValidationException(RequestPageSizeTooBigOrTooSmallMessage, propertyName)
: null;

public static RequestValidationException? TryValidateSymbolsList(
this IReadOnlyCollection<String> symbolNames,
[CallerArgumentExpression("symbolNames")] String propertyName = "") =>
[CallerArgumentExpression(nameof(symbolNames))] String propertyName = "") =>
symbolNames.Count == 0
? new RequestValidationException(ListShouldContainsAtLeastOneItemMessage, propertyName)
: null;

public static RequestValidationException? TryValidateWatchListName(
this String? watchListName,
[CallerArgumentExpression("watchListName")] String propertyName = "") =>
[CallerArgumentExpression(nameof(watchListName))] String propertyName = "") =>
isWatchListNameInvalid(watchListName)
? new RequestValidationException(WatchListNameShouldBe64CharactersLengthMessage, propertyName)
: null;

public static RequestValidationException? TryValidateWatchListName<TKey>(
this TKey watchListName,
[CallerArgumentExpression("watchListName")] String propertyName = "") =>
[CallerArgumentExpression(nameof(watchListName))] String propertyName = "") =>
watchListName is String stringKey && isWatchListNameInvalid(stringKey)
? new RequestValidationException(WatchListNameShouldBe64CharactersLengthMessage, propertyName)
: null;

public static RequestValidationException? TryValidateCollection<TItem>(
this IReadOnlyCollection<TItem> collection,
[CallerArgumentExpression("collection")] String propertyName = "") =>
[CallerArgumentExpression(nameof(collection))] String propertyName = "") =>
collection.Count == 0
? new RequestValidationException(CollectionShouldNotBeEmptyMessage, propertyName)
: null;

public static RequestValidationException? TryValidateInterval<TItem>(
this Interval<TItem> interval,
[CallerArgumentExpression("interval")] String propertyName = "")
[CallerArgumentExpression(nameof(interval))] String propertyName = "")
where TItem : struct, IComparable<TItem> =>
interval.IsOpen()
? new RequestValidationException(IntervalShouldNotBeOpenMessage, propertyName)
: null;

public static String? ValidateWatchListName(
this String? watchListName,
[CallerArgumentExpression("watchListName")] String propertyName = "") =>
[CallerArgumentExpression(nameof(watchListName))] String propertyName = "") =>
isWatchListNameInvalid(watchListName)
? throw new ArgumentException(WatchListNameShouldBe64CharactersLengthMessage, propertyName)
: watchListName;
Expand Down

0 comments on commit ca07d55

Please sign in to comment.