Browse Source

PRS MOBILE - Connection Test app individual client tests

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
3c275c53e1

+ 9 - 2
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/ConnectionTestUnit.xaml

@@ -5,7 +5,7 @@
     <ContentView.Content>
         <Frame Padding="2" CornerRadius="5" Margin="2" BorderColor="DarkGray">
             <StackLayout>
-                <Label x:Name="urlLbl" HorizontalOptions="Center" FontAttributes="Bold" FontSize="24"/>
+                <Label x:Name="urlLbl" Grid.Column="0" HorizontalOptions="Center" FontAttributes="Bold" FontSize="24"/>
                 <Grid>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="*"/>
@@ -21,7 +21,14 @@
                         <Label x:Name="refreshLbl" HorizontalOptions="Center"/>
                     </StackLayout>
                 </Grid>
-                <Button x:Name="emailBtn" Text="Email logs" Clicked="EmailBtn_Clicked"/>
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="*"/>
+                        <ColumnDefinition Width="auto"/>
+                    </Grid.ColumnDefinitions>
+                    <Button Grid.Column="0" x:Name="emailBtn" Text="Email logs" Clicked="EmailBtn_Clicked"/>
+                    <Button Grid.Column="1" Text="Close" Clicked="CloseButton_Clicked" HorizontalOptions="End"/>
+                </Grid>
             </StackLayout>
         </Frame>
     </ContentView.Content>

+ 12 - 3
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/ConnectionTestUnit.xaml.cs

@@ -9,12 +9,15 @@ using Xamarin.Essentials;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using System.Net;
+using InABox.Core;
 
 namespace ConnectionTest
 {
+    public delegate void RemoveURL(View view);
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class ConnectionTestUnit : ContentView
     {
+        public event RemoveURL OnRemoveURL;
         string URL = "";
         string log = "";
         public ConnectionTestUnit(string url)
@@ -24,7 +27,7 @@ namespace ConnectionTest
             urlLbl.Text = URL;
             Task.Run(() =>
             {
-                Thread.Sleep(500);
+                Thread.Sleep(3000);
                 StartTest();
             });
             Resolve();
@@ -96,13 +99,14 @@ namespace ConnectionTest
         {
             int count = 1;
             int crashcount = 0;
-            ClientFactory.SetClientType(typeof(JsonClient<>), "Test app", "1.0", URL, true);
             while (true)
             {
                 try
                 {
                     Thread.Sleep(500);
-                    var result = ClientFactory.Validate("TAN", "nictan");
+                    var client = new JsonClient<User>(URL);
+                    var result = client.Validate("TAN", "nictan", Guid.Empty);
+
                     Device.BeginInvokeOnMainThread(() =>
                     {
                         attemptNoLbl.Text = "Attempt: " + count;
@@ -121,5 +125,10 @@ namespace ConnectionTest
                 }
             }
         }
+
+        private void CloseButton_Clicked(object sender, EventArgs e)
+        {
+            OnRemoveURL?.Invoke(this);
+        }
     }
 }

+ 6 - 0
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/MainPage.xaml.cs

@@ -26,10 +26,16 @@ namespace ConnectionTest
             foreach (var url in urls) 
             {
                 var test = new ConnectionTestUnit(url);
+                test.OnRemoveURL += Test_OnRemoveURL;
                 stacklayout.Children.Add(test);
             }
         }
 
+        private void Test_OnRemoveURL(View view)
+        {
+            stacklayout.Children.Remove(view);
+        }
+
         private void AddButton_Clicked(object sender, EventArgs e)
         {
             if (!string.IsNullOrWhiteSpace(urlEnt.Text))