Spring.Data: fix test to work in NET5 (#207)

Co-authored-by: Roberto Paterlini <r.paterlini@almaviva.it>
This commit is contained in:
Roberto Paterlini
2021-07-30 18:44:59 +02:00
committed by GitHub
parent 974247bd0f
commit 9d7325bd67
11 changed files with 100 additions and 5 deletions

View File

@@ -74,5 +74,6 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(ProjectDir)Data&quot; &quot;$(OutDir)&quot; /y /s /q /d" />
<Exec Command="copy &quot;$(ProjectDir)App.config&quot; &quot;$(OutDir)testhost.dll.config&quot;" />
<Exec Command="copy &quot;$(ProjectDir)App.config&quot; &quot;$(OutDir)ReSharperTestRunner64.dll.config&quot;" />
</Target>
</Project>

View File

@@ -141,6 +141,12 @@ namespace Spring.Data
}
}
#endregion
protected override void OnSetUp()
{
TestObjectDao.Cleanup();
base.OnSetUp();
}
#endregion
}
}

View File

@@ -50,6 +50,9 @@ namespace Spring.Data
}
[Test]
#if NETCOREAPP
[Ignore("Not supported on .NET Core")]
#endif
public void DeclarativeWithAttributes()
{
IAccountManager mgr = ctx["accountManager"] as IAccountManager;

View File

@@ -44,6 +44,9 @@ namespace Spring.Data
}
[Test]
#if NETCOREAPP
[Ignore("Not supported on .NET Core")]
#endif
public void DeclarativeWithAttributes()
{
SimpleAccountManager mgr = ctx["accountManager"] as SimpleAccountManager;

View File

@@ -19,5 +19,6 @@ namespace Spring.Data
//
int GetCountByAltMethod(int lowerAgeLimit);
int GetCountByCommandSetter(int lowerAgeLimit);
void Cleanup();
}
}

View File

@@ -201,5 +201,10 @@ namespace Spring.Data
{
throw new NotImplementedException();
}
public void Cleanup()
{
throw new NotImplementedException();
}
}
}

View File

@@ -145,5 +145,10 @@ namespace Spring.Data
#endregion
}
}
public void Cleanup()
{
AdoTemplate.ExecuteNonQuery(CommandType.Text, "delete from TestObjects ");
}
}
}

View File

@@ -4,9 +4,16 @@
xmlns:tx="http://www.springframework.net/tx"
xmlns:aop="http://www.springframework.net/aop">
<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
<property name="VariableSources">
<list>
<object type="Spring.ProviderNameSource, Spring.Data.Integration.Tests" />
</list>
</property>
</object>
<db:provider id="DbProvider"
provider="SqlServer-2.0"
provider="${providerName}"
connectionString="Data Source=SPRINGQA;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa"/>

View File

@@ -3,9 +3,16 @@
xmlns:db="http://www.springframework.net/database">
<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
<property name="VariableSources">
<list>
<object type="Spring.ProviderNameSource, Spring.Data.Integration.Tests" />
</list>
</property>
</object>
<db:provider id="DbProvider"
provider="SqlServer-2.0"
provider="${providerName}"
connectionString="Data Source=SPRINGQA;Database=Spring;Trusted_Connection=False;User ID=springqa;Password=springqa"/>
<object id="adoTemplate" type="Spring.Data.Core.AdoTemplate, Spring.Data">

View File

@@ -2,8 +2,16 @@
<objects xmlns='http://www.springframework.net'
xmlns:db="http://www.springframework.net/database">
<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
<property name="VariableSources">
<list>
<object type="Spring.ProviderNameSource, Spring.Data.Integration.Tests" />
</list>
</property>
</object>
<db:provider id="DbProvider"
provider="SqlServer-2.0"
provider="${providerName}"
connectionString="Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/>
<object id="adoTemplate" type="Spring.Data.Core.AdoTemplate, Spring.Data">

View File

@@ -0,0 +1,49 @@
#region License
// /*
// * Copyright 2018 the original author or authors.
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
#endregion
#region using
using Spring.Objects.Factory.Config;
#endregion
namespace Spring
{
public class ProviderNameSource : IVariableSource
{
public bool CanResolveVariable(string name)
{
return name.ToLower() == "providername";
}
public string ResolveVariable(string name)
{
if (name.ToLower() != "providername")
{
return null;
}
#if NETCOREAPP
return "SqlServer";
#else
return "SqlServer-2.0";
#endif
}
}
}