From 2ea5cf345750acbcbdf769144b33a8dc14a775c6 Mon Sep 17 00:00:00 2001 From: Benjamin Russell Date: Wed, 27 Jul 2016 16:45:01 -0700 Subject: [PATCH] Quick refactor of the connection service Refactoring to match the layout of the other services. --- .../ConnectionService.cs | 0 .../Contracts}/ConnectionMessages.cs | 2 +- .../Contracts}/ISqlConnection.cs | 13 +---------- .../Contracts/ISqlConnectionFactory.cs | 18 +++++++++++++++ .../Contracts}/SqlConnection.cs | 18 +-------------- .../Contracts/SqlConnectionFactory.cs | 23 +++++++++++++++++++ 6 files changed, 44 insertions(+), 30 deletions(-) rename src/ServiceHost/{Connection => ConnectionServices}/ConnectionService.cs (100%) rename src/ServiceHost/{Connection => ConnectionServices/Contracts}/ConnectionMessages.cs (96%) rename src/ServiceHost/{Connection => ConnectionServices/Contracts}/ISqlConnection.cs (64%) create mode 100644 src/ServiceHost/ConnectionServices/Contracts/ISqlConnectionFactory.cs rename src/ServiceHost/{Connection => ConnectionServices/Contracts}/SqlConnection.cs (76%) create mode 100644 src/ServiceHost/ConnectionServices/Contracts/SqlConnectionFactory.cs diff --git a/src/ServiceHost/Connection/ConnectionService.cs b/src/ServiceHost/ConnectionServices/ConnectionService.cs similarity index 100% rename from src/ServiceHost/Connection/ConnectionService.cs rename to src/ServiceHost/ConnectionServices/ConnectionService.cs diff --git a/src/ServiceHost/Connection/ConnectionMessages.cs b/src/ServiceHost/ConnectionServices/Contracts/ConnectionMessages.cs similarity index 96% rename from src/ServiceHost/Connection/ConnectionMessages.cs rename to src/ServiceHost/ConnectionServices/Contracts/ConnectionMessages.cs index a2b506aa..ddbca266 100644 --- a/src/ServiceHost/Connection/ConnectionMessages.cs +++ b/src/ServiceHost/ConnectionServices/Contracts/ConnectionMessages.cs @@ -5,7 +5,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; -namespace Microsoft.SqlTools.ServiceLayer.Connection +namespace Microsoft.SqlTools.ServiceLayer.ConnectionServices.Contracts { /// /// Message format for the initial connection request diff --git a/src/ServiceHost/Connection/ISqlConnection.cs b/src/ServiceHost/ConnectionServices/Contracts/ISqlConnection.cs similarity index 64% rename from src/ServiceHost/Connection/ISqlConnection.cs rename to src/ServiceHost/ConnectionServices/Contracts/ISqlConnection.cs index 3e5fbdfe..a9a255f3 100644 --- a/src/ServiceHost/Connection/ISqlConnection.cs +++ b/src/ServiceHost/ConnectionServices/Contracts/ISqlConnection.cs @@ -5,19 +5,8 @@ using System.Collections.Generic; -namespace Microsoft.SqlTools.ServiceLayer.Connection +namespace Microsoft.SqlTools.ServiceLayer.ConnectionServices.Contracts { - /// - /// Interface for the SQL Connection factory - /// - public interface ISqlConnectionFactory - { - /// - /// Create a new SQL Connection object - /// - ISqlConnection CreateSqlConnection(); - } - /// /// Interface for the SQL Connection wrapper /// diff --git a/src/ServiceHost/ConnectionServices/Contracts/ISqlConnectionFactory.cs b/src/ServiceHost/ConnectionServices/Contracts/ISqlConnectionFactory.cs new file mode 100644 index 00000000..0a79ec0d --- /dev/null +++ b/src/ServiceHost/ConnectionServices/Contracts/ISqlConnectionFactory.cs @@ -0,0 +1,18 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +namespace Microsoft.SqlTools.ServiceLayer.ConnectionServices.Contracts +{ + /// + /// Interface for the SQL Connection factory + /// + public interface ISqlConnectionFactory + { + /// + /// Create a new SQL Connection object + /// + ISqlConnection CreateSqlConnection(); + } +} diff --git a/src/ServiceHost/Connection/SqlConnection.cs b/src/ServiceHost/ConnectionServices/Contracts/SqlConnection.cs similarity index 76% rename from src/ServiceHost/Connection/SqlConnection.cs rename to src/ServiceHost/ConnectionServices/Contracts/SqlConnection.cs index 6ad90b39..937deaa1 100644 --- a/src/ServiceHost/Connection/SqlConnection.cs +++ b/src/ServiceHost/ConnectionServices/Contracts/SqlConnection.cs @@ -7,24 +7,8 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -namespace Microsoft.SqlTools.ServiceLayer.Connection +namespace Microsoft.SqlTools.ServiceLayer.ConnectionServices.Contracts { - /// - /// Factory class to create SqlClientConnections - /// The purpose of the factory is to make it easier to mock out the database - /// in 'offline' unit test scenarios. - /// - public class SqlConnectionFactory : ISqlConnectionFactory - { - /// - /// Creates a new SqlClientConnection object - /// - public ISqlConnection CreateSqlConnection() - { - return new SqlClientConnection(); - } - } - /// /// Wrapper class that implements ISqlConnection and hosts a SqlConnection. /// This wrapper exists primarily for decoupling to support unit testing. diff --git a/src/ServiceHost/ConnectionServices/Contracts/SqlConnectionFactory.cs b/src/ServiceHost/ConnectionServices/Contracts/SqlConnectionFactory.cs new file mode 100644 index 00000000..79fbae51 --- /dev/null +++ b/src/ServiceHost/ConnectionServices/Contracts/SqlConnectionFactory.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +namespace Microsoft.SqlTools.ServiceLayer.ConnectionServices.Contracts +{ + /// + /// Factory class to create SqlClientConnections + /// The purpose of the factory is to make it easier to mock out the database + /// in 'offline' unit test scenarios. + /// + public class SqlConnectionFactory : ISqlConnectionFactory + { + /// + /// Creates a new SqlClientConnection object + /// + public ISqlConnection CreateSqlConnection() + { + return new SqlClientConnection(); + } + } +}