mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 15:46:29 +01:00
122 lines
3.8 KiB
C#
122 lines
3.8 KiB
C#
|
using NUnit.Framework;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace TINK.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>());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|