Skip to content

Commit

Permalink
Add .NET 9.0 compat + Drop .NET 6.0 and 7.0 support
Browse files Browse the repository at this point in the history
+ Fix build
  • Loading branch information
Elanis committed Dec 2, 2024
1 parent 1450da8 commit b44b760
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 142 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,5 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

Dysnomia.Common.SQL/Dysnomia.Common.SQL.xml
59 changes: 29 additions & 30 deletions Dysnomia.Common.SQL.Tests/DataTableHelperTest.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@

using Xunit;
using Xunit;

namespace Dysnomia.Common.SQL.Tests {
public class TestObject {
public string Foo { get; set; }
public int Bar { get; set; }
}
public class TestObject {
public string Foo { get; set; }
public int Bar { get; set; }
}

public class DataTableHelperTest {
[Fact]
public void CreateDataTableFromObject_null() {
var testObject = new TestObject() {
Foo = null,
Bar = 0
};
public class DataTableHelperTest {
[Fact]
public void CreateDataTableFromObject_null() {
var testObject = new TestObject() {
Foo = null,
Bar = 0
};

Assert.Equal(
1,
DataTableHelper.CreateDataTableFromObject(testObject).Rows.Count
);
}
Assert.Equal(
1,
DataTableHelper.CreateDataTableFromObject(testObject).Rows.Count
);
}

[Fact]
public void CreateDataTableFromObject_string() {
var testObject = new TestObject() {
Foo = "test",
Bar = 0
};
[Fact]
public void CreateDataTableFromObject_string() {
var testObject = new TestObject() {
Foo = "test",
Bar = 0
};

Assert.Equal(
1,
DataTableHelper.CreateDataTableFromObject(testObject).Rows.Count
);
}
}
Assert.Equal(
1,
DataTableHelper.CreateDataTableFromObject(testObject).Rows.Count
);
}
}
}
50 changes: 25 additions & 25 deletions Dysnomia.Common.SQL.Tests/DbNullHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
using Xunit;

namespace Dysnomia.Common.SQL.Tests {
public class DbNullHelperTest {
[Fact]
public void DbNullOrString_EmptyString() {
Assert.Equal(
"".DbNullOrString(),
DBNull.Value
);
}
public class DbNullHelperTest {
[Fact]
public void DbNullOrString_EmptyString() {
Assert.Equal(
"".DbNullOrString(),
DBNull.Value
);
}

[Fact]
public void DbNullOrString_Null() {
string str = null;
[Fact]
public void DbNullOrString_Null() {
string str = null;

Assert.Equal(
str.DbNullOrString(),
DBNull.Value
);
}
Assert.Equal(
str.DbNullOrString(),
DBNull.Value
);
}

[Fact]
public void DbNullOrString_String() {
var str = "data";
[Fact]
public void DbNullOrString_String() {
var str = "data";

Assert.Equal(
str.DbNullOrString(),
str
);
}
}
Assert.Equal(
str.DbNullOrString(),
str
);
}
}
}
157 changes: 77 additions & 80 deletions Dysnomia.Common.SQL.Tests/DbReaderMapperTest.cs
Original file line number Diff line number Diff line change
@@ -1,113 +1,110 @@
using System;
using NSubstitute;

using System;
using System.Collections.Generic;
using System.Data;

using Moq;
using Moq.DataReader;

using Xunit;

namespace Dysnomia.Common.SQL.Tests {
public class DbReaderMapperTestObject {
public string StrElement { get; set; }
public class DbReaderMapperTestObject {
public string StrElement { get; set; }

public uint UShortElement { get; set; }
public uint? NullableUShortElement { get; set; }
public int ShortElement { get; set; }
public int? NullableShortElement { get; set; }
public uint UShortElement { get; set; }
public uint? NullableUShortElement { get; set; }
public int ShortElement { get; set; }
public int? NullableShortElement { get; set; }

public uint UIntElement { get; set; }
public uint? NullableUIntElement { get; set; }
public int IntElement { get; set; }
public int? NullableIntElement { get; set; }
public uint UIntElement { get; set; }
public uint? NullableUIntElement { get; set; }
public int IntElement { get; set; }
public int? NullableIntElement { get; set; }

public long LongElement { get; set; }
public long? NullableLongElement { get; set; }
public ulong UlongElement { get; set; }
public ulong? NullableUlongElement { get; set; }
public long LongElement { get; set; }
public long? NullableLongElement { get; set; }
public ulong UlongElement { get; set; }
public ulong? NullableUlongElement { get; set; }

public decimal DecimalElement { get; set; }
public decimal? NullableDecimalElement { get; set; }
public decimal DecimalElement { get; set; }
public decimal? NullableDecimalElement { get; set; }

public double DoubleElement { get; set; }
public double? NullableDoubleElement { get; set; }
public double DoubleElement { get; set; }
public double? NullableDoubleElement { get; set; }

public bool BoolElement { get; set; }
public bool? NullableBoolElement { get; set; }
public bool BoolElement { get; set; }
public bool? NullableBoolElement { get; set; }

public DateTime DateTimeElement { get; set; }
public DateTime? NullableDateElement { get; set; }
public DateTime DateTimeElement { get; set; }
public DateTime? NullableDateElement { get; set; }

//public Guid GuidElement { get; set; }
//public Guid? NullableGuidElement { get; set; }
}
//public Guid GuidElement { get; set; }
//public Guid? NullableGuidElement { get; set; }
}

public class DbReaderMapperTest {
[Fact]
public void Tests() {
var data = new List<DbReaderMapperTestObject> {
new DbReaderMapperTestObject(),
new DbReaderMapperTestObject() {
StrElement = "",
public class DbReaderMapperTest {
[Fact]
public void Tests() {
var data = new List<DbReaderMapperTestObject> {
new DbReaderMapperTestObject(),
new DbReaderMapperTestObject() {
StrElement = "",

NullableUShortElement = 0,
NullableShortElement = 0,
NullableUShortElement = 0,
NullableShortElement = 0,

NullableUIntElement = 0,
NullableIntElement = 0,
NullableUIntElement = 0,
NullableIntElement = 0,

NullableLongElement = 0,
NullableUlongElement = 0,
NullableLongElement = 0,
NullableUlongElement = 0,

NullableDecimalElement = 0,
NullableDecimalElement = 0,

NullableDoubleElement = 0,
NullableDoubleElement = 0,

NullableBoolElement = false,
NullableBoolElement = false,

NullableDateElement = DateTime.Now,
}
};
NullableDateElement = DateTime.Now,
}
};

var mock = new Mock<IDataReader>();
mock.SetupDataReader(data);
IDataReader reader = mock.Object;
IDataReader reader = Substitute.For<IDataReader>();

while (reader.Read()) {
_ = new DbReaderMapperTestObject() {
StrElement = reader.GetString("StrElement"),
while (reader.Read()) {
_ = new DbReaderMapperTestObject() {
StrElement = reader.GetString("StrElement"),

UShortElement = reader.GetUShort("UShortElement"),
NullableUShortElement = reader.GetNullableUShort("NullableUShortElement"),
ShortElement = reader.GetShort("ShortElement"),
NullableShortElement = reader.GetNullableShort("NullableShortElement"),
UShortElement = reader.GetUShort("UShortElement"),
NullableUShortElement = reader.GetNullableUShort("NullableUShortElement"),
ShortElement = reader.GetShort("ShortElement"),
NullableShortElement = reader.GetNullableShort("NullableShortElement"),

UIntElement = reader.GetUInt("UIntElement"),
NullableUIntElement = reader.GetNullableUInt("NullableUIntElement"),
IntElement = reader.GetInt("IntElement"),
NullableIntElement = reader.GetNullableInt("NullableIntElement"),
UIntElement = reader.GetUInt("UIntElement"),
NullableUIntElement = reader.GetNullableUInt("NullableUIntElement"),
IntElement = reader.GetInt("IntElement"),
NullableIntElement = reader.GetNullableInt("NullableIntElement"),

LongElement = reader.GetLong("LongElement"),
NullableLongElement = reader.GetNullableLong("NullableLongElement"),
UlongElement = reader.GetULong("UlongElement"),
NullableUlongElement = reader.GetNullableULong("NullableUlongElement"),
LongElement = reader.GetLong("LongElement"),
NullableLongElement = reader.GetNullableLong("NullableLongElement"),
UlongElement = reader.GetULong("UlongElement"),
NullableUlongElement = reader.GetNullableULong("NullableUlongElement"),

DecimalElement = reader.GetDecimal("DecimalElement"),
NullableDecimalElement = reader.GetNullableDecimal("NullableDecimalElement"),
DecimalElement = reader.GetDecimal("DecimalElement"),
NullableDecimalElement = reader.GetNullableDecimal("NullableDecimalElement"),

DoubleElement = reader.GetDouble("DoubleElement"),
NullableDoubleElement = reader.GetNullableDouble("NullableDoubleElement"),
DoubleElement = reader.GetDouble("DoubleElement"),
NullableDoubleElement = reader.GetNullableDouble("NullableDoubleElement"),

BoolElement = reader.GetBoolean("BoolElement"),
NullableBoolElement = reader.GetNullableBoolean("NullableBoolElement"),
BoolElement = reader.GetBoolean("BoolElement"),
NullableBoolElement = reader.GetNullableBoolean("NullableBoolElement"),

DateTimeElement = reader.GetDateTime("DateTimeElement"),
NullableDateElement = reader.GetNullableDateTime("NullableDateElement"),
DateTimeElement = reader.GetDateTime("DateTimeElement"),
NullableDateElement = reader.GetNullableDateTime("NullableDateElement"),

//GuidElement = reader.GetGuid("GuidElement"),
//NullableGuidElement = reader.GetNullableGuid("NullableGuidElement"),
};
}
}
}
//GuidElement = reader.GetGuid("GuidElement"),
//NullableGuidElement = reader.GetNullableGuid("NullableGuidElement"),
};
}
}
}
}
10 changes: 5 additions & 5 deletions Dysnomia.Common.SQL.Tests/Dysnomia.Common.SQL.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

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

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq.DataReader" Version="0.2.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions Dysnomia.Common.SQL/Dysnomia.Common.SQL.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Authors>Axel "Elanis" Soupé</Authors>
<Company>Dysnomia</Company>
<Description>A driver agnostic Micro-ORM for .NET Core</Description>
Expand All @@ -12,7 +12,7 @@
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<DocumentationFile>Dysnomia.Common.SteamWebAPI.xml</DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationMarkdown>..\Doc.md</DocumentationMarkdown>
</PropertyGroup>

Expand Down

0 comments on commit b44b760

Please sign in to comment.