public async Task Exists_ShouldReturnFalse_WhenGroupWasDeleted() { // Arrange const int groupId = 1; IEnumerable <Group> databaseGroups = new[] { new Group { GroupId = 1, IsDeleted = true }, new Group { GroupId = 2 }, new Group { GroupId = 3 }, }; DbSet <Group> mockDbSet = databaseGroups .AsQueryable() .BuildMockDbSet() .Object; Mock <IChatContext> contextMock = new Mock <IChatContext>(); contextMock .Setup(m => m.Groups) .Returns(mockDbSet); GroupRepository repository = new GroupRepository(contextMock.Object); // Act bool exists = await repository.Exists(groupId); // Assert Assert.False(exists); }