mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-03-06 08:06:26 +01:00
3.0.271
This commit is contained in:
parent
e0c75d5b37
commit
f38b516d25
57 changed files with 12835 additions and 9925 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.LastenradBayern" android:versionName="3.0.270" android:versionCode="270">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.LastenradBayern" android:versionName="3.0.271" android:versionCode="271">
|
||||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
|
||||
<!-- Google Maps related permissions -->
|
||||
<!-- Permission to receive remote notifications from Google Play Services -->
|
||||
|
|
7263
LastenradBayern/TINK.Android/Resources/Resource.Designer.cs
generated
7263
LastenradBayern/TINK.Android/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -49,8 +49,8 @@
|
|||
<key>CFBundleDisplayName</key>
|
||||
<string>LastenradBayern</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>270</string>
|
||||
<string>271</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.0.270</string>
|
||||
<string>3.0.271</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -1472,7 +1472,9 @@
|
|||
<ImageAsset Include="Media.xcassets\AppIcons.appiconset\Icon-167.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Media.xcassets\AppIcons.appiconset\iTunesArtwork%402x.png" />
|
||||
<ImageAsset Include="Media.xcassets\AppIcons.appiconset\iTunesArtwork%402x.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Media.xcassets\01_Blue.imageset\" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.Meinkonrad" android:versionName="3.0.270" android:versionCode="270">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.Meinkonrad" android:versionName="3.0.271" android:versionCode="271">
|
||||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
|
||||
<!-- Google Maps related permissions -->
|
||||
<!-- Permission to receive remote notifications from Google Play Services -->
|
||||
|
|
7263
Meinkonrad/TINK.Android/Resources/Resource.Designer.cs
generated
7263
Meinkonrad/TINK.Android/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -49,8 +49,8 @@
|
|||
<key>CFBundleDisplayName</key>
|
||||
<string>Mein konrad</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>270</string>
|
||||
<string>271</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.0.270</string>
|
||||
<string>3.0.271</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -1471,7 +1471,9 @@
|
|||
<ImageAsset Include="Media.xcassets\AppIcons.appiconset\Icon-167.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Media.xcassets\AppIcons.appiconset\App-Icon-MeinKonrad_1024.png" />
|
||||
<ImageAsset Include="Media.xcassets\AppIcons.appiconset\App-Icon-MeinKonrad_1024.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Media.xcassets\01_Blue.imageset\" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.hauffware.sharee" android:versionName="3.0.270" android:versionCode="270">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.hauffware.sharee" android:versionName="3.0.271" android:versionCode="271">
|
||||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
|
||||
<!-- Google Maps related permissions -->
|
||||
<!-- Permission to receive remote notifications from Google Play Services -->
|
||||
|
|
7261
TINK/TINK.Android/Resources/Resource.Designer.cs
generated
7261
TINK/TINK.Android/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -49,8 +49,8 @@
|
|||
<key>CFBundleDisplayName</key>
|
||||
<string>sharee.bike</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>270</string>
|
||||
<string>271</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.0.270</string>
|
||||
<string>3.0.271</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace TINK.Model.Connector
|
|||
Log.ForContext<CachedQuery>().Error("Unexpected call to get be bikes occpied detected. No user is logged in.");
|
||||
return new Result<BikeCollection>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
await Task.Run(() => new BikeCollection(new Dictionary<string, BikeInfo>())),
|
||||
await Task.FromResult(new BikeCollection(new Dictionary<string, BikeInfo>())),
|
||||
new GeneralData(),
|
||||
new Exception("Abfrage der reservierten/ gebuchten Räder nicht möglich. Kein Benutzer angemeldet."));
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace TINK.Model.Connector
|
|||
Log.ForContext<Query>().Error("Unexpected call to get be bikes occpied detected. No user is logged in.");
|
||||
return new Result<BikeCollection>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
await Task.Run(() => new BikeCollection(new Dictionary<string, BikeInfo>())),
|
||||
await Task.FromResult(new BikeCollection(new Dictionary<string, BikeInfo>())),
|
||||
new GeneralData(),
|
||||
new Exception("Abfrage der reservierten/ gebuchten Räder fehlgeschlagen. Kein Benutzer angemeldet."));
|
||||
}
|
||||
|
|
|
@ -28,11 +28,9 @@ namespace TINK.Model.Connector
|
|||
/// </summary>
|
||||
/// <param name="stationInfo">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo stationInfo)
|
||||
{
|
||||
return GetPosition(stationInfo.gps);
|
||||
}
|
||||
|
||||
public static IPosition GetPosition(this StationsAvailableResponse.StationInfo stationInfo)
|
||||
=> GetPosition(stationInfo.gps);
|
||||
|
||||
/// <summary> Gets the position from StationInfo object. </summary>
|
||||
/// <param name="authorizationResponse">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
|
@ -160,9 +158,9 @@ namespace TINK.Model.Connector
|
|||
{
|
||||
return bikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List<string>();
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
throw new System.Exception($"Can not get group of user from text \"{bikeInfo.bike_group}\".", l_oException);
|
||||
throw new Exception($"Can not get group of user from text \"{bikeInfo.bike_group}\".", l_oException);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,33 +302,27 @@ namespace TINK.Model.Connector
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get position from a ,- separated string.
|
||||
/// </summary>
|
||||
/// <param name="p_strGps">Text to extract positon from.</param>
|
||||
/// <summary> Get position from a ,- separated string. </summary>
|
||||
/// <param name="gps">Text to extract positon from.</param>
|
||||
/// <returns>Position object.</returns>
|
||||
public static Station.Position GetPosition(GpsInfo gps)
|
||||
{
|
||||
if (gps == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public static IPosition GetPosition(Repository.Response.Position gps)
|
||||
=> PositionFactory.Create(
|
||||
double.TryParse(gps?.latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double latitude) ? latitude : double.NaN,
|
||||
double.TryParse(gps?.longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double longitude) ? longitude : double.NaN);
|
||||
|
||||
double l_oLatitude;
|
||||
if (!double.TryParse(gps.latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out l_oLatitude))
|
||||
return null;
|
||||
/// <summary> Get position from a ,- separated string. </summary>
|
||||
/// <param name="gps">Text to extract positon from.</param>
|
||||
/// <returns>Position object.</returns>
|
||||
public static Map.IMapSpan GetMapSpan(this MapSpan mapSpan)
|
||||
=> Map.MapSpanFactory.Create(
|
||||
GetPosition(mapSpan?.center),
|
||||
double.TryParse(mapSpan?.radius, NumberStyles.Float, CultureInfo.InvariantCulture, out double radius) ? radius: double.NaN);
|
||||
|
||||
double l_oLongitude;
|
||||
if (!double.TryParse(gps.longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out l_oLongitude))
|
||||
return null;
|
||||
|
||||
return new Station.Position(l_oLatitude, l_oLongitude);
|
||||
}
|
||||
|
||||
/// <summary> Gets text of bike from. </summary>
|
||||
/// <param name="p_eType">Type to get text for.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetCopriText(this TypeOfBike p_eType)
|
||||
/// <summary> Gets text of bike from. </summary>
|
||||
/// <param name="p_eType">Type to get text for.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetCopriText(this TypeOfBike p_eType)
|
||||
{
|
||||
switch (p_eType)
|
||||
{
|
||||
|
|
|
@ -85,9 +85,12 @@ namespace TINK.Model.Connector
|
|||
/// <param name="response">Response to get data from.</param>
|
||||
/// <returns>General data object initialized form COPRI response.</returns>
|
||||
public static GeneralData GetGeneralData(this ResponseBase response)
|
||||
=> new GeneralData(response.merchant_message, response.TryGetCopriVersion(out Version copriVersion)
|
||||
? new Version(0,0)
|
||||
: copriVersion);
|
||||
=> new GeneralData(
|
||||
response.init_map.GetMapSpan(),
|
||||
response.merchant_message,
|
||||
response.TryGetCopriVersion(out Version copriVersion)
|
||||
? new Version(0,0)
|
||||
: copriVersion);
|
||||
|
||||
/// <summary> Gets account object from login response.</summary>
|
||||
/// <param name="merchantId">Needed to extract cookie from autorization response.</param>
|
||||
|
|
13
TINKLib/Model/IPosition.cs
Normal file
13
TINKLib/Model/IPosition.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace TINK.Model
|
||||
{
|
||||
public interface IPosition : IEquatable<IPosition>
|
||||
{
|
||||
double Latitude { get; }
|
||||
|
||||
double Longitude { get; }
|
||||
|
||||
bool IsValid { get; }
|
||||
}
|
||||
}
|
14
TINKLib/Model/Map/IMapSpan.cs
Normal file
14
TINKLib/Model/Map/IMapSpan.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace TINK.Model.Map
|
||||
{
|
||||
public interface IMapSpan
|
||||
{
|
||||
/// <summary> Center of map displayed area.</summary>
|
||||
IPosition Center { get; }
|
||||
|
||||
/// <summary> Radius of displayed map area. </summary>
|
||||
double Radius { get; }
|
||||
|
||||
/// <summary> Gets if map span is valid or not. </summary>
|
||||
bool IsValid { get; }
|
||||
}
|
||||
}
|
30
TINKLib/Model/Map/MapSpan.cs
Normal file
30
TINKLib/Model/Map/MapSpan.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
|
||||
namespace TINK.Model.Map
|
||||
{
|
||||
/// <summary> Holds the displayed map area. </summary>
|
||||
public class MapSpan : IMapSpan
|
||||
{
|
||||
internal MapSpan(IPosition center, double radius)
|
||||
{
|
||||
if (!GetIsValid(center, radius))
|
||||
throw new ArgumentNullException();
|
||||
|
||||
Center = center;
|
||||
Radius = radius;
|
||||
}
|
||||
|
||||
/// <summary> Center of map displayed area.</summary>
|
||||
public IPosition Center { get; }
|
||||
|
||||
/// <summary> Radius of displayed map area. </summary>
|
||||
public double Radius { get; }
|
||||
|
||||
public bool IsValid => GetIsValid(Center, Radius);
|
||||
|
||||
public static bool GetIsValid(IPosition center, double radius)
|
||||
=> center != null
|
||||
&& center.IsValid
|
||||
&& !double.IsNaN(radius);
|
||||
}
|
||||
}
|
11
TINKLib/Model/Map/MapSpanFactory.cs
Normal file
11
TINKLib/Model/Map/MapSpanFactory.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
namespace TINK.Model.Map
|
||||
{
|
||||
public static class MapSpanFactory
|
||||
{
|
||||
public static IMapSpan Create(IPosition position = null, double radius = double.NaN)
|
||||
=> MapSpan.GetIsValid(position, radius)
|
||||
? new MapSpan(position, radius) as IMapSpan
|
||||
: new NullMapSpan();
|
||||
}
|
||||
}
|
16
TINKLib/Model/Map/NullMapSpan.cs
Normal file
16
TINKLib/Model/Map/NullMapSpan.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
namespace TINK.Model.Map
|
||||
{
|
||||
public class NullMapSpan : IMapSpan
|
||||
{
|
||||
internal NullMapSpan() { }
|
||||
|
||||
/// <summary> Center of map displayed area.</summary>
|
||||
public IPosition Center { get; } = PositionFactory.Create();
|
||||
|
||||
/// <summary> Radius of displayed map area. </summary>
|
||||
public double Radius => double.NaN;
|
||||
|
||||
public bool IsValid => MapSpan.GetIsValid(Center, Radius);
|
||||
}
|
||||
}
|
17
TINKLib/Model/NullPostion.cs
Normal file
17
TINKLib/Model/NullPostion.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
namespace TINK.Model
|
||||
{
|
||||
public class NullPostion : IPosition
|
||||
{
|
||||
internal NullPostion() { }
|
||||
|
||||
public double Latitude => double.NaN;
|
||||
|
||||
public double Longitude => double.NaN;
|
||||
|
||||
public bool IsValid => Position.GetIsValid(Latitude, Longitude);
|
||||
|
||||
public bool Equals(IPosition other)
|
||||
=> Position.GetEquals(this, other);
|
||||
}
|
||||
}
|
64
TINKLib/Model/Position.cs
Normal file
64
TINKLib/Model/Position.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
|
||||
namespace TINK.Model
|
||||
{
|
||||
public class Position : IPosition
|
||||
{
|
||||
private const double PRECISSION_LATITUDE_LONGITUDE = 0.000000000000001;
|
||||
|
||||
internal Position(double latitude, double longitude)
|
||||
{
|
||||
if (!GetIsValid(latitude, longitude))
|
||||
throw new ArgumentNullException();
|
||||
|
||||
Latitude = latitude;
|
||||
Longitude = longitude;
|
||||
}
|
||||
|
||||
public double Latitude { get; private set; }
|
||||
|
||||
public double Longitude { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Compares position with a target position.
|
||||
/// </summary>
|
||||
/// <param name="target">Target position to compare with.</param>
|
||||
/// <returns>True if positions are equal.</returns>
|
||||
public override bool Equals(object target)
|
||||
{
|
||||
if (!(target is IPosition targetPosition))
|
||||
return false;
|
||||
|
||||
return GetEquals(this, targetPosition);
|
||||
}
|
||||
|
||||
public bool Equals(IPosition other)
|
||||
=> (other is Position position) && position.Equals(this as object);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCode = -1416534245;
|
||||
hashCode = hashCode * -1521134295 + Latitude.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Longitude.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public bool IsValid => GetIsValid(Latitude, Longitude);
|
||||
|
||||
public static bool GetEquals(IPosition source, IPosition target)
|
||||
{
|
||||
if (source == null || target == null)
|
||||
return source == null ^ target == null;
|
||||
|
||||
if (!source.IsValid || !target.IsValid)
|
||||
return !source.IsValid ^ !target.IsValid;
|
||||
|
||||
return Math.Abs(source.Latitude - target.Latitude) < PRECISSION_LATITUDE_LONGITUDE
|
||||
&& Math.Abs(source.Longitude - target.Longitude) < PRECISSION_LATITUDE_LONGITUDE;
|
||||
}
|
||||
|
||||
public static bool GetIsValid(double latitude, double longitude)
|
||||
=> !double.IsNaN(latitude) && !double.IsNaN(longitude);
|
||||
}
|
||||
}
|
11
TINKLib/Model/PositionFactory.cs
Normal file
11
TINKLib/Model/PositionFactory.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
namespace TINK.Model
|
||||
{
|
||||
public static class PositionFactory
|
||||
{
|
||||
public static IPosition Create(double latitude = double.NaN, double longitude = double.NaN)
|
||||
=> Position.GetIsValid(longitude, latitude)
|
||||
? new Position(latitude, longitude) as IPosition
|
||||
: new NullPostion();
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace TINK.Model.Station
|
|||
string StationName { get; }
|
||||
|
||||
/// <summary> Holds the gps- position of the station.</summary>
|
||||
Position Position { get; }
|
||||
IPosition Position { get; }
|
||||
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
IData OperatorData { get; }
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace TINK.Model.Station
|
|||
public string StationName => string.Empty;
|
||||
|
||||
/// <summary> Holds the gps- position of the station.</summary>
|
||||
public Position Position => new Position(double.NaN, double.NaN);
|
||||
public IPosition Position => PositionFactory.Create();
|
||||
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
public IData OperatorData => new Data();
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace TINK.Model.Station
|
||||
{
|
||||
public class Position
|
||||
{
|
||||
private const double PRECISSION_LATITUDE_LONGITUDE = 0.000000000000001;
|
||||
|
||||
public Position()
|
||||
{
|
||||
}
|
||||
|
||||
public Position(double latitude, double longitude)
|
||||
{
|
||||
Latitude = latitude;
|
||||
Longitude = longitude;
|
||||
}
|
||||
|
||||
public double Latitude { get; private set; }
|
||||
|
||||
public double Longitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compares position with a target position.
|
||||
/// </summary>
|
||||
/// <param name="p_oTarget">Target position to compare with.</param>
|
||||
/// <returns>True if positions are equal.</returns>
|
||||
public override bool Equals(object p_oTarget)
|
||||
{
|
||||
var l_oTarget = p_oTarget as Position;
|
||||
if (l_oTarget is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Math.Abs(Latitude - l_oTarget.Latitude) < PRECISSION_LATITUDE_LONGITUDE
|
||||
&& Math.Abs(Longitude - l_oTarget.Longitude) < PRECISSION_LATITUDE_LONGITUDE;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCode = -1416534245;
|
||||
hashCode = hashCode * -1521134295 + Latitude.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Longitude.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace TINK.Model.Station
|
|||
public Station(
|
||||
string id,
|
||||
IEnumerable<string> group,
|
||||
Position position,
|
||||
IPosition position,
|
||||
string stationName = "",
|
||||
Data operatorData = null)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace TINK.Model.Station
|
|||
public string StationName { get; }
|
||||
|
||||
/// <summary> Holds the gps- position of the station.</summary>
|
||||
public Position Position { get; }
|
||||
public IPosition Position { get; }
|
||||
|
||||
/// <summary> Holds operator related info.</summary>
|
||||
public IData OperatorData { get; }
|
||||
|
|
|
@ -476,7 +476,7 @@ namespace TINK.Model
|
|||
AppResources.ChangeLog3_0_266
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 270),
|
||||
new Version(3, 0, 271),
|
||||
AppResources.ChangeLog3_0_231 // Minor improvements.
|
||||
}
|
||||
};
|
||||
|
|
|
@ -730,4 +730,7 @@ Deep linking wird unterstützt.</value>
|
|||
<data name="MessageBikesManagementTariffDescriptionTariffHeaderNameId" xml:space="preserve">
|
||||
<value>Tarif {0}, Nr. {1}</value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_266" xml:space="preserve">
|
||||
<value>Abfrage Erlaubnis für Zugriff azf Standort verbessert.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -980,6 +980,10 @@ Deep linking wird unterstützt.</target>
|
|||
<source>Tariff {0}, nr. {1}</source>
|
||||
<target state="translated">Tarif {0}, Nr. {1}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog3_0_266" translate="yes" xml:space="preserve">
|
||||
<source>Location permissions handling improved.</source>
|
||||
<target state="translated">Abfrage Erlaubnis für Zugriff azf Standort verbessert.</target>
|
||||
</trans-unit>
|
||||
</group>
|
||||
</body>
|
||||
</file>
|
||||
|
|
|
@ -769,6 +769,7 @@ namespace TINK.Repository
|
|||
// Returns a http request.
|
||||
var request = WebRequest.CreateHttp(l_strHost);
|
||||
|
||||
request.Timeout = 5000; // Default value for HttpWebRequest is 100 secs. According to doc this has no impact on async call but when debugging it has.
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
request.UserAgent = userAgent;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace TINK.Repository.Response
|
|||
/// Position of the bike.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public GpsInfo gps { get; private set; }
|
||||
public Position gps { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
/// <summary> Full advertisement name.</summary>
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds info about a single bike.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class GpsInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Latitude position of the bike.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string latitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Longitude position of the bike.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string longitude { get; private set; }
|
||||
}
|
||||
}
|
17
TINKLib/Repository/Response/MapSpan.cs
Normal file
17
TINKLib/Repository/Response/MapSpan.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
/// <summary> Holds information about map area to display.</summary>
|
||||
[DataContract]
|
||||
public class MapSpan
|
||||
{
|
||||
/// <summary> Center position of the map. </summary>
|
||||
[DataMember]
|
||||
public Position center { get; private set; }
|
||||
|
||||
/// <summary> Radius to the map area. </summary>
|
||||
[DataMember]
|
||||
public string radius { get; private set; }
|
||||
}
|
||||
}
|
17
TINKLib/Repository/Response/Position.cs
Normal file
17
TINKLib/Repository/Response/Position.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
/// <summary> Holds position info. </summary>
|
||||
[DataContract]
|
||||
public class Position
|
||||
{
|
||||
/// <summary> Latitude position (bike, station, map center...). </summary>
|
||||
[DataMember]
|
||||
public string latitude { get; private set; }
|
||||
|
||||
/// <summary> Longitude position (bike, station, map center...). </summary>
|
||||
[DataMember]
|
||||
public string longitude { get; private set; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -21,6 +21,10 @@ namespace TINK.Repository.Response
|
|||
[DataMember]
|
||||
public string merchant_message { get; private set; }
|
||||
|
||||
/// <summary> Initial map display area.</summary>
|
||||
[DataMember]
|
||||
public MapSpan init_map { get; private set; }
|
||||
|
||||
/// <summary> Textual description of response. </summary>
|
||||
public new string ToString()
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace TINK.Repository.Response
|
|||
/// Position of the station.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public GpsInfo gps { get; private set; }
|
||||
public Position gps { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public OperatorData operator_data { get; private set; }
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
using System;
|
||||
using TINK.Model.Map;
|
||||
|
||||
namespace TINK.Services.CopriApi
|
||||
{
|
||||
/// <summary> Holds general purpose data returned from COPRI. </summary>
|
||||
public class GeneralData
|
||||
{
|
||||
/// <summary> Constructs an empty general data object. </summary>
|
||||
public GeneralData() : this(null, null, null) { }
|
||||
|
||||
public GeneralData(string merachantMessage = null, Version apiVersion = null)
|
||||
{
|
||||
public GeneralData(
|
||||
IMapSpan initialMapSpan,
|
||||
string merachantMessage,
|
||||
Version apiVersion)
|
||||
{
|
||||
InitialMapSpan = initialMapSpan ?? MapSpanFactory.Create();
|
||||
MerchantMessage = merachantMessage ?? string.Empty;
|
||||
ApiVersion = apiVersion ?? new Version(0, 0);
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Initial map display area.</summary>
|
||||
public IMapSpan InitialMapSpan { get; private set; }
|
||||
|
||||
/// <summary> Message to be shown to user.</summary>
|
||||
public string MerchantMessage { get; private set; }
|
||||
|
||||
|
|
|
@ -353,7 +353,30 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
await MoveMapToCurrentPositionOfUser(status);
|
||||
|
||||
// Get map display area
|
||||
Model.Map.IMapSpan mapSpan = null;
|
||||
if (TinkApp.CenterMapToCurrentLocation && status == Status.Granted)
|
||||
{
|
||||
// Get from smart device
|
||||
mapSpan = await GetFromLocationService(status);
|
||||
}
|
||||
|
||||
if (mapSpan == null)
|
||||
{
|
||||
// Use map display are from COPRI
|
||||
mapSpan = resultStationsAndBikes.GeneralData.InitialMapSpan;
|
||||
}
|
||||
|
||||
if (mapSpan.IsValid)
|
||||
{
|
||||
TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
new Xamarin.Forms.GoogleMaps.Position(mapSpan.Center.Latitude, mapSpan.Center.Longitude),
|
||||
new Distance(mapSpan.Radius * 1000));
|
||||
TinkApp.Save();
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
}
|
||||
|
||||
m_oViewUpdateManager = CreateUpdateTask();
|
||||
|
||||
|
@ -462,41 +485,31 @@ namespace TINK.ViewModel.Map
|
|||
/// Moves the map to the current position of the user.
|
||||
/// If location permission hasn't been granted, the position is not adjusted.
|
||||
/// </summary>
|
||||
private async Task MoveMapToCurrentPositionOfUser(Status status)
|
||||
private async Task<Model.Map.IMapSpan> GetFromLocationService(Status status)
|
||||
{
|
||||
if (status == Status.Granted)
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
if (TinkApp.CenterMapToCurrentLocation)
|
||||
{
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
TinkApp.ActiveMapSpan.Radius);
|
||||
TinkApp.Save();
|
||||
}
|
||||
}
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
if (currentLocation == null)
|
||||
return null;
|
||||
|
||||
return Model.Map.MapSpanFactory.Create(
|
||||
PositionFactory.Create(currentLocation.Latitude, currentLocation.Longitude),
|
||||
TinkApp.ActiveMapSpan.Radius.Kilometers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests the location permission from the user.
|
||||
/// If the user declines, a dialog prompot is shown, telling the user to toggle the permission in the device settings.
|
||||
/// </summary>
|
||||
/// <returns>The permission status.</returns>
|
||||
private async Task<Status> RequestLocationPermission()
|
||||
/// <summary>
|
||||
/// Requests the location permission from the user.
|
||||
/// If the user declines, a dialog prompot is shown, telling the user to toggle the permission in the device settings.
|
||||
/// </summary>
|
||||
/// <returns>The permission status.</returns>
|
||||
private async Task<Status> RequestLocationPermission()
|
||||
{
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Station;
|
||||
using TINK.Model.User;
|
||||
|
||||
namespace TestFramework
|
||||
|
@ -18,22 +22,5 @@ namespace TestFramework
|
|||
{
|
||||
return p_strXmlFile.Replace("\r\n", string.Empty).Replace("\t", string.Empty).Replace(" ", string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all bikes at a given station from copri.
|
||||
/// </summary>
|
||||
public static async Task<BikeCollectionMutable> GetBikesAtStation(
|
||||
User user,
|
||||
TINK.Model.Connector.IConnector connector,
|
||||
string selectedStation)
|
||||
{
|
||||
var l_oBikesAtStation = new BikeCollectionMutable();
|
||||
|
||||
var l_oBikesAvailable = (await connector.Query.GetBikesAsync()).Response;
|
||||
|
||||
l_oBikesAtStation.Update(TINK.Model.BikeCollectionFilter.GetAtStation(l_oBikesAvailable, selectedStation));
|
||||
|
||||
return l_oBikesAtStation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,8 +221,77 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestGetPosition()
|
||||
{
|
||||
Assert.AreEqual(1.234d, TextToTypeHelper.GetPosition(JsonConvert.DeserializeObject<GpsInfo>("{ \"latitude\" : \"1.234\", \"longitude\" : \"5.678\"}")).Latitude);
|
||||
Assert.AreEqual(5.678d, TextToTypeHelper.GetPosition(JsonConvert.DeserializeObject<GpsInfo>("{ \"latitude\" : \"1.234\", \"longitude\" : \"5.678\"}")).Longitude);
|
||||
Assert.AreEqual(1.234d, TextToTypeHelper.GetPosition(JsonConvert.DeserializeObject<Position>("{ \"latitude\" : \"1.234\", \"longitude\" : \"5.678\"}")).Latitude);
|
||||
Assert.AreEqual(5.678d, TextToTypeHelper.GetPosition(JsonConvert.DeserializeObject<Position>("{ \"latitude\" : \"1.234\", \"longitude\" : \"5.678\"}")).Longitude);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMapSpan()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<ResponseBase>(@"
|
||||
{
|
||||
""init_map"": {
|
||||
""radius"": ""2.9"",
|
||||
""center"": {
|
||||
""longitude"": ""7.825490"",
|
||||
""latitude"": ""47.976634""
|
||||
}
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetMapSpan(response.init_map).Radius,
|
||||
Is.EqualTo(2.9));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMapSpan_EmptyRadius()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<ResponseBase>(@"
|
||||
{
|
||||
""init_map"": {
|
||||
""radius"": """",
|
||||
""center"": {
|
||||
""longitude"": ""7.825490"",
|
||||
""latitude"": ""47.976634""
|
||||
}
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetMapSpan(response.init_map).IsValid,
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMapSpan_EmptyPos()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<ResponseBase>(@"
|
||||
{
|
||||
""init_map"": {
|
||||
""radius"": """",
|
||||
""center"": {
|
||||
""longitude"": """",
|
||||
""latitude"": ""47.976634""
|
||||
}
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetMapSpan(response.init_map).IsValid,
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMapSpan_Empty()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<ResponseBase>(@"
|
||||
{
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetMapSpan(response.init_map).IsValid,
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
58
TestShareeLib/Model/Map/TestMapSpan.cs
Normal file
58
TestShareeLib/Model/Map/TestMapSpan.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Map;
|
||||
|
||||
namespace TestShareeLib.Model.Map
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestMapSpan
|
||||
{
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var mapSpan = MapSpanFactory.Create(PositionFactory.Create(12, 13), 11);
|
||||
|
||||
Assert.That(mapSpan.GetType(), Is.EqualTo(typeof(MapSpan)), "Object under test is not of expected type.");
|
||||
|
||||
Assert.That(
|
||||
mapSpan.Radius,
|
||||
Is.EqualTo(11.0));
|
||||
|
||||
Assert.That(
|
||||
mapSpan.Center.Longitude,
|
||||
Is.EqualTo(13.0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValid()
|
||||
{
|
||||
Assert.That(
|
||||
MapSpan.GetIsValid(PositionFactory.Create(14, 99), 2.9),
|
||||
Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValidInvalidCenter()
|
||||
{
|
||||
Assert.That(
|
||||
MapSpan.GetIsValid(PositionFactory.Create(), 2.9),
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValidInvalidCenterNull()
|
||||
{
|
||||
Assert.That(
|
||||
MapSpan.GetIsValid(null, 2.9),
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValidInvalidRadius()
|
||||
{
|
||||
Assert.That(
|
||||
MapSpan.GetIsValid(PositionFactory.Create(14, 99), double.NaN),
|
||||
Is.False);
|
||||
}
|
||||
}
|
||||
}
|
26
TestShareeLib/Model/Map/TestMapSpanFactory.cs
Normal file
26
TestShareeLib/Model/Map/TestMapSpanFactory.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Map;
|
||||
|
||||
namespace TestShareeLib.Model.Map
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestMapSpanFactory
|
||||
{
|
||||
[Test]
|
||||
public void TestCreatePositon()
|
||||
{
|
||||
Assert.That(
|
||||
MapSpanFactory.Create(PositionFactory.Create(12, 13), 11).GetType(),
|
||||
Is.EqualTo(typeof(MapSpan)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateNullPositon()
|
||||
{
|
||||
Assert.That(
|
||||
MapSpanFactory.Create().GetType(),
|
||||
Is.EqualTo(typeof(NullMapSpan)));
|
||||
}
|
||||
}
|
||||
}
|
29
TestShareeLib/Model/Map/TestNullMapSpan.cs
Normal file
29
TestShareeLib/Model/Map/TestNullMapSpan.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Map;
|
||||
|
||||
namespace TestShareeLib.Model.Map
|
||||
{
|
||||
[TestFixture]
|
||||
internal class TestNullMapSpan
|
||||
{
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var mapSpan = MapSpanFactory.Create();
|
||||
|
||||
Assert.That(mapSpan.GetType(), Is.EqualTo(typeof(NullMapSpan)), "Object under test is not of expected type.");
|
||||
|
||||
Assert.That(
|
||||
mapSpan.IsValid,
|
||||
Is.False);
|
||||
|
||||
Assert.That(
|
||||
mapSpan.Radius,
|
||||
Is.EqualTo(double.NaN));
|
||||
|
||||
Assert.That(
|
||||
mapSpan.Center.Longitude,
|
||||
Is.EqualTo(double.NaN));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,43 +2,43 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TestFramework;
|
||||
using TestShareeLib;
|
||||
using TINK.Model.State;
|
||||
|
||||
|
||||
namespace TestTINKLib.Fixtures.Bike
|
||||
namespace TestTINKLib.Fixtures.State
|
||||
{
|
||||
|
||||
|
||||
[TestFixture]
|
||||
public class TestStateBookedInfoSerializeJSON
|
||||
public class TestStateReInquestedfoSerializeJSON
|
||||
{
|
||||
[Test]
|
||||
public void TestSerializeJSON()
|
||||
{
|
||||
// Create object to test.
|
||||
var l_oInfoSource = new StateOccupiedInfo(
|
||||
new DateTime(2017, 09, 20, 23, 05, 0),
|
||||
"Heinz@mueller",
|
||||
"17 xxb");
|
||||
var l_oReservedInfo = new StateRequestedInfo(
|
||||
() => new DateTime(2017, 09, 20),
|
||||
new DateTime(2017, 09, 19),
|
||||
"a@b",
|
||||
"372");
|
||||
|
||||
// Serialize object
|
||||
// Serialize object and verify.
|
||||
var l_oDetected = JsonConvert.SerializeObject(l_oInfoSource);
|
||||
const string EXPECTED = @"
|
||||
{
|
||||
""From"":""2017 - 09 - 20T23: 05:00"",
|
||||
""MailAddress"":""Heinz@mueller"",
|
||||
""Code"":""17 xxb""
|
||||
}";
|
||||
var l_oDetected = JsonConvert.SerializeObject(l_oReservedInfo);
|
||||
// Verify xml
|
||||
const string EXPECTED = @"{""From"":""2017 - 09 - 19T00: 00:00"",""MailAddress"":""a @b"",""Code"":""372""}";
|
||||
Assert.AreEqual(
|
||||
TestHelper.PrepareXmlForStringCompare(EXPECTED.Replace("\n", string.Empty).Replace("\r", string.Empty)),
|
||||
TestHelper.PrepareXmlForStringCompare(l_oDetected.Replace("\n", string.Empty).Replace("\r", string.Empty)));
|
||||
TestHelper.PrepareXmlForStringCompare(EXPECTED),
|
||||
TestHelper.PrepareXmlForStringCompare(l_oDetected));
|
||||
|
||||
// Deserialize object and verify.
|
||||
var l_oInfoTarget = JsonConvert.DeserializeObject<StateOccupiedInfo>(l_oDetected);
|
||||
Assert.AreEqual(InUseStateEnum.Booked, l_oInfoTarget.Value);
|
||||
Assert.AreEqual("Heinz@mueller", l_oInfoTarget.MailAddress);
|
||||
Assert.AreEqual("17 xxb", l_oInfoTarget.Code);
|
||||
Assert.AreEqual(new DateTime(2017, 9, 20, 23, 5, 0), l_oInfoTarget.From);
|
||||
// Deserialize object.
|
||||
var l_oInfoTarge = JsonConvert.DeserializeObject<StateRequestedInfo>(l_oDetected);
|
||||
|
||||
// Verify state.
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, l_oInfoTarge.Value);
|
||||
Assert.AreEqual("a@b", l_oInfoTarge.MailAddress);
|
||||
Assert.AreEqual("372", l_oInfoTarge.Code);
|
||||
Assert.AreEqual(new DateTime(2017, 9, 19, 0, 0, 0), l_oInfoTarge.From);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
28
TestShareeLib/Model/TestNullPosition.cs
Normal file
28
TestShareeLib/Model/TestNullPosition.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model;
|
||||
|
||||
namespace TestShareeLib.Model
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestNullPosition
|
||||
{
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var positon = PositionFactory.Create();
|
||||
Assert.That(positon.GetType(), Is.EqualTo(typeof(NullPostion)), "Object under test is not of expected type.");
|
||||
|
||||
Assert.That(
|
||||
positon.IsValid,
|
||||
Is.False);
|
||||
|
||||
Assert.That(
|
||||
positon.Longitude,
|
||||
Is.EqualTo(double.NaN));
|
||||
|
||||
Assert.That(
|
||||
positon.Latitude,
|
||||
Is.EqualTo(double.NaN));
|
||||
}
|
||||
}
|
||||
}
|
75
TestShareeLib/Model/TestPosition.cs
Normal file
75
TestShareeLib/Model/TestPosition.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model;
|
||||
|
||||
namespace TestShareeLib.Model
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestPosition
|
||||
{
|
||||
[Test]
|
||||
public void TestEquals()
|
||||
{
|
||||
var positonA = PositionFactory.Create(12, 13);
|
||||
var positonB = PositionFactory.Create(12, 13);
|
||||
|
||||
Assert.That(positonA.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
||||
Assert.That(positonB.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
||||
|
||||
Assert.That(
|
||||
positonA.Equals(positonB),
|
||||
Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEqualsNotEquaLong()
|
||||
{
|
||||
var positonA = PositionFactory.Create(12, 13);
|
||||
var positonB = PositionFactory.Create(13, 13);
|
||||
|
||||
Assert.That(positonA.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
||||
Assert.That(positonB.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
||||
|
||||
Assert.That(
|
||||
positonA.Equals(positonB),
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEqualsNotEquaLat()
|
||||
{
|
||||
var positonA = PositionFactory.Create(12, 13);
|
||||
var positonB = PositionFactory.Create(12, 12);
|
||||
|
||||
Assert.That(positonA.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
||||
Assert.That(positonB.GetType(), Is.EqualTo(typeof(Position)), "Object under test is not of expected type.");
|
||||
|
||||
Assert.That(
|
||||
positonA.Equals(positonB),
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValid()
|
||||
{
|
||||
Assert.That(
|
||||
Position.GetIsValid(1, 2),
|
||||
Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValidInvalidLong()
|
||||
{
|
||||
Assert.That(
|
||||
Position.GetIsValid(double.NaN, 2),
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsValidInvalidLat()
|
||||
{
|
||||
Assert.That(
|
||||
Position.GetIsValid(2, double.NaN),
|
||||
Is.False);
|
||||
}
|
||||
}
|
||||
}
|
28
TestShareeLib/Model/TestPositionFactory.cs
Normal file
28
TestShareeLib/Model/TestPositionFactory.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TINK.Model;
|
||||
|
||||
namespace TestShareeLib.Model
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestPositionFactory
|
||||
{
|
||||
[Test]
|
||||
public void TestCreatePosition()
|
||||
{
|
||||
Assert.That(
|
||||
PositionFactory.Create(9.55, 8.33).GetType(),
|
||||
Is.EqualTo(typeof(Position)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateNullPosition()
|
||||
{
|
||||
Assert.That(
|
||||
PositionFactory.Create().GetType(),
|
||||
Is.EqualTo(typeof(NullPostion)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Map;
|
||||
using TINK.Services.CopriApi;
|
||||
|
||||
namespace TestShareeLib.Services.CopriApi
|
||||
|
@ -11,19 +13,27 @@ namespace TestShareeLib.Services.CopriApi
|
|||
public void TestCtor()
|
||||
{
|
||||
Assert.That(
|
||||
new GeneralData(null, null).MerchantMessage,
|
||||
new GeneralData().MerchantMessage,
|
||||
Is.EqualTo(""));
|
||||
|
||||
Assert.That(
|
||||
new GeneralData(null, null).ApiVersion,
|
||||
new GeneralData().ApiVersion,
|
||||
Is.EqualTo(new Version(0,0)));
|
||||
|
||||
Assert.That(
|
||||
new GeneralData().InitialMapSpan?.IsValid,
|
||||
Is.False,
|
||||
"Object not not be null but invalid.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMessage()
|
||||
{
|
||||
Assert.That(
|
||||
new GeneralData("Hello", null).MerchantMessage,
|
||||
new GeneralData(
|
||||
MapSpanFactory.Create(),
|
||||
"Hello",
|
||||
null).MerchantMessage,
|
||||
Is.EqualTo("Hello"));
|
||||
}
|
||||
|
||||
|
@ -31,8 +41,30 @@ namespace TestShareeLib.Services.CopriApi
|
|||
public void TestVersion()
|
||||
{
|
||||
Assert.That(
|
||||
new GeneralData(null, new Version(1,2)).ApiVersion,
|
||||
new GeneralData(
|
||||
MapSpanFactory.Create(),
|
||||
null,
|
||||
new Version(1,2)).ApiVersion,
|
||||
Is.EqualTo(new Version(1, 2)));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestInitialMapSpan()
|
||||
{
|
||||
Assert.That(
|
||||
new GeneralData(
|
||||
MapSpanFactory.Create(PositionFactory.Create(0, 8), 15),
|
||||
null,
|
||||
new Version(1, 2)).InitialMapSpan.Center.Longitude,
|
||||
Is.EqualTo(8));
|
||||
|
||||
Assert.That(
|
||||
new GeneralData(
|
||||
MapSpanFactory.Create(PositionFactory.Create(0, 8), 15),
|
||||
null,
|
||||
new Version(1, 2)).InitialMapSpan.Radius,
|
||||
Is.EqualTo(15));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model.Map;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Services.CopriApi;
|
||||
|
||||
|
@ -19,7 +21,10 @@ namespace TestShareeLib.Services.CopriApi
|
|||
public void TestGeneralData()
|
||||
{
|
||||
Assert.That(
|
||||
new Result<object>(typeof(TestResult), new TestResult(), new GeneralData("Hello")).GeneralData.MerchantMessage,
|
||||
new Result<object>(typeof(TestResult), new TestResult(), new GeneralData(
|
||||
MapSpanFactory.Create(),
|
||||
"Hello",
|
||||
new Version(0, 0))).GeneralData.MerchantMessage,
|
||||
Is.EqualTo("Hello"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31229.75
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31912.275
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestShareeLib", "TestShareeLib.csproj", "{FE15D644-F638-48B8-AD63-A3A9D01A8033}"
|
||||
EndProject
|
||||
|
@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TINKLib", "..\TINKLib\TINKL
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFramework", "..\TestFramework\TestFramework.csproj", "{F86692DF-BCB9-4236-8337-04CB65EE4256}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LockItBLE", "..\LockItBLE\LockItBLE.csproj", "{2F7F8786-3655-452E-A697-878C86EFD56A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LockItShared", "..\LockItShared\LockItShared.csproj", "{9E828F60-CC79-4C5D-B647-F15552104524}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -27,6 +31,14 @@ Global
|
|||
{F86692DF-BCB9-4236-8337-04CB65EE4256}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F86692DF-BCB9-4236-8337-04CB65EE4256}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F86692DF-BCB9-4236-8337-04CB65EE4256}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2F7F8786-3655-452E-A697-878C86EFD56A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2F7F8786-3655-452E-A697-878C86EFD56A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2F7F8786-3655-452E-A697-878C86EFD56A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F7F8786-3655-452E-A697-878C86EFD56A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9E828F60-CC79-4C5D-B647-F15552104524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9E828F60-CC79-4C5D-B647-F15552104524}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9E828F60-CC79-4C5D-B647-F15552104524}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9E828F60-CC79-4C5D-B647-F15552104524}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Services.CopriApi.ServerUris;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using NUnit.Framework;
|
||||
using Rhino.Mocks;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Connector;
|
||||
using System.Linq;
|
||||
using TINK.Repository;
|
||||
using TestFramework.Repository;
|
||||
using System;
|
||||
using NSubstitute;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
||||
{
|
||||
|
@ -86,13 +86,15 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
[Test]
|
||||
public void TestIsConnected()
|
||||
{
|
||||
var l_oMock = MockRepository.GenerateMock<IConnector>();
|
||||
l_oMock.Expect(x => x.IsConnected).Return(true) ;
|
||||
Assert.IsTrue(new FilteredConnector(new List<string>(), l_oMock).IsConnected);
|
||||
var connector = Substitute.For<IConnector>();
|
||||
connector.IsConnected.Returns(true);
|
||||
Assert.IsTrue(new FilteredConnector(new List<string>(), connector).IsConnected);
|
||||
var dummy = connector.Received().IsConnected;
|
||||
|
||||
l_oMock = MockRepository.GenerateMock<IConnector>();
|
||||
l_oMock.Expect(x => x.IsConnected).Return(false);
|
||||
Assert.IsFalse(new FilteredConnector(new List<string>(), l_oMock).IsConnected);
|
||||
connector = Substitute.For<IConnector>();
|
||||
connector.IsConnected.Returns(false);
|
||||
Assert.IsFalse(new FilteredConnector(new List<string>(), connector).IsConnected);
|
||||
dummy = connector.Received().IsConnected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TINK.Model.Station;
|
||||
|
||||
using TINK.Model;
|
||||
|
||||
namespace TestTINKLib.Fixtures.Station
|
||||
{
|
||||
|
@ -14,7 +13,7 @@ namespace TestTINKLib.Fixtures.Station
|
|||
[Test]
|
||||
public void TestConstruct()
|
||||
{
|
||||
var l_oStation = new TINK.Model.Station.Station("7", new HashSet<string>(new List<string> { "TINK" }).ToList(), new Position(1,2), "Hallo");
|
||||
var l_oStation = new TINK.Model.Station.Station("7", new HashSet<string>(new List<string> { "TINK" }).ToList(), PositionFactory.Create(1,2), "Hallo");
|
||||
Assert.AreEqual("7", l_oStation.Id);
|
||||
Assert.AreEqual("TINK", string.Join(",", l_oStation.Group));
|
||||
Assert.AreEqual(1, l_oStation.Position.Latitude);
|
||||
|
@ -25,7 +24,7 @@ namespace TestTINKLib.Fixtures.Station
|
|||
[Test]
|
||||
public void TestConstruct_InvalidStationName()
|
||||
{
|
||||
var l_oStation = new TINK.Model.Station.Station("7", new HashSet<string>(new List<string> { "TINK" }).ToList(), new Position(1, 2), null);
|
||||
var l_oStation = new TINK.Model.Station.Station("7", new HashSet<string>(new List<string> { "TINK" }).ToList(), PositionFactory.Create(1, 2), null);
|
||||
Assert.AreEqual("7", l_oStation.Id);
|
||||
Assert.AreEqual("TINK", string.Join(",", l_oStation.Group));
|
||||
Assert.AreEqual(1, l_oStation.Position.Latitude);
|
||||
|
@ -36,14 +35,14 @@ namespace TestTINKLib.Fixtures.Station
|
|||
[Test]
|
||||
public void TestConstruct_InvalidStationGroup()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new TINK.Model.Station.Station("7", null, new Position(1, 2), "Hallo"));
|
||||
Assert.Throws<ArgumentException>(() => new TINK.Model.Station.Station("7", null, PositionFactory.Create(1, 2), "Hallo"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConstruct_NoOperator()
|
||||
{
|
||||
Assert.That(
|
||||
new TINK.Model.Station.Station("7", new List<string>(), new Position(1, 2), "Hallo").OperatorData,
|
||||
new TINK.Model.Station.Station("7", new List<string>(), PositionFactory.Create(1, 2), "Hallo").OperatorData,
|
||||
Is.Not.Null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace UITest.Fixtures.ObjectTests.User.Account
|
|||
|
||||
Assert.AreEqual("a@b", account.Mail);
|
||||
Assert.AreEqual("112", account.Pwd);
|
||||
Assert.That(account.IsAgbAcknowledged, Is.False);
|
||||
Assert.That(account.IsAgbAcknowledged, Is.True);
|
||||
Assert.AreEqual("3330", account.SessionCookie);
|
||||
Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group));
|
||||
Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel);
|
||||
|
|
|
@ -123,7 +123,6 @@
|
|||
<Compile Include="Fixtures\ObjectTests\Connector\Response\TestBookingResponse.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Response\TestResponseBase.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Response\TestStationsAllResponse.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestTextToTypeHelper.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\State\TestStateBookedInfo.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\State\TestStateDisposableInfo.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\State\TestStateInfoMutable.cs" />
|
||||
|
|
Loading…
Add table
Reference in a new issue