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;
|
2024-04-09 12:53:23 +02:00
|
|
|
|
using ShareeBike.Model.Services.CopriApi.ServerUris;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
|
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.Connector
|
2021-07-12 21:31:46 +02:00
|
|
|
|
{
|
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
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(l_oUri.Uris.Count, Is.GreaterThan(0), "There must be at least one uri");
|
|
|
|
|
Assert.That(l_oUri.ActiveUri, Is.Not.Null);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
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
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(l_oUri.Uris.Count, Is.EqualTo(3));
|
|
|
|
|
Assert.That(l_oUri.ActiveUri, Is.EqualTo(new Uri("http://2.3.4.5")));
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
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()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(
|
|
|
|
|
CopriServerUriList.DefaultActiveUri.AbsoluteUri, Is.EqualTo("https://shareeapp-primary.copri.eu/APIjsonserver"),
|
2022-09-06 16:08:19 +02:00
|
|
|
|
"In production environment, server address must always be app.tink-konstanz.de/APIjsonserver.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
}
|