Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test project which use the db. Supply sqldb.config to run #115

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,4 @@ $RECYCLE.BIN/

# Vim temporary swap files
*.swp
/BiggerTests/sqlDb.config
35 changes: 35 additions & 0 deletions BiggerTests/BiggerTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PCAxis.Sql\PCAxis.Sql.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="sqlDb.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="testhost.dll.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
42 changes: 42 additions & 0 deletions BiggerTests/ConfigTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Configuration;

using PCAxis.Sql.DbConfig;

namespace BiggerTests
{
[TestClass]
public class ConfigTest
{
[TestMethod]
public void TestMethod1()
{
//System.Configuration.ConfigurationFileMap configMap = new ConfigurationFileMap("./app.config");
//System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(configMap);
//var sdfdsz = configuration.AppSettings["dsa"];
//string value = configuration.AppSettings["TestKey"];
string path = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath;
var k = ConfigurationManager.AppSettings["TestKey"];
Assert.AreEqual("testvalue", k);
}

[TestMethod]
public void TestMethod2()
{

var k = ConfigurationManager.AppSettings["dbconfigFile"];
Assert.AreEqual("SqlDb.config", k);
}



[TestMethod]
public void TestGetsDefaultDatabase()
{
var dbConf = SqlDbConfigsStatic.DefaultDatabase;

var langCount = dbConf.GetAllLanguages().Count;
Assert.IsTrue(langCount > 1);
}

}
}
1 change: 1 addition & 0 deletions BiggerTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
7 changes: 7 additions & 0 deletions BiggerTests/testhost.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="TestKey" value="testvalue"/>
<add key="dbconfigFile" value="SqlDb.config"/>
</appSettings>
</configuration>
6 changes: 6 additions & 0 deletions PCAxis.Sql.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCAxis.Sql", "PCAxis.Sql\PC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCAxis.Sql.UnitTest", "PCAxis.Sql.UnitTest\PCAxis.Sql.UnitTest.csproj", "{5A2DF24D-3515-4C1F-BE56-ED8637A0A87E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BiggerTests", "BiggerTests\BiggerTests.csproj", "{28955788-C792-428C-9EC7-59D1A293E1E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{5A2DF24D-3515-4C1F-BE56-ED8637A0A87E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A2DF24D-3515-4C1F-BE56-ED8637A0A87E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A2DF24D-3515-4C1F-BE56-ED8637A0A87E}.Release|Any CPU.Build.0 = Release|Any CPU
{28955788-C792-428C-9EC7-59D1A293E1E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28955788-C792-428C-9EC7-59D1A293E1E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28955788-C792-428C-9EC7-59D1A293E1E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28955788-C792-428C-9EC7-59D1A293E1E9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading