Beispiel #1
0
        public void TypedEntity_ComplexBinary_IncludingSchemaAlias()
        {
            SetupContentTest();

            var schema = Hive.Cms().NewContentType("mycontent")
                         .Define("text", "singleLineTextBox", "tab1")
                         .Commit().Item;

            var schema2 = Hive.Cms().NewContentType("someOtherContent")
                          .Define("text", "singleLineTextBox", "tab1")
                          .Commit().Item;

            var revision1 = Hive.Cms().NewRevision("shouldreturn", "-", "mycontent")
                            .SetValue("text", "some text")
                            .Publish()
                            .Commit().Item;

            var revision2 = Hive.Cms().NewRevision("shouldnotreturn", "-", "mycontent")
                            .SetValue("text", "some text to be excluded")
                            .Publish()
                            .Commit().Item;

            var revision3 = Hive.Cms().NewRevision("shouldnotreturneither", "-", "someOtherContent")
                            .SetValue("text", "some text to be excluded")
                            .Publish()
                            .Commit().Item;

            Assert.That(schema, Is.Not.Null);
            Assert.That(schema2, Is.Not.Null);
            Assert.That(revision1, Is.Not.Null);
            Assert.That(revision2, Is.Not.Null);
            Assert.That(revision3, Is.Not.Null);

            Assert.That(schema.Id, Is.Not.EqualTo(HiveId.Empty));
            Assert.That(schema2.Id, Is.Not.EqualTo(HiveId.Empty));
            Assert.That(revision1.Id, Is.Not.EqualTo(HiveId.Empty));
            Assert.That(revision2.Id, Is.Not.EqualTo(HiveId.Empty));
            Assert.That(revision3.Id, Is.Not.EqualTo(HiveId.Empty));

            Hive.Context.GenerationScopedCache.Clear();

            // Schema is mycontent, text starts with "some text", but id not equal to revision2
            // Should only return revision1

            var results = Hive.Query <TypedEntity, IContentStore>()
                          .Where(
                x =>
                x.EntitySchema.Alias == "mycontent" &&
                (x.Attribute <string>("text").StartsWith("some text") && x.Id != revision2.Id)).ToList();

            Assert.That(results.Count, Is.EqualTo(1));

            Hive.Context.GenerationScopedCache.Clear();

            // Schema is someOtherContent or the above binary combo
            results = Hive.Query <TypedEntity, IContentStore>()
                      .Where(
                x => x.EntitySchema.Alias == "someOtherContent" || (
                    x.EntitySchema.Alias == "mycontent" &&
                    (x.Attribute <string>("text").StartsWith("some text") && x.Id != revision2.Id))).ToList();

            Assert.That(results.Count, Is.EqualTo(2));
        }