Files
.circleci
.github
BTCPayServer
BTCPayServer.Common
BTCPayServer.Data
BTCPayServer.Rating
BTCPayServer.Tests
Lnd
Logging
Mocks
Properties
TestData
AuthenticationTests.cs
BTCPayServer.Tests.csproj
BTCPayServerTester.cs
ChangellyTests.cs
ChargeTester.cs
CheckoutUITests.cs
CoinSwitchTests.cs
CrowdfundTests.cs
CustomerHttpServer.cs
Dockerfile
ElementsTests.cs
Extensions.cs
LightningDTester.cs
MockDelay.cs
PSBTTests.cs
PaymentHandlerTest.cs
PaymentRequestTests.cs
ProcessLauncher.cs
README.md
RateRulesTest.cs
SeleniumTester.cs
SeleniumTests.cs
ServerTester.cs
StorageTests.cs
TestAccount.cs
TestUtils.cs
UnitTest1.cs
UtilitiesTests.cs
Utils.cs
docker-bitcoin-cli.ps1
docker-bitcoin-cli.sh
docker-bitcoin-generate.ps1
docker-compose.monero.yml
docker-compose.yml
docker-customer-lightning-cli.ps1
docker-customer-lightning-cli.sh
docker-entrypoint.sh
docker-litecoin-cli.ps1
docker-litecoin-cli.sh
docker-merchant-lightning-cli.ps1
docker-merchant-lightning-cli.sh
sshd.Dockerfile
xunit.runner.json
Build
Docs
.dockerignore
.editorconfig
.gitattributes
.gitignore
LICENSE
README.md
SECURITY.md
amd64.Dockerfile
arm32v7.Dockerfile
arm64v8.Dockerfile
btcpayserver.sln
build.ps1
build.sh
docker-entrypoint.sh
nuget.config
publish-docker.ps1
run.ps1
run.sh
btcpayserver/BTCPayServer.Tests/CoinSwitchTests.cs
2019-10-14 00:24:41 +09:00

92 lines
3.3 KiB
C#

using BTCPayServer.Controllers;
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Payments.CoinSwitch;
using BTCPayServer.Tests.Logging;
using Microsoft.AspNetCore.Mvc;
using Xunit;
using Xunit.Abstractions;
using BTCPayServer.Data;
using System.Threading.Tasks;
namespace BTCPayServer.Tests
{
public class CoinSwitchTests
{
public CoinSwitchTests(ITestOutputHelper helper)
{
Logs.Tester = new XUnitLog(helper) {Name = "Tests"};
Logs.LogProvider = new XUnitLogProvider(helper);
}
[Fact]
[Trait("Integration", "Integration")]
public async Task CanSetCoinSwitchPaymentMethod()
{
using (var tester = ServerTester.Create())
{
await tester.StartAsync();
var user = tester.NewAccount();
user.GrantAccess();
var controller = tester.PayTester.GetController<StoresController>(user.UserId, user.StoreId);
var storeBlob = controller.CurrentStore.GetStoreBlob();
Assert.Null(storeBlob.CoinSwitchSettings);
var updateModel = new UpdateCoinSwitchSettingsViewModel()
{
MerchantId = "aaa",
};
Assert.Equal("UpdateStore", Assert.IsType<RedirectToActionResult>(
await controller.UpdateCoinSwitchSettings(user.StoreId, updateModel, "save")).ActionName);
var store = await tester.PayTester.StoreRepository.FindStore(user.StoreId);
storeBlob = controller.CurrentStore.GetStoreBlob();
Assert.NotNull(storeBlob.CoinSwitchSettings);
Assert.NotNull(storeBlob.CoinSwitchSettings);
Assert.IsType<CoinSwitchSettings>(storeBlob.CoinSwitchSettings);
Assert.Equal(storeBlob.CoinSwitchSettings.MerchantId,
updateModel.MerchantId);
}
}
[Fact]
[Trait("Integration", "Integration")]
public async Task CanToggleCoinSwitchPaymentMethod()
{
using (var tester = ServerTester.Create())
{
await tester.StartAsync();
var user = tester.NewAccount();
user.GrantAccess();
var controller = tester.PayTester.GetController<StoresController>(user.UserId, user.StoreId);
var updateModel = new UpdateCoinSwitchSettingsViewModel()
{
MerchantId = "aaa",
Enabled = true
};
Assert.Equal("UpdateStore", Assert.IsType<RedirectToActionResult>(
await controller.UpdateCoinSwitchSettings(user.StoreId, updateModel, "save")).ActionName);
var store = await tester.PayTester.StoreRepository.FindStore(user.StoreId);
Assert.True(store.GetStoreBlob().CoinSwitchSettings.Enabled);
updateModel.Enabled = false;
Assert.Equal("UpdateStore", Assert.IsType<RedirectToActionResult>(
await controller.UpdateCoinSwitchSettings(user.StoreId, updateModel, "save")).ActionName);
store = await tester.PayTester.StoreRepository.FindStore(user.StoreId);
Assert.False(store.GetStoreBlob().CoinSwitchSettings.Enabled);
}
}
}
}