public async Task GetByIdAsyncWithSpecification_ShouldApplySpecification() { // Arrange TestEntity[] entities = _fixture.CreateMany <TestEntity>(2).ToArray(); var dbContextMock = new DbContextMock <TestDbContext>(_options); dbContextMock.CreateDbSetMock(x => x.TestEntities, (x, _) => (x.Id), entities); var repository = new ReadRepository <TestEntity, Guid>(() => dbContextMock.Object); var specification = new Mock <ISpecification <TestEntity> >(); // Act TestEntity result = await repository.GetSingleWithSpecificationAsync(specification.Object); // Assert result.Should().NotBeNull(); result.Should().BeOfType(typeof(TestEntity)); }