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

Make tests run on .net framework and .net #887

Closed
wants to merge 4 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
18 changes: 7 additions & 11 deletions src/Caliburn.Micro.Core.Tests/ScreenExtentionTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Caliburn.Micro.Core;
using Xunit;

namespace Caliburn.Micro.Core.Tests
Expand Down Expand Up @@ -35,13 +31,13 @@ public async Task Screen_ConductWithTests()
child2.ConductWith(root);
child3.ConductWith(root);

await ScreenExtensions.TryActivateAsync(root).ConfigureAwait(false);
await ScreenExtensions.TryActivateAsync(root);

Assert.True(child1.WasActivated, "child 1 should be active");
Assert.True(child2.WasActivated, "child 2 should be active");
Assert.True(child3.WasActivated, "child 3 should be active");

await ScreenExtensions.TryDeactivateAsync(root, true).ConfigureAwait(false);
await ScreenExtensions.TryDeactivateAsync(root, true);

Assert.True(child1.IsClosed, "child 1 should be closed");
Assert.True(child2.IsClosed, "child 2 should be closed");
Expand Down Expand Up @@ -72,13 +68,13 @@ public async Task Conductor_ConductWithTests()
root.Items.Add(child2);
root.Items.Add(child3);

await ScreenExtensions.TryActivateAsync(root).ConfigureAwait(false);
await ScreenExtensions.TryActivateAsync(root);

Assert.True(child1.WasActivated, "child 1 should be active");
Assert.True(child2.WasActivated, "child 2 should be active");
Assert.True(child3.WasActivated, "child 3 should be active");

await ScreenExtensions.TryDeactivateAsync(root, true).ConfigureAwait(false);
await ScreenExtensions.TryDeactivateAsync(root, true);

Assert.True(child1.IsClosed, "child 1 should be closed");
Assert.True(child2.IsClosed, "child 2 should be closed");
Expand Down Expand Up @@ -109,7 +105,7 @@ protected override async Task OnActivateAsync(CancellationToken cancellationToke
{
if (deactivationDelay.HasValue)
{
await Task.Delay(deactivationDelay.Value, cancellationToken).ConfigureAwait(false);
await Task.Delay(deactivationDelay.Value, cancellationToken);
}

await base.OnActivateAsync(cancellationToken);
Expand All @@ -120,11 +116,11 @@ protected override async Task OnActivateAsync(CancellationToken cancellationToke

protected override async Task OnDeactivateAsync(bool close, CancellationToken cancellationToken = default(CancellationToken))
{
await base.OnDeactivateAsync(close, cancellationToken).ConfigureAwait(false);
await base.OnDeactivateAsync(close, cancellationToken);

if (deactivationDelay.HasValue)
{
await Task.Delay(deactivationDelay.Value, cancellationToken).ConfigureAwait(false);
await Task.Delay(deactivationDelay.Value, cancellationToken);
}

IsClosed = close;
Expand Down
35 changes: 35 additions & 0 deletions src/Caliburn.Micro.Net.Tests/Caliburn.Micro.Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.37" />
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Caliburn.Micro.Core\Caliburn.Micro.Core.csproj" />
<ProjectReference Include="..\Caliburn.Micro.Platform.Core\Caliburn.Micro.Platform.Core.csproj" />
<ProjectReference Include="..\Caliburn.Micro.Platform\Caliburn.Micro.Platform.csproj" />
</ItemGroup>

<Import Project="..\Caliburn.Micro.Platform.Tests.Shared\Caliburn.Micro.Platform.Tests.Shared.projitems" Label="Shared" />

</Project>
24 changes: 9 additions & 15 deletions src/Caliburn.Micro.Platform.Core/StringSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,15 @@ public static string[] Split(string message, char separator)
{
squareBrackets--;
}
else if (current == separator)
else if (current == separator && squareBrackets == 0)
{
if (squareBrackets == 0)
if (builder.Length > 0)
{
str = builder.ToString();
if (!string.IsNullOrEmpty(str))
{
list.Add(builder.ToString().Trim());
}

builder.Length = 0;
continue;
list.Add(builder.ToString().Trim());
}

builder.Length = 0;
continue;
}

builder.Append(current);
Expand Down Expand Up @@ -89,14 +85,12 @@ public static string[] SplitParameters(string parameters)
{
var current = parameters[i];

if (current == '"' || current == '\'')
if ((current == '"' || current == '\'') && (i == 0 || parameters[i - 1] != '\\'))
{
if (i == 0 || parameters[i - 1] != '\\')
{
isInString = !isInString;
}
isInString = !isInString;
}


if (!isInString)
{
switch (current)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void A_given_UserControl_is_ScopeRoute()
Assert.Same(userControl, route.Root);
}

[WpfFact]
[Fact]
public void Any_DependencyObject_is_ScopeRoot_if_IsScopeRoot_is_true()
{
var dependencyObject = new DependencyObject();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>b8615b2f-22ea-44a3-a424-e47963673837</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Caliburn.Micro.Platform.Tests.Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AssemblyCacheTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BindingScopeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MessageBinderTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ParserTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ScopeNamingRouteTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)StringSplitterTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewLocatorTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModelLocatorTests.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>b8615b2f-22ea-44a3-a424-e47963673837</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Caliburn.Micro.Platform.Tests.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<TargetFramework>net48</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.37" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="Xunit.StaFact" Version="0.2.17" />
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
</ItemGroup>

<ItemGroup>
Expand All @@ -33,4 +33,6 @@
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" />
</ItemGroup>

<Import Project="..\Caliburn.Micro.Platform.Tests.Shared\Caliburn.Micro.Platform.Tests.Shared.projitems" Label="Shared" />

</Project>
Loading
Loading