Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Fischer committed Feb 23, 2024
1 parent 74d380e commit e17fae5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using FakeItEasy;
using Microsoft.EntityFrameworkCore;
using MockQueryable.FakeItEasy;
using NUnit.Framework;

Expand Down Expand Up @@ -166,18 +167,17 @@ public async Task DbSetGetAllUserEntitiesAsync()
}

[TestCase]
public async Task DbSetGetAllUserEntitiesAsync_ShouldReturnAllEntities_WhenSourceIsChanged()
public async Task DbSetToListAsyncAsync_ShouldReturnAllEntities_WhenSourceIsChanged()
{
// arrange
var users = new List<UserEntity>();

var mockDbSet = users.AsQueryable().BuildMockDbSet();
var userRepository = new TestDbSetRepository(mockDbSet);


// act
var result1 = await userRepository.GetAllAsync().ToListAsync();
var result1 = await mockDbSet.ToListAsync();
users.AddRange(CreateUserList());
var result2 = await userRepository.GetAllAsync().ToListAsync();
var result2 = await mockDbSet.ToListAsync();

// assert
Assert.AreEqual(0, result1.Count);
Expand Down
7 changes: 3 additions & 4 deletions src/MockQueryable/MockQueryable.Sample/MyServiceMoqTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,17 @@ public async Task DbSetGetAllUserEntitiesAsync()


[TestCase]
public async Task DbSetGetAllUserEntitiesAsync_ShouldReturnAllEntities_WhenSourceIsChanged()
public async Task DbSetToListAsyncAsync_ShouldReturnAllEntities_WhenSourceIsChanged()
{
// arrange
var users = new List<UserEntity>();

var mockDbSet = users.AsQueryable().BuildMockDbSet();
var userRepository = new TestDbSetRepository(mockDbSet.Object);

// act
var result1 = await userRepository.GetAllAsync().ToListAsync();
var result1 = await mockDbSet.Object.ToListAsync();
users.AddRange(CreateUserList());
var result2 = await userRepository.GetAllAsync().ToListAsync();
var result2 = await mockDbSet.Object.ToListAsync();

// assert
Assert.AreEqual(0, result1.Count);
Expand Down

0 comments on commit e17fae5

Please sign in to comment.