Files
managing-apps/src/Managing.Infrastructure.Tests/TradaoTests.cs
Oda 029ba5f40e Add funding rate watcher (#2)
* Add FundingRate interfaces and worker

* Add build on PR

* Remove zip

* Specify the solution path

* Add build for worker too

* Set up StatisticService.cs for funding rate

* Add Fundingrate alerts

* Send alert when big funding rate change + add SlashCommands.cs for fundingrate

* Remove fixtures

* Refact names

* Renames
2024-07-19 08:31:09 +07:00

66 lines
1.6 KiB
C#

using Managing.Domain.Shared.Helpers;
using Managing.Infrastructure.Evm.Services;
using Xunit;
namespace Managing.Infrastructure.Tests;
public class TradaoTests
{
private readonly TradaoService _tradaoService;
public TradaoTests()
{
_tradaoService = new TradaoService();
}
[Fact]
public async void Should_return_best_trader()
{
var service = new TradaoService();
var details = await service.GetBestTrader();
Assert.NotNull(details);
}
[Fact]
public async void Should_return_bad_trader()
{
var service = new TradaoService();
var details = (await service.GetBadTrader()).FindBadTrader();
Assert.NotNull(details);
}
[Fact]
public async void Should_return_funding_rates()
{
var service = new TradaoService();
var details = await service.GetFundingRates();
Assert.NotNull(details);
}
[Fact]
public void GetApy_WithPositiveRate_ReturnsExpectedPositiveApy()
{
var result = _tradaoService.GetApy("0.0055");
Assert.True(result > 48m);
}
[Fact]
public void GetApy_WithNegativeRate_ReturnsPositiveApy()
{
var result = _tradaoService.GetApy("-0.00834530");
Assert.True(result < -73m);
}
[Fact]
public void GetApy_WithZeroRate_ReturnsZeroApy()
{
var result = _tradaoService.GetApy("0");
Assert.Equal(0m, result);
}
[Fact]
public void GetApy_WithInvalidFormat_ThrowsFormatException()
{
Assert.Throws<FormatException>(() => _tradaoService.GetApy("invalid"));
}
}