2023-04-19 12:14:14 +02:00
|
|
|
using System;
|
2022-08-30 15:42:25 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using TINK.Model;
|
|
|
|
using TINK.ViewModel.WhatsNew;
|
|
|
|
using Xamarin.Essentials;
|
|
|
|
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
[TestFixture]
|
|
|
|
public class TestWhatsNew
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestIsMessagesConsistent()
|
|
|
|
{
|
|
|
|
foreach (AppFlavor app in Enum.GetValues(typeof(AppFlavor)))
|
|
|
|
{
|
|
|
|
foreach (DevicePlatform platform in new List<DevicePlatform> { DevicePlatform.iOS, DevicePlatform.Android })
|
|
|
|
Assert.That(
|
|
|
|
() => new WhatsNew(
|
|
|
|
WhatsNew.AllFlavorsAndPlatformMessages[WhatsNew.AllFlavorsAndPlatformMessages.Count - 1].Version,
|
|
|
|
WhatsNew.AllFlavorsAndPlatformMessages[0].Version,
|
|
|
|
WhatsNew.AllFlavorsAndPlatformMessages[0].Version,
|
|
|
|
app,
|
|
|
|
platform).WhatsNewText,
|
|
|
|
Throws.Nothing,
|
|
|
|
"Invalid entries detected.");
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestIsShowRequired_CleanInstall()
|
|
|
|
{
|
|
|
|
Assert.IsFalse(new WhatsNew(
|
|
|
|
new Version(2, 4), /* Current version */
|
|
|
|
null, // last version
|
|
|
|
null, /* Whats new was never shown */
|
|
|
|
AppFlavor.ShareeBike,
|
|
|
|
DevicePlatform.Android).IsShowRequired);
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <summary>
|
2023-04-19 12:14:14 +02:00
|
|
|
/// This test verified old implementation which worked with the different versions to determine whenther whats new has to be shown or not.
|
|
|
|
/// Test updated to new implementation (based on filtering of AllFlavorsAndPlatformMessages)
|
2022-09-06 16:08:19 +02:00
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void TestIsShowRequired_Update_VersionWhichSupporsWhatsNew()
|
|
|
|
{
|
|
|
|
Assert.IsTrue(
|
|
|
|
new WhatsNew(
|
|
|
|
new Version(3, 0, 335), /* Current version */
|
|
|
|
new Version(3, 0, 333), /* last version */
|
|
|
|
new Version(3, 0, 111), /* Version when whats new was shown */
|
|
|
|
AppFlavor.ShareeBike,
|
|
|
|
DevicePlatform.Android).IsShowRequired,
|
2023-04-19 12:14:14 +02:00
|
|
|
"If whats new was last shown for version 3.0.111 and current version is 2.0.335 info must be shown");
|
2022-09-06 16:08:19 +02:00
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <summary>
|
2023-04-19 12:14:14 +02:00
|
|
|
/// This test verified old implementation which worked with the different versions to determine whenther whats new has to be shown or not.
|
|
|
|
/// Test updated to new implementation (based on filtering of AllFlavorsAndPlatformMessages)
|
2022-09-06 16:08:19 +02:00
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void TestIsShowRequired_Update_VersionWithoutWhatsNew()
|
|
|
|
{
|
|
|
|
Assert.IsTrue(
|
|
|
|
new WhatsNew(
|
|
|
|
new Version(3, 0, 335), /* Current version */
|
|
|
|
new Version(3, 0, 333), /* last version */
|
|
|
|
null, /* Whats new was never shown */
|
|
|
|
AppFlavor.ShareeBike,
|
|
|
|
DevicePlatform.Android).IsShowRequired,
|
|
|
|
"If whats new was never shown but last version was 3.0.333 (not clean install) info must be shown");
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestIsShowRequired_False()
|
|
|
|
{
|
|
|
|
Assert.IsFalse(
|
|
|
|
new WhatsNew(new Version(2, 5), new Version(2, 5), new Version(2, 5), AppFlavor.ShareeBike, DevicePlatform.Android).IsShowRequired,
|
|
|
|
"Whats new must never be presented twice.");
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestIsShowRequired_False_Errors()
|
|
|
|
{
|
|
|
|
Assert.IsFalse(new WhatsNew(null, new Version(2, 6), new Version(2, 5), AppFlavor.ShareeBike, DevicePlatform.Android).IsShowRequired);
|
|
|
|
Assert.IsFalse(new WhatsNew(new Version(2, 6), null, new Version(2, 5), AppFlavor.ShareeBike, DevicePlatform.Android).IsShowRequired);
|
|
|
|
Assert.IsFalse(new WhatsNew(null, null, new Version(2, 5), AppFlavor.ShareeBike, DevicePlatform.Android).IsShowRequired);
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewText_MajorUpdate()
|
|
|
|
{
|
|
|
|
Assert.AreEqual(
|
|
|
|
"<p><b>3.0.0.115</b><br/>Benutzeroberfläche verbessert.\r\n\r\n" +
|
|
|
|
"</p><p><b>3.0.120</b><br/>Verbesserung: Keine Fehler mehr beim schnellen Tippen.\r\nOfflineanzeige Stationen/ Räderinfo.\r\n\r\n</p>",
|
|
|
|
WhatsNewViewModel.GetWhatNextHtmlText(new WhatsNew(new Version(3, 0, 120), new Version(3, 0, 0, 114), new Version(3, 0, 0, 114), AppFlavor.ShareeBike, DevicePlatform.Android).WhatsNewText),
|
|
|
|
"Current version is 30.0.120, last whats new was shown in version 3.0.0.114: Two changes to be notified about.");
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewText_MinorUpdate()
|
|
|
|
{
|
|
|
|
Assert.AreEqual(
|
|
|
|
"<p><b>3.0.120</b><br/>Verbesserung: Keine Fehler mehr beim schnellen Tippen.\r\nOfflineanzeige Stationen/ Räderinfo.\r\n\r\n</p>",
|
|
|
|
WhatsNewViewModel.GetWhatNextHtmlText(new WhatsNew(new Version(3, 0, 120), new Version(3, 0, 0, 115), new Version(3, 0, 0, 115), AppFlavor.ShareeBike, DevicePlatform.Android).WhatsNewText));
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewGetFileredMessages_GeneralMessage()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
new WhatsNew(new Version(3, 0, 335), new Version(3, 0), new Version(3, 0), AppFlavor.ShareeBike, DevicePlatform.iOS, new WhatsNewMessages
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new Version(3, 0, 0, 115),
|
|
|
|
"Benutzeroberfläche verbessert.\r\n\r\n"
|
|
|
|
}
|
|
|
|
}).WhatsNewText.Count(),
|
|
|
|
Is.EqualTo(1));
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewGetFileredMessages_MeinKonradOnly_Included()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
new WhatsNew(new Version(3, 0, 335), new Version(3, 0), new Version(3, 0), AppFlavor.MeinKonrad, DevicePlatform.iOS, new WhatsNewMessages
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new Version(3, 0, 0, 115),
|
|
|
|
"Benutzeroberfläche verbessert.\r\n\r\n",
|
|
|
|
new List<AppFlavor> {AppFlavor.MeinKonrad}
|
|
|
|
}
|
|
|
|
}).WhatsNewText.Count(),
|
|
|
|
Is.EqualTo(1));
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewGetFileredMessages_MeinKonradOnly_Excluded()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
new WhatsNew(new Version(3, 0, 335), new Version(3, 0), new Version(3, 0), AppFlavor.ShareeBike, DevicePlatform.iOS, new WhatsNewMessages
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new Version(3, 0, 0, 115),
|
|
|
|
"Benutzeroberfläche verbessert.\r\n\r\n",
|
|
|
|
new List<AppFlavor> {AppFlavor.MeinKonrad}
|
|
|
|
}
|
|
|
|
}).WhatsNewText.Count(),
|
|
|
|
Is.EqualTo(0));
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewGetFileredMessages_iOSOnly_Included()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
new WhatsNew(new Version(3, 0, 335), new Version(3, 0), new Version(3, 0), AppFlavor.ShareeBike, DevicePlatform.iOS, new WhatsNewMessages
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new Version(3, 0, 0, 115),
|
|
|
|
"Benutzeroberfläche verbessert.\r\n\r\n",
|
|
|
|
null,
|
|
|
|
new List<DevicePlatform> {DevicePlatform.iOS}
|
|
|
|
}
|
|
|
|
}).WhatsNewText.Count(),
|
|
|
|
Is.EqualTo(1));
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
[Test]
|
|
|
|
public void TestWhatsNewGetFileredMessages_iOSOnly_Exclued()
|
|
|
|
{
|
|
|
|
Assert.That(
|
|
|
|
new WhatsNew(new Version(3, 0, 335), new Version(3, 0), new Version(3, 0), AppFlavor.ShareeBike, DevicePlatform.Android, new WhatsNewMessages
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new Version(3, 0, 0, 115),
|
|
|
|
"Benutzeroberfläche verbessert.\r\n\r\n",
|
|
|
|
null,
|
|
|
|
new List<DevicePlatform> {DevicePlatform.iOS}
|
|
|
|
}
|
|
|
|
}).WhatsNewText.Count(),
|
|
|
|
Is.EqualTo(0));
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
}
|