Skip to content

Commit

Permalink
Add tests and restructure some tests
Browse files Browse the repository at this point in the history
(#44)
  • Loading branch information
StefH committed Sep 28, 2016
1 parent 29cff17 commit 0588b82
Show file tree
Hide file tree
Showing 3 changed files with 441 additions and 371 deletions.
36 changes: 36 additions & 0 deletions test/System.Linq.Dynamic.Core.Tests/EntitiesTests.Cast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
using Xunit;

namespace System.Linq.Dynamic.Core.Tests
{
public partial class EntitiesTests
{
[Fact]
public void Cast_To_nullableint()
{
// Arrange
PopulateTestData(1, 0);

// Act
var expectedResult = _context.Blogs.Select(b => (int?)b.BlogId);
var result = _context.Blogs.AsQueryable().Select("int?(BlogId)");

// Assert
Assert.Equal(expectedResult.ToArray(), result.ToDynamicArray<int?>());
}

[Fact]
public void Cast_To_newnullableint()
{
// Arrange
PopulateTestData(1, 0);

// Act
var expectedResult = _context.Blogs.Select(x => new { i = (int?)x.BlogId });
var result = _context.Blogs.AsQueryable().Select("new (int?(BlogId) as i)");

//Assert
Assert.Equal(expectedResult.Count(), result.Count());
}
}
}
Loading

0 comments on commit 0588b82

Please sign in to comment.