Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #267 from QuantozTechnology/rename_operationfeesta…
Browse files Browse the repository at this point in the history
…ts_to_feestats

Rename and redirect OperationFeeStats to FeeStats
  • Loading branch information
elucidsoft committed Jul 1, 2020
2 parents b2d37e6 + 92700f5 commit 6c1e9ee
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
namespace stellar_dotnet_sdk_test.requests
{
[TestClass]
public class OperationFeeRequestBuilderTest
public class FeeRequestBuilderTest
{
[TestMethod]
public void TestBuilder()
{
Server server = new Server("https://horizon-testnet.stellar.org");
Uri uri = server.OperationFeeStats.BuildUri();
Assert.AreEqual("https://horizon-testnet.stellar.org/operation_fee_stats", uri.ToString());
Uri uri = server.FeeStats.BuildUri();
Assert.AreEqual("https://horizon-testnet.stellar.org/fee_stats", uri.ToString());
}

[TestMethod]
public async Task TestExecute()
{
var jsonResponse = File.ReadAllText(Path.Combine("testdata", "operationFeeStats.json"));
var jsonResponse = File.ReadAllText(Path.Combine("testdata", "feeStats.json"));
var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
{
var fees = await server.OperationFeeStats.Execute();
OperationFeeStatsDeserializerTest.AssertTestData(fees);
var fees = await server.FeeStats.Execute();
FeeStatsDeserializerTest.AssertTestData(fees);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
namespace stellar_dotnet_sdk_test.responses
{
[TestClass]
public class OperationFeeStatsDeserializerTest
public class FeeStatsDeserializerTest
{
[TestMethod]
public void TestDeserialize()
{
var json = File.ReadAllText(Path.Combine("testdata", "operationFeeStats.json"));
var stats = JsonSingleton.GetInstance<OperationFeeStatsResponse>(json);
var json = File.ReadAllText(Path.Combine("testdata", "feeStats.json"));
var stats = JsonSingleton.GetInstance<FeeStatsResponse>(json);
AssertTestData(stats);
}

[TestMethod]
public void TestSerializeDeserialize()
{
var json = File.ReadAllText(Path.Combine("testdata", "operationFeeStats.json"));
var stats = JsonConvert.DeserializeObject<OperationFeeStatsResponse>(json);
var json = File.ReadAllText(Path.Combine("testdata", "feeStats.json"));
var stats = JsonConvert.DeserializeObject<FeeStatsResponse>(json);

var serialized = JsonConvert.SerializeObject(stats);
var back = JsonConvert.DeserializeObject<OperationFeeStatsResponse>(serialized);
var back = JsonConvert.DeserializeObject<FeeStatsResponse>(serialized);

Assert.AreEqual(stats.LastLedger, back.LastLedger);
Assert.AreEqual(stats.LastLedgerBaseFee, back.LastLedgerBaseFee);
Assert.AreEqual(stats.LedgerCapacityUsage, back.LedgerCapacityUsage);
}

public static void AssertTestData(OperationFeeStatsResponse stats)
public static void AssertTestData(FeeStatsResponse stats)
{
Assert.AreEqual(0.97m, stats.LedgerCapacityUsage);

Expand Down
2 changes: 1 addition & 1 deletion stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<None Update="testdata\operationPassiveOffer.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\operationFeeStats.json">
<None Update="testdata\feeStats.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\operationPathPaymentStrictSend.json">
Expand Down
2 changes: 1 addition & 1 deletion stellar-dotnet-sdk/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public RootResponse Root()

public OperationsRequestBuilder Operations => new OperationsRequestBuilder(_serverUri, _httpClient);

public OperationFeeStatsRequestBuilder OperationFeeStats => new OperationFeeStatsRequestBuilder(_serverUri, _httpClient);
public FeeStatsRequestBuilder FeeStats => new FeeStatsRequestBuilder(_serverUri, _httpClient);

public OrderBookRequestBuilder OrderBook => new OrderBookRequestBuilder(_serverUri, _httpClient);

Expand Down
23 changes: 23 additions & 0 deletions stellar-dotnet-sdk/requests/FeeStatsRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using stellar_dotnet_sdk.responses;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using stellar_dotnet_sdk.responses.operations;

namespace stellar_dotnet_sdk.requests
{
public class FeeStatsRequestBuilder : RequestBuilder<FeeStatsRequestBuilder>
{
public FeeStatsRequestBuilder(Uri serverURI, HttpClient httpClient)
: base(serverURI, "fee_stats", httpClient)
{
}

public async Task<FeeStatsResponse> Execute()
{
return await Execute<FeeStatsResponse>(BuildUri());
}
}
}
23 changes: 0 additions & 23 deletions stellar-dotnet-sdk/requests/OperationFeeStatsRequestBuilder.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace stellar_dotnet_sdk.responses
{
public class OperationFeeStatsResponse : Response
public class FeeStatsResponse : Response
{
[JsonProperty(PropertyName = "ledger_capacity_usage")]
public decimal LedgerCapacityUsage { get; }
Expand All @@ -18,8 +18,8 @@ public class OperationFeeStatsResponse : Response

[JsonProperty(PropertyName = "max_fee")]
public FeeStatsResponseData MaxFee { get; private set; }
public OperationFeeStatsResponse(decimal ledgerCapacityUsage, long lastLedgerBaseFee, uint lastLedger, FeeStatsResponseData feeCharged, FeeStatsResponseData maxFee)

public FeeStatsResponse(decimal ledgerCapacityUsage, long lastLedgerBaseFee, uint lastLedger, FeeStatsResponseData feeCharged, FeeStatsResponseData maxFee)
{
LedgerCapacityUsage = ledgerCapacityUsage;
LastLedgerBaseFee = lastLedgerBaseFee;
Expand Down

0 comments on commit 6c1e9ee

Please sign in to comment.