sharee.bike-App/SharedBusinessLogic.Tests/ViewModel/Bikes/Bike/BC/TestMyBikePageViewModel.cs

88 lines
2.2 KiB
C#
Raw Normal View History

2023-04-05 15:02:10 +02:00
using System;
using NSubstitute;
2022-08-30 15:42:25 +02:00
using NUnit.Framework;
2024-04-09 12:53:23 +02:00
using ShareeBike.Model.Device;
using ShareeBike.ViewModel;
using ShareeBike.ViewModel.Bikes;
2021-07-12 21:31:46 +02:00
namespace UITest.Fixtures.ViewModel
{
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestMyBikesPageViewModel
{
/// <summary>
2023-06-06 12:00:24 +02:00
/// Tests base class functionality by using child.
2022-09-06 16:08:19 +02:00
/// </summary>
[Test]
public void TestStateText_LoggedIn_Reserved()
{
var l_oViewModel = TestBikeViewModel.TestStateText_LoggedIn_Reserved(
2024-04-09 12:53:23 +02:00
(bike, user) => new ShareeBike.ViewModel.Bikes.Bike.BC.BikeViewModel(
2022-09-06 16:08:19 +02:00
null,
null,
null,
null,
2023-04-05 15:02:10 +02:00
Substitute.For<ISmartDevice>(),
2022-09-06 16:08:19 +02:00
null,
bike,
user,
new MyBikeInUseStateInfoProvider(),
2023-04-05 15:02:10 +02:00
Substitute.For<IBikesViewModel>(),
2022-09-06 16:08:19 +02:00
url => { }));
2021-07-12 21:31:46 +02:00
2024-04-09 12:53:23 +02:00
Assert.That(l_oViewModel.StateText, Is.EqualTo("Location Station 3, still 15 min. reserved."));
2022-09-06 16:08:19 +02:00
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
2023-06-06 12:00:24 +02:00
/// Tests base class functionality by using child.
2022-09-06 16:08:19 +02:00
/// </summary>
[Test]
public void TestStateText_LoggedIn_ReservedWithCopriConnect()
{
var l_oViewModel = TestBikeViewModel.TestStateText_LoggedIn_ReservedWithCopriConnect(
2024-04-09 12:53:23 +02:00
(bike, user) => new ShareeBike.ViewModel.Bikes.Bike.BC.BikeViewModel(
2022-09-06 16:08:19 +02:00
null,
null,
null,
null,
2023-04-05 15:02:10 +02:00
Substitute.For<ISmartDevice>(),
2022-09-06 16:08:19 +02:00
null,
bike,
user,
new MyBikeInUseStateInfoProvider(),
2023-04-05 15:02:10 +02:00
Substitute.For<IBikesViewModel>(),
2022-09-06 16:08:19 +02:00
url => { }));
2021-07-12 21:31:46 +02:00
2024-04-09 12:53:23 +02:00
Assert.That(l_oViewModel.StateText, Is.EqualTo("Code 4asdfA, location Station 3, still 7 min. reserved."));
2022-09-06 16:08:19 +02:00
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
2023-06-06 12:00:24 +02:00
/// Tests base class functionality by using child.
2022-09-06 16:08:19 +02:00
/// </summary>
///
[Test]
public void TestStateText_LoggedIn_Booked()
{
var l_oViewModel = TestBikeViewModel.TestStateText_LoggedIn_Booked(
2024-04-09 12:53:23 +02:00
(bike, user) => new ShareeBike.ViewModel.Bikes.Bike.BC.BikeViewModel(
2022-09-06 16:08:19 +02:00
null,
null,
null,
null,
2023-04-05 15:02:10 +02:00
Substitute.For<ISmartDevice>(),
2022-09-06 16:08:19 +02:00
null,
bike,
user,
new MyBikeInUseStateInfoProvider(),
2023-04-05 15:02:10 +02:00
Substitute.For<IBikesViewModel>(),
2022-09-06 16:08:19 +02:00
url => { }));
2021-07-12 21:31:46 +02:00
2024-04-09 12:53:23 +02:00
Assert.That(
l_oViewModel.StateText, Is.EqualTo($"Code 4asdfA, location Station 3, rented since {new DateTime(2018, 10, 24, 21, 49, 00).ToString("dd. MMMM HH:mm")}."));
2022-09-06 16:08:19 +02:00
}
}
2021-07-12 21:31:46 +02:00
}