Skip to content

Commit

Permalink
Remove redundant type specifier in new calls
Browse files Browse the repository at this point in the history
  • Loading branch information
KUTlime committed Oct 27, 2023
1 parent f8ee631 commit 987b362
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<StockName> GetStockName(string stockId, CancellationToken toke
var topStockSymbol = validatedResponse.Results.FirstOrDefault();
var stockSymbol = Contract.Check(
topStockSymbol, _symbolResponseMapper, "Finnhub stock symbol result contract failure. The given stock symbol can't be found.");
return new StockName(stockSymbol.Description, stockSymbol.Symbol);
return new(stockSymbol.Description, stockSymbol.Symbol);
}

internal record FinnhubSymbolResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public async Task<Stock> GetStockWithActualPrice(StockName stockName, Cancellati
var result = JsonSerializer.Deserialize<QuoteResponse>(response);
var priceRaw = result ?? throw new EmptyStockPriceException($"{stockName.Name} with symbol: {stockName.Abbreviation}");
var price = Contract.Check(priceRaw, _mapper, "Finnhub stock price quote contract failure.");
return new Stock(
new StockName(validStockName.Result.Name, validStockName.Result.Abbreviation),
new DTOs.StockPrice(price.Current, price.High, price.Low, price.Open, price.PreviousClose, price.Time));
return new(
new(validStockName.Result.Name, validStockName.Result.Abbreviation),
new(price.Current, price.High, price.Low, price.Open, price.PreviousClose, price.Time));
}

internal record QuoteResponse
Expand Down
4 changes: 2 additions & 2 deletions src/Presentation/Kutlime.StockValue.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static async Task<Stock> TryGetStockValue(IStockProvider stockProvider,
{
try
{
return await stockProvider.GetStockWithActualPrice(new StockName(stockName, stockName), cancellationToken);
return await stockProvider.GetStockWithActualPrice(new(stockName, stockName), cancellationToken);
}
catch (AggregateException e) when (e.InnerExceptions.Any(ex => ex is OperationCanceledException or TaskCanceledException))
{
Expand All @@ -27,7 +27,7 @@ private static async Task<Stock> TryGetStockValue(IStockProvider stockProvider,
System.Console.WriteLine(e.Message);
}

return new Stock(new StockName(string.Empty, string.Empty), new StockPrice(0, 0, 0, 0, 0, 0));
return new(new(string.Empty, string.Empty), new(0, 0, 0, 0, 0, 0));
}

private static CancellationTokenSource RegisterCancellationToken()
Expand Down

0 comments on commit 987b362

Please sign in to comment.