mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-22 23:26:31 +01:00
188 lines
6.5 KiB
C#
188 lines
6.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using TINK.Model;
|
|
using TINK.ViewModel.WhatsNew;
|
|
using Xamarin.Essentials;
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests
|
|
{
|
|
[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.");
|
|
}
|
|
}
|
|
|
|
[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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// This test verified old implementedation which worked with the different versions to determine whenther whats new has to be shown or not.
|
|
/// Test updated to new implmentedation (based on filtering of AllFlavorsAndPlatformMessages)
|
|
/// </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,
|
|
"If whats new was last shonw for version 3.0.111 and current version is 2.0.335 info must be shown");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// This test verified old implementedation which worked with the different versions to determine whenther whats new has to be shown or not.
|
|
/// Test updated to new implmentedation (based on filtering of AllFlavorsAndPlatformMessages)
|
|
/// </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");
|
|
}
|
|
|
|
[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.");
|
|
}
|
|
|
|
[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);
|
|
}
|
|
|
|
[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.");
|
|
}
|
|
|
|
[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));
|
|
}
|
|
|
|
[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));
|
|
}
|
|
|
|
[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));
|
|
}
|
|
|
|
[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));
|
|
}
|
|
|
|
[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));
|
|
}
|
|
|
|
[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));
|
|
}
|
|
}
|
|
}
|