Skip to content

Commit

Permalink
Reduce amount of projects.
Browse files Browse the repository at this point in the history
Add the Sql Login Screen to my custom Dialogs
Add a test to check our connection string
  • Loading branch information
LoneWandererProductions committed Dec 26, 2023
1 parent 18613a8 commit 894e2c5
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 43 deletions.
13 changes: 13 additions & 0 deletions CommonControls/FileIoHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ public static string ShowFolder(string folder)
return browser.Root;
}

/// <summary>
/// Shows the login screen.
/// </summary>
/// <returns>Connection String</returns>
public static string ShowLoginScreen()
{
var login = new SqlLogin();
_ = login.ShowDialog();

return login.View.ConnectionString;
}


/// <summary>
/// Looks up a file
/// Returns the PathObject
Expand Down
4 changes: 2 additions & 2 deletions CommonControls/SqlLogin.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mc:Ignorable="d"
Title="Connect to Server" Height="450" Width="450">
<Window.DataContext>
<local:SqlView x:Name="View" />
<local:SqlView x:Name="View" x:FieldModifier="public" />
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
Expand Down Expand Up @@ -38,7 +38,7 @@
<TextBox Grid.ColumnSpan="2" Grid.Column="2" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Path=Server, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.ColumnSpan="2" Grid.Column="2" Grid.Row="3" TextWrapping="Wrap" Text="{Binding Path=Database, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="Connect" Grid.Column="2" HorizontalAlignment="Left" Grid.Row="7" VerticalAlignment="Top" Command="{Binding ConnectCommand}"/>
<Button Content="Close" Grid.Column="3" HorizontalAlignment="Left" Grid.Row="7" VerticalAlignment="Top" Click="Button_Click"/>
<Button Content="Close" Grid.Column="3" HorizontalAlignment="Left" Grid.Row="7" VerticalAlignment="Top" Command="{Binding CloseCommand}"/>
<TextBox Grid.ColumnSpan="2" Grid.Column="2" HorizontalAlignment="Stretch" Grid.Row="9" TextWrapping="Wrap" VerticalAlignment="Stretch" Text="{Binding Path=Log, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="False"/>
</Grid>
</Window>
10 changes: 0 additions & 10 deletions CommonControls/SqlLogin.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,5 @@ public SqlLogin()
{
InitializeComponent();
}

/// <summary>
/// Handles the Click event of the Button control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}
25 changes: 24 additions & 1 deletion CommonControls/SqlView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// ReSharper disable MemberCanBePrivate.Global

using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using ViewModel;

Expand All @@ -28,6 +29,11 @@ public sealed class SqlView : INotifyPropertyChanged
/// </summary>
private ICommand _connectCommand;

/// <summary>
/// The close command
/// </summary>
private ICommand _closeCommand;

/// <summary>
/// The data base
/// </summary>
Expand Down Expand Up @@ -136,6 +142,15 @@ public string Log
public ICommand ConnectCommand =>
_connectCommand ??= new DelegateCommand<object>(ConnectAction, CanExecute);

/// <summary>
/// Gets the close command.
/// </summary>
/// <value>
/// The close command.
/// </value>
public ICommand CloseCommand =>
_closeCommand ??= new DelegateCommand<object>(CloseAction, CanExecute);

/// <summary>
/// Gets the connection string.
/// </summary>
Expand All @@ -153,7 +168,6 @@ public string Log
/// </value>
public string AddLog { get; set; }


/// <inheritdoc />
/// <summary>
/// Triggers if an Attribute gets changed
Expand Down Expand Up @@ -194,5 +208,14 @@ private void ConnectAction(object obj)
var connect = new SqlConnect(Database, Server, IsActive);
ConnectionString = connect.GetConnectionString();
}

/// <summary>
/// Closes the app
/// </summary>
/// <param name="obj">The object.</param>
private void CloseAction(object obj)
{
Application.Current.Shutdown();
}
}
}
20 changes: 20 additions & 0 deletions CommonLibraryGuiTests/CommonCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* PROGRAMER: Peter Geinitz (Wayfarer)
*/

using System;
using System.Collections.Generic;
using System.Threading;
using CommonControls;
Expand Down Expand Up @@ -113,5 +114,24 @@ public void Win32Api()
//TODO Test in Live environment
Assert.AreNotEqual(512, Win32Enums.MouseEvents.WmMousemove, "checked out");
}

/// <summary>
/// Test of the ConnectionString Dialog.
/// </summary>
[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));
}
}
}
1 change: 1 addition & 0 deletions CommonLibraryTests/CommonLibraryTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

<ItemGroup>
<ProjectReference Include="..\CommonControls\CommonControls.csproj" />
<ProjectReference Include="..\Communication\Communication.csproj" />
<ProjectReference Include="..\ExtendedSystemObjects\ExtendedSystemObjects.csproj" />
<ProjectReference Include="..\FileHandler\FileHandler.csproj" />
<ProjectReference Include="..\ImageCompare\ImageCompare.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -10,13 +10,19 @@
using Communication;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CommonLibraryTestsCommunication
namespace CommonLibraryTests
{
[TestClass]
public class Communication
{
/// <summary>
/// The path
/// </summary>
private readonly string _path = Path.Combine(Directory.GetCurrentDirectory(), nameof(Communication));

/// <summary>
/// Communicationses this instance.
/// </summary>
[TestMethod]
public void Communications()
{
Expand Down

This file was deleted.

10 changes: 2 additions & 8 deletions CoreLibrary.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 894e2c5

Please sign in to comment.