diff options
Diffstat (limited to 'Software/Visual_Studio_v2/Tango.UnitTests')
5 files changed, 186 insertions, 0 deletions
diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs b/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs new file mode 100644 index 000000000..8a2314858 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs @@ -0,0 +1,45 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Tango.DAL.Entities; +using Tango.DAL.Mongo; +using System.Linq; + +namespace Tango.UnitTests.DAL +{ + [TestClass] + public class Mongo + { + [TestMethod] + public void Simple_Operations() + { + MongoRepository<OrganizationEntity> repo = new MongoRepository<OrganizationEntity>(new MongoDataBaseSettings() + { + Address = "mongodb://localhost:27017", + DatabaseName = "TEST" + }); + + repo.DeleteAsync(x => true).GetAwaiter().GetResult(); + + OrganizationEntity org1 = new OrganizationEntity(); + org1.Name = "Org 1"; + + repo.Insert(org1).GetAwaiter().GetResult(); + + Assert.IsNotNull(org1.ID); + + var org2 = repo.GetAsync(x => x.ID == org1.ID).GetAwaiter().GetResult().FirstOrDefault(); + + Assert.IsNotNull(org2); + + Assert.AreEqual(org1.Name, org2.Name); + + long count = repo.DeleteAsync(x => x.ID == org1.ID).GetAwaiter().GetResult(); + + Assert.AreEqual(count, 1); + + count = repo.Count().GetAwaiter().GetResult(); + + Assert.AreEqual(count, 0); + } + } +} diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/Properties/AssemblyInfo.cs b/Software/Visual_Studio_v2/Tango.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..374da8010 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango.UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("932d6bf7-ed35-4ffa-a573-356c071ca727")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj b/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj new file mode 100644 index 000000000..bcdb3c11f --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" /> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{932D6BF7-ED35-4FFA-A573-356C071CA727}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tango.UnitTests</RootNamespace> + <AssemblyName>Tango.UnitTests</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> + <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> + <IsCodedUITest>False</IsCodedUITest> + <TestProjectType>UnitTest</TestProjectType> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="DnsClient, Version=1.2.0.0, Culture=neutral, PublicKeyToken=4574bb5573c51424, processorArchitecture=MSIL"> + <HintPath>..\packages\DnsClient.1.2.0\lib\net45\DnsClient.dll</HintPath> + </Reference> + <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> + </Reference> + <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> + </Reference> + <Reference Include="MongoDB.Bson, Version=2.8.1.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\MongoDB.Bson.2.8.1\lib\net452\MongoDB.Bson.dll</HintPath> + </Reference> + <Reference Include="MongoDB.Driver, Version=2.8.1.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\MongoDB.Driver.2.8.1\lib\net452\MongoDB.Driver.dll</HintPath> + </Reference> + <Reference Include="MongoDB.Driver.Core, Version=2.8.1.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\MongoDB.Driver.Core.2.8.1\lib\net452\MongoDB.Driver.Core.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath> + </Reference> + <Reference Include="System.Core" /> + <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath> + <Private>True</Private> + <Private>True</Private> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="DAL\Mongo.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tango.DAL.Mongo\Tango.DAL.Mongo.csproj"> + <Project>{9d1f1789-745c-4725-9dc4-12e0b0090a64}</Project> + <Name>Tango.DAL.Mongo</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DAL\Tango.DAL.csproj"> + <Project>{9701ad8c-5b58-4a1e-be59-ef4de36549d9}</Project> + <Name>Tango.DAL</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" /> + <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" /> + </Target> + <Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/app.config b/Software/Visual_Studio_v2/Tango.UnitTests/app.config new file mode 100644 index 000000000..d592063f0 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/app.config @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/packages.config b/Software/Visual_Studio_v2/Tango.UnitTests/packages.config new file mode 100644 index 000000000..9852f98c8 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/packages.config @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="DnsClient" version="1.2.0" targetFramework="net461" /> + <package id="MongoDB.Bson" version="2.8.1" targetFramework="net461" /> + <package id="MongoDB.Driver" version="2.8.1" targetFramework="net461" /> + <package id="MongoDB.Driver.Core" version="2.8.1" targetFramework="net461" /> + <package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net461" /> + <package id="MSTest.TestFramework" version="1.3.2" targetFramework="net461" /> + <package id="System.Buffers" version="4.4.0" targetFramework="net461" /> + <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" /> +</packages>
\ No newline at end of file |
