From a1ebedc0d10cef545f9f0bda3768bc57c5a4b66b Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Fri, 12 Jan 2018 16:54:57 +0900 Subject: [PATCH] Fix unit test --- BTCPayServer.Tests/UnitTest1.cs | 8 +++++++- BTCPayServer/Services/Invoices/InvoiceEntity.cs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 5da4bc4c1..6eee9385c 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -43,8 +43,14 @@ namespace BTCPayServer.Tests entity.TxFee = Money.Coins(0.1m); entity.Rate = 5000; - var cryptoData = entity.GetCryptoData("BTC", null); + var cryptoData = entity.GetCryptoData("BTC", null, true); Assert.NotNull(cryptoData); // Should use legacy data to build itself + Assert.Null(entity.GetCryptoData("BTC", null, false)); + entity.SetCryptoData(new CryptoData() { ParentEntity = entity, Rate = entity.Rate, CryptoCode = "BTC", TxFee = entity.TxFee, FeeRate = new FeeRate(entity.TxFee, 100), DepositAddress = entity.DepositAddress, Network = null }); + Assert.NotNull(entity.GetCryptoData("BTC", null, false)); + Assert.NotNull(entity.GetCryptoData("BTC", null, true)); + + entity.Payments = new System.Collections.Generic.List(); entity.ProductInformation = new ProductInformation() { Price = 5000 }; diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 614117158..8c586309d 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -395,9 +395,9 @@ namespace BTCPayServer.Services.Invoices return rates.TryGetValue(network.CryptoCode, out var data); } - public CryptoData GetCryptoData(string cryptoCode, BTCPayNetworkProvider networkProvider) + public CryptoData GetCryptoData(string cryptoCode, BTCPayNetworkProvider networkProvider, bool alwaysIncludeBTC = false) { - GetCryptoData(networkProvider).TryGetValue(cryptoCode, out var data); + GetCryptoData(networkProvider, alwaysIncludeBTC).TryGetValue(cryptoCode, out var data); return data; }