Skip to content
Merged
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 @@ -393,6 +393,8 @@ public static void AssertAllTypes(JsonOwnedAllTypes expected, JsonOwnedAllTypes
Assert.Equal(expected.TestSignedByte, actual.TestSignedByte);
Assert.Equal(expected.TestSingle, actual.TestSingle);
Assert.Equal(expected.TestTimeSpan, actual.TestTimeSpan);
Assert.Equal(expected.TestDateOnly, actual.TestDateOnly);
Assert.Equal(expected.TestTimeOnly, actual.TestTimeOnly);
Assert.Equal(expected.TestUnsignedInt16, actual.TestUnsignedInt16);
Assert.Equal(expected.TestUnsignedInt32, actual.TestUnsignedInt32);
Assert.Equal(expected.TestUnsignedInt64, actual.TestUnsignedInt64);
Expand All @@ -417,6 +419,8 @@ public static void AssertAllTypes(JsonOwnedAllTypes expected, JsonOwnedAllTypes
AssertPrimitiveCollection(expected.TestSignedByteCollection, actual.TestSignedByteCollection);
AssertPrimitiveCollection(expected.TestSingleCollection, actual.TestSingleCollection);
AssertPrimitiveCollection(expected.TestTimeSpanCollection, actual.TestTimeSpanCollection);
AssertPrimitiveCollection(expected.TestDateOnlyCollection, actual.TestDateOnlyCollection);
AssertPrimitiveCollection(expected.TestTimeOnlyCollection, actual.TestTimeOnlyCollection);
AssertPrimitiveCollection(expected.TestUnsignedInt16Collection, actual.TestUnsignedInt16Collection);
AssertPrimitiveCollection(expected.TestUnsignedInt32Collection, actual.TestUnsignedInt32Collection);
AssertPrimitiveCollection(expected.TestUnsignedInt64Collection, actual.TestUnsignedInt64Collection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,8 @@ public virtual Task Json_all_types_projection_individual_properties(bool async)
x.Reference.TestSignedByte,
x.Reference.TestSingle,
x.Reference.TestTimeSpan,
x.Reference.TestDateOnly,
x.Reference.TestTimeOnly,
x.Reference.TestUnsignedInt16,
x.Reference.TestUnsignedInt32,
x.Reference.TestUnsignedInt64,
Expand Down Expand Up @@ -2365,6 +2367,22 @@ public virtual Task Json_predicate_on_timespan(bool async)
ss => ss.Set<JsonEntityAllTypes>().Where(x => x.Reference.TestTimeSpan != new TimeSpan(3, 2, 0)),
entryCount: 6);

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Json_predicate_on_dateonly(bool async)
=> AssertQuery(
async,
ss => ss.Set<JsonEntityAllTypes>().Where(x => x.Reference.TestDateOnly != new DateOnly(3, 2, 1)),
entryCount: 6);

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Json_predicate_on_timeonly(bool async)
=> AssertQuery(
async,
ss => ss.Set<JsonEntityAllTypes>().Where(x => x.Reference.TestTimeOnly != new TimeOnly(3, 2, 0)),
entryCount: 6);

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Json_predicate_on_unisgnedint16(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class JsonOwnedAllTypes
public DateTime TestDateTime { get; set; }
public DateTimeOffset TestDateTimeOffset { get; set; }
public TimeSpan TestTimeSpan { get; set; }
public DateOnly TestDateOnly { get; set; }
public TimeOnly TestTimeOnly { get; set; }
public float TestSingle { get; set; }
public bool TestBoolean { get; set; }
public byte TestByte { get; set; }
Expand Down Expand Up @@ -73,6 +75,8 @@ public IList<double> TestDoubleCollection
public List<DateTime> TestDateTimeCollection { get; set; }
public IList<DateTimeOffset> TestDateTimeOffsetCollection { get; set; }
public TimeSpan[] TestTimeSpanCollection { get; set; } = { new(1, 1, 1) };
public DateOnly[] TestDateOnlyCollection { get; set; }
public TimeOnly[] TestTimeOnlyCollection { get; set; }

public List<float> TestSingleCollection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
TestDateTime = DateTime.Parse("01/01/2000 12:34:56"),
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)),
TestTimeSpan = new TimeSpan(0, 10, 9, 8, 7),
TestDateOnly = new DateOnly(2023, 10, 10),
TestTimeOnly = new TimeOnly(11, 12, 13),
TestSingle = -1.234F,
TestBoolean = true,
TestByte = 255,
Expand Down Expand Up @@ -749,6 +751,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
-1.234F
},
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
TestDateOnlyCollection = new[] { new DateOnly(1234, 1, 23), new DateOnly(4321, 1, 21) },
TestTimeOnlyCollection = new[] { new TimeOnly(11, 42, 23), new TimeOnly(7, 17, 27) },
TestUnsignedInt16Collection = new List<ushort>
{
ushort.MinValue,
Expand Down Expand Up @@ -802,6 +806,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
TestDateTime = DateTime.Parse("01/01/3000 12:34:56"),
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("01/01/3000 12:34:56"), TimeSpan.FromHours(-8.0)),
TestTimeSpan = new TimeSpan(0, 5, 9, 8, 7),
TestDateOnly = new DateOnly(2123, 7, 8),
TestTimeOnly = new TimeOnly(9, 10, 11),
TestSingle = -1.24F,
TestBoolean = true,
TestByte = 25,
Expand Down Expand Up @@ -852,6 +858,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
-1.234F
},
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
TestDateOnlyCollection = new[] { new DateOnly(2234, 1, 23), new DateOnly(5321, 1, 21) },
TestTimeOnlyCollection = new[] { new TimeOnly(21, 42, 23), new TimeOnly(17, 17, 27) },
TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue },
TestUnsignedInt32Collection = new[] { uint.MinValue, (uint)0, uint.MaxValue },
TestUnsignedInt64Collection = new ObservableCollection<ulong>
Expand Down Expand Up @@ -900,6 +908,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
TestDateTime = DateTime.Parse("11/11/2100 12:34:56"),
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("11/11/2200 12:34:56"), TimeSpan.FromHours(-5.0)),
TestTimeSpan = new TimeSpan(0, 6, 5, 4, 3),
TestDateOnly = new DateOnly(2323, 4, 3),
TestTimeOnly = new TimeOnly(5, 7, 8),
TestSingle = -1.4F,
TestBoolean = false,
TestByte = 25,
Expand Down Expand Up @@ -950,6 +960,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
-1.234F
},
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
TestDateOnlyCollection = new[] { new DateOnly(3234, 1, 23), new DateOnly(4331, 1, 21) },
TestTimeOnlyCollection = new[] { new TimeOnly(13, 42, 23), new TimeOnly(7, 17, 25) },
TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue },
TestUnsignedInt32Collection = new[] { uint.MinValue, (uint)0, uint.MaxValue },
TestUnsignedInt64Collection = new ObservableCollection<ulong>
Expand Down Expand Up @@ -998,6 +1010,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
TestDateTime = DateTime.Parse("11/11/3100 12:34:56"),
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("11/11/3200 12:34:56"), TimeSpan.FromHours(-5.0)),
TestTimeSpan = new TimeSpan(0, 6, 5, 2, 3),
TestDateOnly = new DateOnly(4019, 2, 25),
TestTimeOnly = new TimeOnly(5, 30, 42),
TestSingle = -1.4F,
TestBoolean = false,
TestByte = 25,
Expand Down Expand Up @@ -1048,6 +1062,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
-1.234F
},
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
TestDateOnlyCollection = new[] { new DateOnly(1638, 1, 23), new DateOnly(4321, 1, 21) },
TestTimeOnlyCollection = new[] { new TimeOnly(8, 22, 23), new TimeOnly(7, 27, 37) },
TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue },
TestUnsignedInt32Collection = new[] { uint.MinValue, (uint)0, uint.MaxValue },
TestUnsignedInt64Collection = new ObservableCollection<ulong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,50 @@ public virtual Task Edit_single_property_timespan()
Assert.Equal(new TimeSpan(0, 10, 1, 1, 7), result.Collection[0].TestTimeSpan);
});

[ConditionalFact]
public virtual Task Edit_single_property_dateonly()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
CreateContext,
UseTransaction,
async context =>
{
var query = await context.JsonEntitiesAllTypes.ToListAsync();
var entity = query.Single(x => x.Id == 1);
entity.Reference.TestDateOnly = new DateOnly(1023, 1, 1);
entity.Collection[0].TestDateOnly = new DateOnly(2000, 2, 4);

ClearLog();
await context.SaveChangesAsync();
},
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(new DateOnly(1023, 1, 1), result.Reference.TestDateOnly);
Assert.Equal(new DateOnly(2000, 2, 4), result.Collection[0].TestDateOnly);
});

[ConditionalFact]
public virtual Task Edit_single_property_timeonly()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
CreateContext,
UseTransaction,
async context =>
{
var query = await context.JsonEntitiesAllTypes.ToListAsync();
var entity = query.Single(x => x.Id == 1);
entity.Reference.TestTimeOnly = new TimeOnly(1, 1, 7);
entity.Collection[0].TestTimeOnly = new TimeOnly(1, 1, 7);

ClearLog();
await context.SaveChangesAsync();
},
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(new TimeOnly(1, 1, 7), result.Reference.TestTimeOnly);
Assert.Equal(new TimeOnly(1, 1, 7), result.Collection[0].TestTimeOnly);
});

[ConditionalFact]
public virtual Task Edit_single_property_uint16()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
Expand Down Expand Up @@ -2016,6 +2060,60 @@ public virtual Task Edit_single_property_collection_of_timespan()
Assert.False(result.Collection[0].NewCollectionSet);
});

[ConditionalFact]
public virtual Task Edit_single_property_collection_of_dateonly()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
CreateContext,
UseTransaction,
async context =>
{
var query = await context.JsonEntitiesAllTypes.ToListAsync();
var entity = query.Single(x => x.Id == 1);
entity.Reference.TestDateOnlyCollection[0] = new DateOnly(1, 1, 7);
entity.Collection[0].TestDateOnlyCollection[1] = new DateOnly(1, 1, 7);

ClearLog();
await context.SaveChangesAsync();
},
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(
new[] { new DateOnly(1, 1, 7), new DateOnly(4321, 1, 21) }, result.Reference.TestDateOnlyCollection);
Assert.Equal(
new[] { new DateOnly(3234, 1, 23), new DateOnly(1, 1, 7) }, result.Collection[0].TestDateOnlyCollection);

Assert.False(result.Reference.NewCollectionSet);
Assert.False(result.Collection[0].NewCollectionSet);
});

[ConditionalFact]
public virtual Task Edit_single_property_collection_of_timeonly()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
CreateContext,
UseTransaction,
async context =>
{
var query = await context.JsonEntitiesAllTypes.ToListAsync();
var entity = query.Single(x => x.Id == 1);
entity.Reference.TestTimeOnlyCollection[0] = new TimeOnly(1, 1, 7);
entity.Collection[0].TestTimeOnlyCollection[1] = new TimeOnly(1, 1, 7);

ClearLog();
await context.SaveChangesAsync();
},
async context =>
{
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
Assert.Equal(
new[] { new TimeOnly(1, 1, 7), new TimeOnly(7, 17, 27) }, result.Reference.TestTimeOnlyCollection);
Assert.Equal(
new[] { new TimeOnly(13, 42, 23), new TimeOnly(1, 1, 7) }, result.Collection[0].TestTimeOnlyCollection);

Assert.False(result.Reference.NewCollectionSet);
Assert.False(result.Collection[0].NewCollectionSet);
});

[ConditionalFact]
public virtual Task Edit_single_property_collection_of_uint16()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
Expand Down
Loading