From dd1c3ede4a9a9dd32a2bd243e8bd411ad55917d7 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Fri, 25 Mar 2022 10:13:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20GeoLocation=20?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/GeolocationTest.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/UnitTest/Components/GeolocationTest.cs diff --git a/test/UnitTest/Components/GeolocationTest.cs b/test/UnitTest/Components/GeolocationTest.cs new file mode 100644 index 000000000..9d7ef490a --- /dev/null +++ b/test/UnitTest/Components/GeolocationTest.cs @@ -0,0 +1,11 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +using Microsoft.JSInterop; + +namespace UnitTest.Components; + +public class GeolocationTest : BootstrapBlazorTestBase +{ +} -- Gitee From 14d57934cba2e3164208928fef74d148ff7c9c83 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Fri, 25 Mar 2022 10:13:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/GeolocationTest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/UnitTest/Components/GeolocationTest.cs b/test/UnitTest/Components/GeolocationTest.cs index 9d7ef490a..b8c230e6c 100644 --- a/test/UnitTest/Components/GeolocationTest.cs +++ b/test/UnitTest/Components/GeolocationTest.cs @@ -8,4 +8,13 @@ namespace UnitTest.Components; public class GeolocationTest : BootstrapBlazorTestBase { + [Fact] + public async Task Geolocation_Ok() + { + var cut = Context.RenderComponent(); + var instance = cut.Instance; + await instance.GetLocaltion(); + await instance.WatchPosition(); + await instance.ClearWatchPosition(1); + } } -- Gitee From d49e48f8703fcc5bdf83a1003412cf0be3c5ae96 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Fri, 25 Mar 2022 10:13:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/GeolocationTest.cs | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/UnitTest/Components/GeolocationTest.cs b/test/UnitTest/Components/GeolocationTest.cs index b8c230e6c..fcc218b9f 100644 --- a/test/UnitTest/Components/GeolocationTest.cs +++ b/test/UnitTest/Components/GeolocationTest.cs @@ -17,4 +17,59 @@ public class GeolocationTest : BootstrapBlazorTestBase await instance.WatchPosition(); await instance.ClearWatchPosition(1); } + + [Fact] + public void GeolocationItem_Ok() + { + var item = new GeolocationItem() + { + Latitude = 10, + Accuracy = 10, + Altitude = 10, + AltitudeAccuracy = 10, + CurrentDistance = 10, + Heading = 10, + LastLat = 10, + LastLong = 10, + Longitude = 10, + Speed = 10, + Timestamp = 10, + TotalDistance = 10 + }; + Assert.Equal(10, item.Latitude); + Assert.Equal(10, item.Accuracy); + Assert.Equal(10, item.Altitude); + Assert.Equal(10, item.AltitudeAccuracy); + Assert.Equal(10, item.CurrentDistance); + Assert.Equal(10, item.Heading); + Assert.Equal(10, item.LastLong); + Assert.Equal(10, item.LastLat); + Assert.Equal(10, item.Longitude); + Assert.Equal(10, item.Speed); + Assert.Equal(10, item.Timestamp); + Assert.Equal(10, item.TotalDistance); + Assert.Equal(1970, item.LastUpdateTime.Year); + } + + private class MockGeoTest : ComponentBase + { + [Inject] + [NotNull] + private IJSRuntime? JSRuntime { get; set; } + + [NotNull] + private JSInterop? Interop { get; set; } + + protected override void OnInitialized() + { + base.OnInitialized(); + Interop = new JSInterop(JSRuntime); + } + + public ValueTask GetLocaltion() => Geolocation.GetLocaltion(Interop, this, "Test"); + + public ValueTask WatchPosition() => Geolocation.WatchPosition(Interop, this, "Test"); + + public ValueTask ClearWatchPosition(long watchId) => Geolocation.ClearWatchPosition(Interop, watchId); + } } -- Gitee