public void AnyPredicateTrueTest() { Mock <UserEntity> otherEntity = new Mock <UserEntity>(); otherEntity.SetupGet(e => e.Id).Returns(4); testRepo.Add(testEntity.Object); testRepo.Add(otherEntity.Object); bool any = testRepo.Any(u => u.Id == 4); Assert.IsTrue(any); }
public bool IsNameTaken(string name) { name = name.ToLower().Trim().MultipleSpaceRemove(); if (entityRepository.Any(entity => entity.Name.ToLower().Trim() == name)) { return(true); } return(reservedEntityNameRepository.Any(r => r.Name.ToLower().Trim() == name)); }
public async Task Get_Blogs_Any() { // Arrange // Act var hasAny = await _blogsRepository.Any(x => x.Posts.Count(y => y.Tags.Count == 2) > 4); // Assert Assert.True(hasAny); }
public override void Validate(SendMessageViewModel model, ValidatorAction action = ValidatorAction.Undefined) { if (model.RecipientID.HasValue) { bool exists = entityRepository.Any(e => e.EntityID == model.RecipientID); if (!exists) { AddError("Recipient does not exists", () => model.RecipientName); } } else { bool exists = entityRepository.Any(e => e.Name.ToLower() == model.RecipientName.ToLower()); if (!exists) { AddError("Recipient does not exists", () => model.RecipientName); } } }
private static bool countryExists(CreateCountryParameters param) { return(entityRepository.Any(e => e.Name == param.CountryName)); }