public void Can_Perform_Count_On_DataTypeDefinitionRepository() { using (IScope scope = ScopeProvider.CreateScope()) { // Act IQuery <IDataType> query = ScopeProvider.CreateQuery <IDataType>().Where(x => x.Name.StartsWith("D")); int count = DataTypeRepository.Count(query); // Assert Assert.That(count, Is.EqualTo(4)); } }
public void Can_Perform_GetByQuery_On_DataTypeDefinitionRepository() { using (IScope scope = ScopeProvider.CreateScope()) { // Act IQuery <IDataType> query = ScopeProvider.CreateQuery <IDataType>().Where(x => x.EditorAlias == Constants.PropertyEditors.Aliases.RadioButtonList); IDataType[] result = DataTypeRepository.Get(query).ToArray(); // Assert Assert.That(result, Is.Not.Null); Assert.That(result.Any(), Is.True); Assert.That(result.FirstOrDefault()?.Name, Is.EqualTo("Radiobox")); } }
public void Can_Perform_Count_On_RelationRepository() { // Arrange using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType); // Act IQuery <IRelation> query = ScopeProvider.CreateQuery <IRelation>().Where(x => x.ParentId == _textpage.Id); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(2)); } }
public void Can_Perform_GetByQuery_On_RelationRepository() { // Arrange using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType); // Act IQuery <IRelation> query = ScopeProvider.CreateQuery <IRelation>().Where(x => x.RelationTypeId == _relateContent.Id); IEnumerable <IRelation> relations = repository.Get(query); // Assert Assert.That(relations, Is.Not.Null); Assert.That(relations.Any(), Is.True); Assert.That(relations.Any(x => x == null), Is.False); Assert.That(relations.Count(), Is.EqualTo(2)); } }
public void Can_Perform_GetByQuery_On_UserRepository() { // Arrange ICoreScopeProvider provider = ScopeProvider; using (var scope = provider.CreateCoreScope()) { var repository = CreateRepository(provider); CreateAndCommitMultipleUsers(repository); // Act var query = ScopeProvider.CreateQuery <IUser>().Where(x => x.Username == "TestUser1"); var result = repository.Get(query); // Assert Assert.That(result.Count(), Is.GreaterThanOrEqualTo(1)); } }
public void Can_Perform_Count_On_UserRepository() { // Arrange ICoreScopeProvider provider = ScopeProvider; using (ICoreScope scope = provider.CreateCoreScope()) { UserRepository repository = CreateRepository(provider); IUser[] users = CreateAndCommitMultipleUsers(repository); // Act IQuery <IUser> query = ScopeProvider.CreateQuery <IUser>().Where(x => x.Username == "TestUser1" || x.Username == "TestUser2"); int result = repository.Count(query); // Assert Assert.AreEqual(2, result); } }
protected IQuery <T> Query <T>() => ScopeProvider.CreateQuery <T>();