From e17fae50f874f05f665b5185a6bdbacc45f9c4ca Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 23 Feb 2024 17:17:37 +0100 Subject: [PATCH] Fixed tests --- .../MockQueryable.Sample/MyServiceFakeItEasyTests.cs | 10 +++++----- .../MockQueryable.Sample/MyServiceMoqTests.cs | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/MockQueryable/MockQueryable.Sample/MyServiceFakeItEasyTests.cs b/src/MockQueryable/MockQueryable.Sample/MyServiceFakeItEasyTests.cs index db0620e..b3ed6a5 100644 --- a/src/MockQueryable/MockQueryable.Sample/MyServiceFakeItEasyTests.cs +++ b/src/MockQueryable/MockQueryable.Sample/MyServiceFakeItEasyTests.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using FakeItEasy; +using Microsoft.EntityFrameworkCore; using MockQueryable.FakeItEasy; using NUnit.Framework; @@ -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(); 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); diff --git a/src/MockQueryable/MockQueryable.Sample/MyServiceMoqTests.cs b/src/MockQueryable/MockQueryable.Sample/MyServiceMoqTests.cs index b0d128e..9ae85c2 100644 --- a/src/MockQueryable/MockQueryable.Sample/MyServiceMoqTests.cs +++ b/src/MockQueryable/MockQueryable.Sample/MyServiceMoqTests.cs @@ -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(); 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);