public static TypedEntity SetupTestData(Guid newGuid, Guid newGuidRedHerring, NhibernateTestSetupHelper repo)
        {
            var entity = HiveModelCreationHelper.MockTypedEntity();

            entity.Id = new HiveId(newGuid);
            entity.EntitySchema.Alias = "schema-alias1";

            var existingDef = entity.EntitySchema.AttributeDefinitions[0];
            var newDef      = HiveModelCreationHelper.CreateAttributeDefinition("aliasForQuerying", "", "", existingDef.AttributeType, existingDef.AttributeGroup, true);

            entity.EntitySchema.AttributeDefinitions.Add(newDef);
            entity.Attributes.Add(new TypedAttribute(newDef, "my-new-value"));

            entity.Attributes[1].DynamicValue = "not-on-red-herring";
            entity.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "my-test-route";

            var redHerringEntity = HiveModelCreationHelper.MockTypedEntity();

            redHerringEntity.Id = new HiveId(newGuidRedHerring);
            redHerringEntity.EntitySchema.Alias = "redherring-schema";

            using (var uow = repo.ProviderSetup.UnitFactory.Create())
            {
                uow.EntityRepository.AddOrUpdate(entity);
                uow.EntityRepository.AddOrUpdate(redHerringEntity);
                uow.Complete();
            }

            return(entity);
        }
Exemplo n.º 2
0
        public static TypedEntity SetupTestData(Guid newGuid, Guid newGuidRedHerring, ProviderSetup providerSetup)
        {
            var entity = HiveModelCreationHelper.MockTypedEntity();

            entity.Id = new HiveId(newGuid);
            entity.EntitySchema.Alias = "schema-alias1";

            var existingDef = entity.EntitySchema.AttributeDefinitions[0];
            var newDef      = HiveModelCreationHelper.CreateAttributeDefinition("aliasForQuerying", "", "", existingDef.AttributeType, existingDef.AttributeGroup, true);

            var boolType    = new AttributeType("boolean", "", "", new BoolSerializationType());
            var newDef_bool = HiveModelCreationHelper.CreateAttributeDefinition(BoolDefAlias, "", "", boolType, existingDef.AttributeGroup, true);

            entity.EntitySchema.AttributeDefinitions.Add(newDef);
            entity.EntitySchema.AttributeDefinitions.Add(newDef_bool);
            entity.Attributes.Add(new TypedAttribute(newDef, "my-new-value"));
            entity.Attributes.Add(new TypedAttribute(newDef_bool, true));

            entity.Attributes[1].DynamicValue = "not-on-red-herring";
            entity.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "my-test-route";

            var redHerringEntity = HiveModelCreationHelper.MockTypedEntity();

            redHerringEntity.Id = new HiveId(newGuidRedHerring);
            redHerringEntity.EntitySchema.Alias = "redherring-schema";
            var newDef_onRedHerring_bool = HiveModelCreationHelper.CreateAttributeDefinition(BoolDefAlias, "", "", boolType, existingDef.AttributeGroup, true);

            redHerringEntity.EntitySchema.AttributeDefinitions.Add(newDef_onRedHerring_bool);
            redHerringEntity.Attributes.Add(new TypedAttribute(newDef_onRedHerring_bool, "false"));

            using (var uow = providerSetup.UnitFactory.Create())
            {
                uow.EntityRepository.AddOrUpdate(entity);
                // Only add extra entity if caller wants it
                if (newGuidRedHerring != Guid.Empty)
                {
                    uow.EntityRepository.AddOrUpdate(redHerringEntity);
                }
                uow.Complete();
            }

            return(entity);
        }
Exemplo n.º 3
0
        public static Content SetupTestContentData(Guid newGuid, Guid newGuidRedHerring, ProviderSetup providerSetup)
        {
            var baseEntity = HiveModelCreationHelper.MockTypedEntity();
            var entity     = new Content(baseEntity);

            entity.Id = new HiveId(newGuid);
            entity.EntitySchema.Alias = "schema-alias1";

            var existingDef = entity.EntitySchema.AttributeDefinitions[0];
            var newDef      = HiveModelCreationHelper.CreateAttributeDefinition("aliasForQuerying", "", "", existingDef.AttributeType, existingDef.AttributeGroup, true);

            entity.EntitySchema.AttributeDefinitions.Add(newDef);
            entity.Attributes.Add(new TypedAttribute(newDef, "my-new-value"));

            entity.Attributes[1].DynamicValue = "not-on-red-herring";
            entity.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "my-test-route";

            var redHerringEntity = HiveModelCreationHelper.MockTypedEntity();

            redHerringEntity.Id = new HiveId(newGuidRedHerring);
            redHerringEntity.EntitySchema.Alias = "redherring-schema";

            using (var uow = providerSetup.UnitFactory.Create())
            {
                var publishedRevision = new Revision <TypedEntity>(entity)
                {
                    MetaData = { StatusType = FixedStatusTypes.Published }
                };

                uow.EntityRepository.Revisions.AddOrUpdate(publishedRevision);
                // Only add extra entity if caller wants it
                if (newGuidRedHerring != Guid.Empty)
                {
                    uow.EntityRepository.AddOrUpdate(redHerringEntity);
                }
                uow.Complete();
            }

            return(entity);
        }