Skip to content

Commit

Permalink
Add test verifying #15208
Browse files Browse the repository at this point in the history
DateTimeOffset and Contains()

Fixes #15208
  • Loading branch information
roji committed Jun 28, 2019
1 parent a2ce460 commit 2b405df
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5617,6 +5617,60 @@ public class Reference16233

#endregion

#region Bug15208

[ConditionalFact]
public virtual void Contains_DateTimeOffset()
{
using (CreateDatabase15208())
{
using (var context = new MyContext15208(_options))
{
var dto = new DateTimeOffset(2019, 1, 1, 1, 1, 1, TimeSpan.Zero);
var (start, end) = (dto.AddDays(-1), dto.AddDays(1));
var dates = new List<DateTimeOffset> { dto };
var blog = context.Blogs
.Single(b =>
start <= b.PublicationDate.Date &&
b.PublicationDate < end &&
dates.Contains(b.PublicationDate));
Assert.Equal(1, blog.Id);
}
}
}

private SqlServerTestStore CreateDatabase15208()
=> CreateTestStore(
() => new MyContext15208(_options),
context =>
{
ClearLog();
});

public class MyContext15208 : DbContext
{
public DbSet<Blog> Blogs { get; set; }

public MyContext15208(DbContextOptions options) : base(options) {}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>().HasData(new Blog
{
Id = 1,
PublicationDate = new DateTimeOffset(2019, 1, 1, 1, 1, 1, TimeSpan.Zero)
});
}
}

public class Blog
{
public int Id { get; set; }
public DateTimeOffset PublicationDate { get; set; }
}

#endregion Bug15208

private DbContextOptions _options;

private SqlServerTestStore CreateTestStore<TContext>(
Expand Down

0 comments on commit 2b405df

Please sign in to comment.