Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Giorgi committed Oct 24, 2024
1 parent d3dfcc7 commit 9017d79
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
3 changes: 1 addition & 2 deletions DuckDB.NET.Test/DuckDBManagedAppenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ public void TemporalValues()
result.Select(tuple => tuple.Item4).Should().BeEquivalentTo(dates);
result.Select(tuple => tuple.Item5).Should().BeEquivalentTo(dates);
result.Select(tuple => tuple.Item6).Should().BeEquivalentTo(dates);
result.Select(tuple => tuple.Item7).Should().BeEquivalentTo(dates.Select(time => time.ToDateTimeOffset(TimeSpan.FromHours(1))),
options => options.ComparingByMembers<DateTimeOffset>().Including(offset => offset.Offset).Including(offset => offset.TimeOfDay));
result.Select(tuple => tuple.Item7).Should().BeEquivalentTo(dates.Select(time => time.ToDateTimeOffset(TimeSpan.FromHours(1))));
result.Select(tuple => tuple.Item8).Should().BeEquivalentTo(dates.Select(TimeOnly.FromDateTime));
}

Expand Down
8 changes: 5 additions & 3 deletions DuckDB.NET.Test/ModuleInit.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using DuckDB.NET.Test.Helpers;
using FluentAssertions;
using System;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#nullable enable
namespace DuckDB.NET.Test;
Expand All @@ -13,5 +11,9 @@ public static class ModuleInit
public static void Init()
{
NativeLibraryHelper.TryLoad();

AssertionOptions.AssertEquivalencyUsing(options => options.ComparingByMembers<DateTimeOffset>().Including(info =>
info.Name == nameof(DateTimeOffset.Offset) ||
info.Name == nameof(DateTimeOffset.TimeOfDay)));
}
}
26 changes: 19 additions & 7 deletions DuckDB.NET.Test/Parameters/ListParameterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DuckDB.NET.Data;
using DuckDB.NET.Native;
using FluentAssertions;
using FluentAssertions.Common;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -72,8 +73,7 @@ public void CanBindLongList()
[Fact]
public void CanBindHugeIntList()
{
TestInsertSelect("HugeInt",
faker => BigInteger.Subtract(DuckDBHugeInt.HugeIntMaxValue, faker.Random.Int(min: 0)));
TestInsertSelect("HugeInt", faker => BigInteger.Subtract(DuckDBHugeInt.HugeIntMaxValue, faker.Random.Int(min: 0)));
}

[Fact]
Expand Down Expand Up @@ -130,11 +130,23 @@ public void CanBindDateTimeList()
TestInsertSelect("Date", faker => faker.Date.Past().Date);
}

//[Fact]
//public void CanBindDateTimeOffsetList()
//{
// TestInsertSelect("TimeTZ", faker => faker.Date.PastOffset());
//}
[Fact]
public void CanBindDateTimeOffsetList()
{
TestInsertSelect("TimeTZ", faker =>
{
var dateTime = faker.Date.Between(DateTime.Now.AddYears(-100), DateTime.Now.AddYears(100));

if (dateTime.Hour < 1)
{
dateTime = dateTime.AddHours(1);
}

dateTime = dateTime.AddTicks(-dateTime.Ticks % 10);

return dateTime.ToDateTimeOffset(TimeSpan.FromHours(1));
});
}

[Fact]
public void CanBindStringList()
Expand Down

0 comments on commit 9017d79

Please sign in to comment.