diff --git a/CommonControls/FileIoHandler.cs b/CommonControls/FileIoHandler.cs index 9fc84df2..45215180 100644 --- a/CommonControls/FileIoHandler.cs +++ b/CommonControls/FileIoHandler.cs @@ -38,6 +38,19 @@ public static string ShowFolder(string folder) return browser.Root; } + /// + /// Shows the login screen. + /// + /// Connection String + public static string ShowLoginScreen() + { + var login = new SqlLogin(); + _ = login.ShowDialog(); + + return login.View.ConnectionString; + } + + /// /// Looks up a file /// Returns the PathObject diff --git a/CommonControls/SqlLogin.xaml b/CommonControls/SqlLogin.xaml index 2c030bd2..b3ba12ff 100644 --- a/CommonControls/SqlLogin.xaml +++ b/CommonControls/SqlLogin.xaml @@ -8,7 +8,7 @@ mc:Ignorable="d" Title="Connect to Server" Height="450" Width="450"> - + @@ -38,7 +38,7 @@ private ICommand _connectCommand; + /// + /// The close command + /// + private ICommand _closeCommand; + /// /// The data base /// @@ -136,6 +142,15 @@ public string Log public ICommand ConnectCommand => _connectCommand ??= new DelegateCommand(ConnectAction, CanExecute); + /// + /// Gets the close command. + /// + /// + /// The close command. + /// + public ICommand CloseCommand => + _closeCommand ??= new DelegateCommand(CloseAction, CanExecute); + /// /// Gets the connection string. /// @@ -153,7 +168,6 @@ public string Log /// public string AddLog { get; set; } - /// /// /// Triggers if an Attribute gets changed @@ -194,5 +208,14 @@ private void ConnectAction(object obj) var connect = new SqlConnect(Database, Server, IsActive); ConnectionString = connect.GetConnectionString(); } + + /// + /// Closes the app + /// + /// The object. + private void CloseAction(object obj) + { + Application.Current.Shutdown(); + } } } diff --git a/CommonLibraryGuiTests/CommonCtrl.cs b/CommonLibraryGuiTests/CommonCtrl.cs index c65ee95d..ac5d7800 100644 --- a/CommonLibraryGuiTests/CommonCtrl.cs +++ b/CommonLibraryGuiTests/CommonCtrl.cs @@ -6,6 +6,7 @@ * PROGRAMER: Peter Geinitz (Wayfarer) */ +using System; using System.Collections.Generic; using System.Threading; using CommonControls; @@ -113,5 +114,24 @@ public void Win32Api() //TODO Test in Live environment Assert.AreNotEqual(512, Win32Enums.MouseEvents.WmMousemove, "checked out"); } + + /// + /// Test of the ConnectionString Dialog. + /// + [Test] + [Apartment(ApartmentState.STA)] + public void ConnectionString() + { + var login = new SqlLogin(); + login.Show(); + login.View.Server = "SqlServer"; + login.View.Database = @"MyDB\Hello"; + login.View.ConnectCommand.Execute(null); + var result = login.View.ConnectionString; + login.Close(); + + Assert.IsTrue(result.Equals(@"PersistSecurity Info= False;TrustServerCertificate=False;Integrated Security=True;SqlServer;MyDB\Hello", StringComparison.Ordinal), + string.Concat("Wrong Connection string: ", result)); + } } } diff --git a/CommonLibraryTests/CommonLibraryTests.csproj b/CommonLibraryTests/CommonLibraryTests.csproj index 96ac61c6..d61ecfad 100644 --- a/CommonLibraryTests/CommonLibraryTests.csproj +++ b/CommonLibraryTests/CommonLibraryTests.csproj @@ -49,6 +49,7 @@ + diff --git a/CommonLibraryTestsCommunication/Communication.cs b/CommonLibraryTests/Communication.cs similarity index 79% rename from CommonLibraryTestsCommunication/Communication.cs rename to CommonLibraryTests/Communication.cs index 1ed1f9c3..e83dc5b8 100644 --- a/CommonLibraryTestsCommunication/Communication.cs +++ b/CommonLibraryTests/Communication.cs @@ -1,6 +1,6 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: CommonLibraryTestsCommunication + * PROJECT: CommonLibraryTests * FILE: Communication.cs * PURPOSE: Test for our communication * PROGRAMER: Peter Geinitz (Wayfarer) @@ -10,13 +10,19 @@ using Communication; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace CommonLibraryTestsCommunication +namespace CommonLibraryTests { [TestClass] public class Communication { + /// + /// The path + /// private readonly string _path = Path.Combine(Directory.GetCurrentDirectory(), nameof(Communication)); + /// + /// Communicationses this instance. + /// [TestMethod] public void Communications() { diff --git a/CommonLibraryTestsCommunication/CommonLibraryTestsCommunication.csproj b/CommonLibraryTestsCommunication/CommonLibraryTestsCommunication.csproj deleted file mode 100644 index dbe8431a..00000000 --- a/CommonLibraryTestsCommunication/CommonLibraryTestsCommunication.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net5.0 - - false - - - - - - - - - - - - - - diff --git a/CoreLibrary.sln b/CoreLibrary.sln index 586eeab6..89523e4e 100644 --- a/CoreLibrary.sln +++ b/CoreLibrary.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34330.188 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.34301.259 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViewModel", "ViewModel\ViewModel.csproj", "{9B2741D2-443A-4136-B9A4-1191686DA4AD}" EndProject @@ -51,8 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Communication", "Communicat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LightVector", "LightVector\LightVector.csproj", "{8DD286ED-2358-47E1-BD4D-B4DCB550681E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonLibraryTestsCommunication", "CommonLibraryTestsCommunication\CommonLibraryTestsCommunication.csproj", "{B98A7BCE-4188-4E1E-B733-A89906049BEC}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mathematics", "Mathematics\Mathematics.csproj", "{03B1DB00-54D5-4095-BE71-B26CFA923420}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imaging", "Imaging\Imaging.csproj", "{810F6A32-3C86-4DB8-B3C3-F9CF438A1D47}" @@ -143,10 +141,6 @@ Global {8DD286ED-2358-47E1-BD4D-B4DCB550681E}.Debug|Any CPU.Build.0 = Debug|Any CPU {8DD286ED-2358-47E1-BD4D-B4DCB550681E}.Release|Any CPU.ActiveCfg = Release|Any CPU {8DD286ED-2358-47E1-BD4D-B4DCB550681E}.Release|Any CPU.Build.0 = Release|Any CPU - {B98A7BCE-4188-4E1E-B733-A89906049BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B98A7BCE-4188-4E1E-B733-A89906049BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B98A7BCE-4188-4E1E-B733-A89906049BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B98A7BCE-4188-4E1E-B733-A89906049BEC}.Release|Any CPU.Build.0 = Release|Any CPU {03B1DB00-54D5-4095-BE71-B26CFA923420}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03B1DB00-54D5-4095-BE71-B26CFA923420}.Debug|Any CPU.Build.0 = Debug|Any CPU {03B1DB00-54D5-4095-BE71-B26CFA923420}.Release|Any CPU.ActiveCfg = Release|Any CPU