aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/App.config20
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs64
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Helper.cs9
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj30
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/packages.config5
5 files changed, 128 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/App.config b/Software/Visual_Studio/Tango.UnitTesting/App.config
new file mode 100644
index 000000000..901eeb586
--- /dev/null
+++ b/Software/Visual_Studio/Tango.UnitTesting/App.config
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
+ </providers>
+ </entityFramework>
+ <system.data>
+ <DbProviderFactories>
+ <remove invariant="System.Data.SQLite.EF6" />
+ <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
+ <remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
+ </system.data>
+</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs
new file mode 100644
index 000000000..b56f04c70
--- /dev/null
+++ b/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs
@@ -0,0 +1,64 @@
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Tango.DAL;
+using System.Linq;
+
+namespace Tango.UnitTesting
+{
+ [TestClass]
+ [TestCategory("DAL")]
+ public class DAL_TST
+ {
+ [TestMethod]
+ public void Validate_Server_SQLServer_Connection()
+ {
+ Guid guid = Guid.NewGuid();
+
+ using (var db = new DAL.Remote.DB.RemoteDB("LOCALHOST\\SQLEXPRESS", false))
+ {
+ var action = new DAL.Remote.DB.ACTION();
+ action.CODE = 1;
+ action.NAME = "Action 1";
+ action.DESCRIPTION = "Description 1";
+ action.GUID = guid;
+ action.LAST_UPDATED = DateTime.Now;
+
+ db.ACTIONS.Add(action);
+ db.SaveChanges();
+ }
+
+ using (var db = new DAL.Remote.DB.RemoteDB("LOCALHOST\\SQLEXPRESS", false))
+ {
+ var action = db.ACTIONS.Single(x => x.GUID == guid);
+ db.ACTIONS.Remove(action);
+ db.SaveChanges();
+ }
+ }
+
+ [TestMethod]
+ public void Validate_Local_SQLite_Connection()
+ {
+ String guid = Guid.NewGuid().ToString();
+
+ using (var db = new DAL.Local.DB.LocalDB(Helper.GetSQLiteFilePath()))
+ {
+ var action = new DAL.Local.DB.ACTION();
+ action.CODE = 1;
+ action.NAME = "Action 1";
+ action.DESCRIPTION = "Description 1";
+ action.GUID = guid;
+
+ db.ACTIONS.Add(action);
+ db.SaveChanges();
+ }
+
+ using (var db = new DAL.Local.DB.LocalDB(Helper.GetSQLiteFilePath()))
+ {
+ var actions = db.ACTIONS.ToList();
+ var action = db.ACTIONS.Single(x => x.GUID == guid);
+ db.ACTIONS.Remove(action);
+ db.SaveChanges();
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Helper.cs b/Software/Visual_Studio/Tango.UnitTesting/Helper.cs
index ece74d3f3..21e36168c 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Helper.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/Helper.cs
@@ -35,6 +35,15 @@ namespace Tango.UnitTesting
}
/// <summary>
+ /// Gets the SQLite database file path in DB folder.
+ /// </summary>
+ /// <returns></returns>
+ public static String GetSQLiteFilePath()
+ {
+ return Path.GetFullPath(@"..\..\..\DB\Tango.db");
+ }
+
+ /// <summary>
/// Initializes the logging manager.
/// </summary>
public static ConsoleLogger InitializeLogging(bool useConsole = false, [CallerMemberName] string testName = null)
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
index 02a500341..494981db1 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
+++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
@@ -40,6 +40,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+ </Reference>
<Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
@@ -53,7 +59,19 @@
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
+ <Reference Include="System.Data.SQLite, Version=1.0.106.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Data.SQLite.Core.1.0.106.0\lib\net46\System.Data.SQLite.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data.SQLite.EF6, Version=1.0.106.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Data.SQLite.EF6.1.0.106.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="System.Data.SQLite.Linq, Version=1.0.106.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+ <HintPath>..\packages\System.Data.SQLite.Linq.1.0.106.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Versioning\GlobalVersionInfo.cs">
@@ -62,8 +80,10 @@
<Compile Include="Helper.cs" />
<Compile Include="Protobuf_TST.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="DAL_TST.cs" />
</ItemGroup>
<ItemGroup>
+ <None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@@ -71,6 +91,14 @@
<Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
<Name>Tango.Core</Name>
</ProjectReference>
+ <ProjectReference Include="..\Tango.DAL.Local\Tango.DAL.Local.csproj">
+ <Project>{0e0eef3e-8f4e-4f23-9d19-479fd8d76c12}</Project>
+ <Name>Tango.DAL.Local</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Tango.DAL.Remote\Tango.DAL.Remote.csproj">
+ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project>
+ <Name>Tango.DAL.Remote</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.Logging\Tango.Logging.csproj">
<Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project>
<Name>Tango.Logging</Name>
@@ -96,6 +124,8 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets'))" />
+ <Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.106.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.106.0\build\net46\System.Data.SQLite.Core.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" />
+ <Import Project="..\packages\System.Data.SQLite.Core.1.0.106.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.106.0\build\net46\System.Data.SQLite.Core.targets')" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Tango.UnitTesting/packages.config b/Software/Visual_Studio/Tango.UnitTesting/packages.config
index d3cd9d043..3ffe10b39 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/packages.config
+++ b/Software/Visual_Studio/Tango.UnitTesting/packages.config
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="EntityFramework" version="6.0.0" targetFramework="net46" />
<package id="Google.Protobuf" version="3.4.1" targetFramework="net45" />
<package id="MSTest.TestAdapter" version="1.1.11" targetFramework="net45" />
<package id="MSTest.TestFramework" version="1.1.11" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
+ <package id="System.Data.SQLite" version="1.0.106.0" targetFramework="net46" />
+ <package id="System.Data.SQLite.Core" version="1.0.106.0" targetFramework="net46" />
+ <package id="System.Data.SQLite.EF6" version="1.0.106.0" targetFramework="net46" />
+ <package id="System.Data.SQLite.Linq" version="1.0.106.0" targetFramework="net46" />
</packages> \ No newline at end of file