sharee.bike-App/TestShareeLib/Services/CopriApi/ServerUris/TestCopriServerUriList.cs

66 lines
1.7 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
2021-07-12 21:31:46 +02:00
using System.Collections.Generic;
2022-08-30 15:42:25 +02:00
using NUnit.Framework;
2021-07-12 21:31:46 +02:00
using TINK.Model.Services.CopriApi.ServerUris;
namespace TestTINKLib.Fixtures.ObjectTests.Connector
{
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestCopriServerUriList
{
[Test]
public void TestConstruct()
{
var l_oUri = new CopriServerUriList();
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.Greater(l_oUri.Uris.Count, 0, "There must be at least one uri");
Assert.NotNull(l_oUri.ActiveUri);
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestConstruct_AryStringString()
{
var l_oUri = new CopriServerUriList(
(new List<Uri> { new Uri("http://1.2.3.4"), new Uri("http://2.3.4.5"), new Uri("http://3.4.5.6") }).ToArray(),
new Uri("http://2.3.4.5"));
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.AreEqual(3, l_oUri.Uris.Count);
Assert.AreEqual(new Uri("http://2.3.4.5"), l_oUri.ActiveUri);
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestConstruct_AryStringString_NullList()
{
Assert.Throws<ArgumentException>(() => new CopriServerUriList(
null,
new Uri("http://2.3.4.5")));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestConstruct_AryStringString_InvalidList()
{
Assert.Throws<ArgumentException>(() => new CopriServerUriList(
(new List<Uri>()).ToArray(),
new Uri("http://2.3.4.5")));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestConstruct_AryStringString_InvalidActiveUri()
{
Assert.Throws<ArgumentException>(() => new CopriServerUriList(
(new List<Uri> { new Uri("http://1.2.3.4"), new Uri("http://2.3.4.5"), new Uri("http://3.4.5.6") }).ToArray(),
new Uri("http://9.9.9.9")));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestDefaultActiveUri()
{
Assert.AreEqual(
"https://shareeapp-primary.copri.eu/APIjsonserver",
CopriServerUriList.DefaultActiveUri.AbsoluteUri,
"In production environment, server address must always be app.tink-konstanz.de/APIjsonserver.");
}
}
2021-07-12 21:31:46 +02:00
}