Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Jul 10, 2018
1 parent 5a58c4a commit 7c9bb45
Show file tree
Hide file tree
Showing 22 changed files with 264 additions and 347 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="1.9.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="1.9.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 6 additions & 14 deletions src/EntityFramework.Testing.FakeItEasy.Tests/ManipulationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
#if !NET40
using System.Threading.Tasks;
#endif
using global::FakeItEasy;
using Xunit;

Expand All @@ -25,7 +23,7 @@ public void Can_remove_set()

var result = set.ToList();

Assert.Equal(0, result.Count);
Assert.Empty(result);
}

[Fact]
Expand Down Expand Up @@ -57,7 +55,7 @@ public void Can_removeRange_sets()

var result = set.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand Down Expand Up @@ -89,7 +87,7 @@ public void Can_attach_set()

var result = set.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand All @@ -105,7 +103,7 @@ public void Can_add_set()

var result = set.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand Down Expand Up @@ -162,10 +160,9 @@ public void Can_toList_twice()

var result2 = set.ToList();

Assert.Equal(1, result2.Count);
Assert.Single(result2);
}

#if !NET40
[Fact]
public async Task Can_find_set_async()
{
Expand All @@ -185,7 +182,6 @@ public async Task Can_find_set_async()
Assert.NotNull(result);
Assert.Equal(1, result.BlogId);
}
#endif

[Fact]
public void Can_specify_asNoTracking()
Expand All @@ -197,7 +193,7 @@ public void Can_specify_asNoTracking()
.AsNoTracking()
.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand All @@ -211,11 +207,7 @@ public void Can_create_entity()

private DbSet<Blog> GetFakeDbSet()
{
#if NET40
return A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)));
#else
return A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)).Implements(typeof(IDbAsyncEnumerable<Blog>)));
#endif
}

public class Blog
Expand Down
19 changes: 7 additions & 12 deletions src/EntityFramework.Testing.FakeItEasy.Tests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void Can_enumerate_set()
{
var data = new List<Blog> { new Blog { }, new Blog { } };

var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)))
var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)).Implements(typeof(IDbAsyncEnumerable<Blog>)))
.SetupData(data);

var count = 0;
Expand All @@ -26,7 +26,7 @@ public void Can_enumerate_set()

Assert.Equal(2, count);
}
#if !NET40

[Fact]
public async Task Can_enumerate_set_async()
{
Expand All @@ -40,21 +40,20 @@ public async Task Can_enumerate_set_async()

Assert.Equal(2, count);
}
#endif

[Fact]
public void Can_use_linq_materializer_directly_on_set()
{
var data = new List<Blog> { new Blog(), new Blog() };

var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)))
var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)).Implements(typeof(IDbAsyncEnumerable<Blog>)))
.SetupData(data);

var result = set.ToList();

Assert.Equal(2, result.Count);
}

#if !NET40
[Fact]
public async Task Can_use_linq_materializer_directly_on_set_async()
{
Expand All @@ -67,7 +66,6 @@ public async Task Can_use_linq_materializer_directly_on_set_async()

Assert.Equal(2, result.Count);
}
#endif

[Fact]
public void Can_use_linq_opeartors()
Expand All @@ -79,7 +77,7 @@ public void Can_use_linq_opeartors()
new Blog { BlogId = 3}
};

var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)))
var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)).Implements(typeof(IDbAsyncEnumerable<Blog>)))
.SetupData(data);

var result = set
Expand All @@ -92,7 +90,6 @@ public void Can_use_linq_opeartors()
Assert.Equal(2, result[1].BlogId);
}

#if !NET40
[Fact]
public async Task Can_use_linq_opeartors_async()
{
Expand All @@ -116,14 +113,12 @@ public async Task Can_use_linq_opeartors_async()
Assert.Equal(2, result[1].BlogId);
}

#endif

[Fact]
public void Can_use_include_directly_on_set()
{
var data = new List<Blog> { new Blog(), new Blog() };

var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)))
var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)).Implements(typeof(IDbAsyncEnumerable<Blog>)))
.SetupData(data);

var result = set
Expand All @@ -138,7 +133,7 @@ public void Can_use_include_after_linq_operator()
{
var data = new List<Blog> { new Blog(), new Blog() };

var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)))
var set = A.Fake<DbSet<Blog>>(o => o.Implements(typeof(IQueryable<Blog>)).Implements(typeof(IDbAsyncEnumerable<Blog>)))
.SetupData(data);

var result = set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ namespace FakeItEasy
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
#if !NET40
using System.Threading;
using System.Threading.Tasks;
#endif
using EntityFramework.Testing;

/// <summary>
Expand Down Expand Up @@ -43,17 +41,14 @@ public static DbSet<TEntity> SetupData<TEntity>(this DbSet<TEntity> dbSet, IColl
A.CallTo(() => ((IQueryable<TEntity>)dbSet).ElementType).ReturnsLazily(info => query.ElementType);
A.CallTo(() => ((IQueryable<TEntity>)dbSet).GetEnumerator()).ReturnsLazily(info => query.GetEnumerator());

#if !NET40
A.CallTo(() => ((IDbAsyncEnumerable<TEntity>)dbSet).GetAsyncEnumerator()).ReturnsLazily(info => query.GetAsyncEnumerator());
#endif

A.CallTo(() => dbSet.AsNoTracking()).Returns(dbSet);
A.CallTo(() => dbSet.Include(A<string>._)).Returns(dbSet);
A.CallTo(() => dbSet.Find(A<object[]>._)).ReturnsLazily<TEntity, object[]>(objs => find(objs));

#if !NET40
A.CallTo(() => dbSet.FindAsync(A<object[]>._)).ReturnsLazily<Task<TEntity>, object[]>(objs => Task.Run(() => find(objs)));
A.CallTo(() => dbSet.FindAsync(A<CancellationToken>._, A<object[]>._)).ReturnsLazily<Task<TEntity>, CancellationToken, object[]>((token, objs) => Task.Run(() => find(objs), token));
#endif

A.CallTo(() => dbSet.Create()).ReturnsLazily(() => Activator.CreateInstance<TEntity>());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ninject.MockingKernel.Moq" Version="3.3.0" />
<PackageReference Include="xunit" Version="1.9.2" />
<PackageReference Include="xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ninject.MockingKernel.Moq" Version="3.3.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="1.9.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 6 additions & 10 deletions src/EntityFramework.Testing.Moq.Tests/ManipulationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
#if !NET40
using System.Threading.Tasks;
#endif
using global::Moq;
using Xunit;

Expand All @@ -24,7 +22,7 @@ public void Can_remove_set()

var result = set.Object.ToList();

Assert.Equal(0, result.Count);
Assert.Empty(result);
}

[Fact]
Expand Down Expand Up @@ -57,7 +55,7 @@ public void Can_removeRange_sets()

var result = set.Object.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand Down Expand Up @@ -90,7 +88,7 @@ public void Can_add_set()

var result = set.Object.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand All @@ -106,7 +104,7 @@ public void Can_attach_set()

var result = set.Object.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand Down Expand Up @@ -165,10 +163,9 @@ public void Can_toList_twice()

var result2 = set.Object.ToList();

Assert.Equal(1, result2.Count);
Assert.Single(result2);
}

#if !NET40
[Fact]
public async Task Can_find_set_async()
{
Expand All @@ -188,7 +185,6 @@ public async Task Can_find_set_async()
Assert.NotNull(result);
Assert.Equal(1, result.BlogId);
}
#endif

[Fact]
public void Can_specify_asNoTracking()
Expand All @@ -200,7 +196,7 @@ public void Can_specify_asNoTracking()
.AsNoTracking()
.ToList();

Assert.Equal(1, result.Count);
Assert.Single(result);
}

[Fact]
Expand Down
Loading

0 comments on commit 7c9bb45

Please sign in to comment.