Skip to content

Commit

Permalink
#29 Ported project files to VS2022, updated all the nuget packages
Browse files Browse the repository at this point in the history
  • Loading branch information
stewienj committed Sep 27, 2023
1 parent 511e745 commit 6170861
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<UseWpf>true</UseWpf>
<TargetFrameworks>netcoreapp3.1;net451;net46</TargetFrameworks>
<TargetFrameworks>net46</TargetFrameworks>
<Copyright>Creative Commons</Copyright>
<Company>Swordfish Computing Pty Ltd</Company>
<Product>Swordfish.NET.TestV3</Product>
Expand Down

This file was deleted.

56 changes: 35 additions & 21 deletions ExamplesAndTests/Swordfish.NET.UnitTestV3/SerializationTests.cs
Original file line number Diff line number Diff line change
@@ -1,69 +1,83 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Swordfish.NET.Collections;
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
#if NETCOREAPP
using System.Text.Json;
#endif

namespace Swordfish.NET.UnitTestV3
{
[TestClass]
public class SerializationTests
{
[TestMethod]
public void ConcurrentObservableCollectionSerializationTest()
#if NETCOREAPP
private T RoundTripSerialization<T>(T collection) where T : class
{
var bytes = JsonSerializer.SerializeToUtf8Bytes(collection,
new JsonSerializerOptions { WriteIndented = false });
return JsonSerializer.Deserialize<T>(new ReadOnlySpan<byte>(bytes));
}
#else
private T RoundTripSerialization<T>(T collection) where T : class
{
var serializer = new BinaryFormatter();
var stream = new MemoryStream();
serializer.Serialize(stream, collection);
stream.Position = 0;
return serializer.Deserialize(stream) as T;
}
#endif

[TestMethod]
public void ConcurrentObservableCollectionSerializationTest()
{
var collection = new ConcurrentObservableCollection<string>();
for (int i = 0; i < 10; i++)
collection.Add("TestItem" + (i + 1).ToString());
serializer.Serialize(stream, collection);
stream.Position = 0;
collection = serializer.Deserialize(stream) as ConcurrentObservableCollection<string>;

collection = RoundTripSerialization(collection);

for (int i = 0; i < 10; i++)
Assert.AreEqual("TestItem" + (i + 1).ToString(), collection[i]);
}

[TestMethod]
[TestMethod]
public void ConcurrentObservableDictionarySerializationTest()
{
var serializer = new BinaryFormatter();
var stream = new MemoryStream();
var collection = new ConcurrentObservableDictionary<string, int>();
for (int i = 0; i < 10; i++)
collection.Add("TestItem" + (i + 1).ToString(), i);
serializer.Serialize(stream, collection);
stream.Position = 0;
collection = serializer.Deserialize(stream) as ConcurrentObservableDictionary<string, int>;

collection = RoundTripSerialization(collection);

for (int i = 0; i < 10; i++)
Assert.AreEqual(i, collection["TestItem" + (i + 1).ToString()]);
}

[TestMethod]
public void ConcurrentObservableSortedDictionarySerializationTest()
{
var serializer = new BinaryFormatter();
var stream = new MemoryStream();
var collection = new ConcurrentObservableSortedDictionary<string, int>();
for (int i = 0; i < 10; i++)
collection.Add("TestItem" + (i + 1).ToString(), i);
serializer.Serialize(stream, collection);
stream.Position = 0;
collection = serializer.Deserialize(stream) as ConcurrentObservableSortedDictionary<string, int>;

collection = RoundTripSerialization(collection);

for (int i = 0; i < 10; i++)
Assert.AreEqual(i, collection["TestItem" + (i + 1).ToString()]);
}

[TestMethod]
public void ConcurrentObservableHashSetSerializationTest()
{
var serializer = new BinaryFormatter();
var stream = new MemoryStream();
var collection = new ConcurrentObservableHashSet<string>();
for (int i = 0; i < 10; i++)
collection.Add("TestItem" + (i + 1).ToString());
serializer.Serialize(stream, collection);
stream.Position = 0;
collection = serializer.Deserialize(stream) as ConcurrentObservableHashSet<string>;

collection = RoundTripSerialization(collection);

Assert.AreEqual(10, collection.Count);
for (int i = 0; i < 10; i++)
Assert.IsTrue(collection.Contains("TestItem" + (i + 1).ToString()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net451;net46;net5.0-windows</TargetFrameworks>
<TargetFrameworks>net46;net6.0</TargetFrameworks>
<Copyright>Creative Commons</Copyright>
<Company>Swordfish Computing Pty Ltd</Company>
<Product>Swordfish.NET.TestV3</Product>
<Title>Swordfish.NET.TestV3</Title>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Swordfish.NET.CollectionsV3\Swordfish.NET.CollectionsV3.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Swordfish.NET.Collections</RootNamespace>
<AssemblyName>Swordfish.NET.CollectionsV3</AssemblyName>
<TargetFrameworks>netstandard2.0;net451;net46</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
<Copyright>Creative Commons</Copyright>
<Company>Swordfish Computing Pty Ltd</Company>
<Product>Swordfish.NET.CollectionsV3</Product>
Expand Down

0 comments on commit 6170861

Please sign in to comment.