Version 3.0.381

This commit is contained in:
Anja 2024-04-09 12:53:23 +02:00
parent f963c0a219
commit 3a363acf3a
1525 changed files with 60589 additions and 125098 deletions

View file

@ -0,0 +1,110 @@
using System.Collections.Generic;
using NUnit.Framework;
using ShareeBike.Model;
using ShareeBike.ViewModel.Settings;
namespace UITest.Fixtures.ObjectTests.ViewModel.Settings
{
[TestFixture]
public class TestFilterCollectionMutable
{
[Test]
public void TestConstruct_NoConradAccount()
{
var l_oColl = new SettingsBikeFilterViewModel(
new GroupFilterSettings(new Dictionary<string, FilterState> {
{"ShareeBike", FilterState.On },
{"Citybike", FilterState.On}
}),
new List<string> { "ShareeBike" });
Assert.That(l_oColl[0].Key, Is.EqualTo("ShareeBike"));
Assert.That(l_oColl[0].IsActivated, Is.True);
Assert.That(l_oColl[0].IsEnabled, Is.True);
Assert.That(l_oColl[1].Key, Is.EqualTo("Citybike"));
Assert.That(l_oColl[1].IsActivated, Is.False, "Citybike must be off if user is not part of group.");
Assert.That(l_oColl[1].IsEnabled, Is.False, "Citybike must be disabled if user is not part of group.");
Assert.That(l_oColl.FilterCollection["ShareeBike"], Is.EqualTo(FilterState.On));
Assert.That(l_oColl.FilterCollection["Citybike"], Is.EqualTo(FilterState.On), "Filter state must be preserved.");
}
[Test]
public void TestConstruct_ConradAccount()
{
var l_oColl = new SettingsBikeFilterViewModel(
new GroupFilterSettings(new Dictionary<string, FilterState> {
{"ShareeBike", FilterState.On },
{"Citybike", FilterState.On}
}),
new List<string> { "ShareeBike", "Citybike" });
Assert.That(l_oColl[0].Key, Is.EqualTo("ShareeBike"));
Assert.That(l_oColl[0].IsActivated, Is.True);
Assert.That(l_oColl[0].IsEnabled, Is.True);
Assert.That(l_oColl[1].Key, Is.EqualTo("Citybike"));
Assert.That(l_oColl[1].IsActivated, Is.True);
Assert.That(l_oColl[1].IsEnabled, Is.True);
Assert.That(l_oColl.FilterCollection["ShareeBike"], Is.EqualTo(FilterState.On));
Assert.That(l_oColl.FilterCollection["Citybike"], Is.EqualTo(FilterState.On), "Filter state must be preserved.");
}
[Test]
public void TestConstruct_TurnOff()
{
var l_oColl = new SettingsBikeFilterViewModel(
new GroupFilterSettings(new Dictionary<string, FilterState> {
{"ShareeBike", FilterState.On },
{"Citybike", FilterState.On}
}),
new List<string> { "ShareeBike", "Citybike" });
// Check prerequisites.
Assert.That(l_oColl[0].Key, Is.EqualTo("ShareeBike"));
Assert.That(l_oColl[0].IsActivated, Is.True);
Assert.That(l_oColl[0].IsEnabled, Is.True);
Assert.That(l_oColl[1].Key, Is.EqualTo("Citybike"));
Assert.That(l_oColl[1].IsActivated, Is.True);
Assert.That(l_oColl[1].IsEnabled, Is.True);
Assert.That(l_oColl.FilterCollection["ShareeBike"], Is.EqualTo(FilterState.On));
Assert.That(l_oColl.FilterCollection["Citybike"], Is.EqualTo(FilterState.On), "Filter state must be preserved.");
// Turn filter konrad off.
l_oColl[1].IsActivated = false;
// Verify changes.
Assert.That(l_oColl.FilterCollection["ShareeBike"], Is.EqualTo(FilterState.On));
Assert.That(l_oColl.FilterCollection["Citybike"], Is.EqualTo(FilterState.Off), "Filter state must be preserved.");
}
[Test]
public void TestConstruct_NoUserLoggedIn()
{
var l_oColl = new SettingsBikeFilterViewModel(
new GroupFilterSettings(new Dictionary<string, FilterState> {
{"ShareeBike", FilterState.On },
{"Citybike", FilterState.On}
}),
null);
// Check prerequisites.
Assert.That(l_oColl[0].Key, Is.EqualTo("ShareeBike"));
Assert.That(l_oColl[0].IsActivated, Is.True);
Assert.That(l_oColl[0].IsEnabled, Is.True);
Assert.That(l_oColl[1].Key, Is.EqualTo("Citybike"));
Assert.That(l_oColl[1].IsActivated, Is.True);
Assert.That(l_oColl[1].IsEnabled, Is.True);
Assert.That(l_oColl.FilterCollection["ShareeBike"], Is.EqualTo(FilterState.On));
Assert.That(l_oColl.FilterCollection["Citybike"], Is.EqualTo(FilterState.On), "Filter state must be preserved.");
}
}
}

View file

@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using ShareeBike.Model;
using ShareeBike.Model.Connector;
using ShareeBike.ViewModel.Settings;
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.SettingsNS
{
[TestFixture]
public class TestGroupFilterSettings
{
[Test]
public void TestDoFilter()
{
var l_oFilter = new GroupFilterSettings(new Dictionary<string, FilterState> { { $"HOM_{FilterHelper.CITYBIKE}", FilterState.Off }, { $"HOM_{FilterHelper.CARGOBIKE}", FilterState.On }, { "HOM_117025", FilterState.On } });
var l_oResult = l_oFilter.DoFilter(new List<string> { $"HOM_{FilterHelper.CITYBIKE}", $"HOM_{FilterHelper.CARGOBIKE}" });
Assert.That(l_oResult.ToList().Count, Is.EqualTo(1));
Assert.That(l_oResult.ToList()[0], Is.EqualTo($"HOM_{FilterHelper.CARGOBIKE}"));
}
}
}

View file

@ -0,0 +1,40 @@
using System;
using NUnit.Framework;
using ShareeBike.Settings;
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.SettingsNS
{
[TestFixture]
public class TestPollingParameters
{
[Test]
public void TestConstruct()
{
Assert.That(new PollingParameters(new TimeSpan(0, 0, 11), true).IsActivated, Is.True);
Assert.That((new PollingParameters(new TimeSpan(0, 0, 11), true).Periode.TotalSeconds), Is.EqualTo(11));
}
[Test]
public void TestEquals()
{
Assert.That((new PollingParameters(new TimeSpan(0, 0, 11), true)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)), Is.True);
Assert.That((new PollingParameters(new TimeSpan(0, 0, 11), false)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)), Is.False);
Assert.That((new PollingParameters(new TimeSpan(0, 0, 12), true)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)), Is.False);
}
[Test]
public void TestUnequals()
{
Assert.That((new PollingParameters(new TimeSpan(0, 0, 11), true)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)), Is.False);
Assert.That((new PollingParameters(new TimeSpan(0, 0, 11), false)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)), Is.True);
Assert.That((new PollingParameters(new TimeSpan(0, 0, 12), true)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)), Is.True);
}
[Test]
public void TestToString()
{
Assert.That(
(new PollingParameters(new TimeSpan(0, 0, 11), true).ToString()), Is.EqualTo("Polling is on=True, polling interval=11[sec]."));
}
}
}

View file

@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace ShareeBike.ViewModel.Settings
{
[TestFixture]
public class TestServicesViewModel
{
[Test]
public void TestCtor()
{
var servicesViewModel = new ServicesViewModel(
new List<string> {
"ServiceA",
"ServiceB",
"ServiceB", // Dupes are removed
"ServiceC" },
new Dictionary<string, string> {
{ "ServiceA", "Top service of type A" },
{ "ServiceB", "Supertop service of type B" },
{ "OldsService", "This entry is discarded" }},
"ServiceB");
Assert.That(
servicesViewModel.ServicesTextList,
Is.EqualTo(new List<string> {
"ServiceC",
"Supertop service of type B",
"Top service of type A" }).AsCollection);
Assert.That(
servicesViewModel.Active,
Is.EqualTo("ServiceB"));
}
[Test]
public void TestCtorInvalidActive()
{
Assert.That(
() => new ServicesViewModel(
new List<string> { "ServiceA", "ServiceB", "ServiceB", "ServiceC" },
new Dictionary<string, string> { { "ServiceA", "Top service of type A" }, { "ServiceB", "Supertop service of type B" } },
"ServiceX"),
Throws.TypeOf<ArgumentException>());
}
[Test]
public void TestCtorInvalidServiceNames()
{
Assert.That(
() => new ServicesViewModel(
new List<string> { "ServiceA", "ServiceB", "ServiceC" },
new Dictionary<string, string> { { "ServiceA", "Top fast" }, { "ServiceB", "Top fast" } },
"ServiceB"),
Throws.TypeOf<ArgumentException>());
}
[Test]
public void TestGetActiveTextDisplayTextAvailable()
{
var servicesViewModel = new ServicesViewModel(
new List<string> {
"ServiceB"},
new Dictionary<string, string> {
{ "ServiceB", "Supertop service of type B" }},
"ServiceB");
Assert.That(
servicesViewModel.ActiveText,
Is.EqualTo("Supertop service of type B"));
}
[Test]
public void TestGetActiveTextNoDisplayText()
{
var servicesViewModel = new ServicesViewModel(
new List<string> {
"ServiceB"},
new Dictionary<string, string>(),
"ServiceB");
Assert.That(
servicesViewModel.ActiveText,
Is.EqualTo("ServiceB"));
}
[Test]
public void TestSetActiveText()
{
var servicesViewModel = new ServicesViewModel(
new List<string> {
"ServiceA",
"ServiceB" },
new Dictionary<string, string>(),
"ServiceB")
{
ActiveText = "ServiceA"
};
Assert.That(
servicesViewModel.ActiveText,
Is.EqualTo("ServiceA"));
}
[Test]
public void TestSetActiveTextInvalid()
{
var servicesViewModel = new ServicesViewModel(
new List<string> {
"ServiceA",
"ServiceB" },
new Dictionary<string, string>(),
"ServiceB");
Assert.That(
() => servicesViewModel.ActiveText = "ServiceX",
Throws.InstanceOf<ArgumentException>());
}
}
}