public void ExistsReturnsCorrectly() { //Arrange string address = "test"; List <Email> emails = new List <Email> { new Email { Address = address }, new Email { Address = $"aa{address}" }, new Email { Address = $"{address}bb" } }; var dbSet = emails.AsQueryable().BuildMockDbSet(); context.Setup(c => c.Set <Email>()).Returns(dbSet.Object); IEmailRepository repository = new EmailRepository(context.Object); //Act var result = repository.Exists(address).Result; //Assert Assert.IsInstanceOfType(result, typeof(Email)); Assert.AreEqual(address, result.Address); }