Example #1
0
        protected override void PersistNewItem(IMacro entity)
        {
            ((Macro)entity).AddingEntity();

            var name = string.Concat(entity.Alias, ".macro");
            var json = _serializationService.ToStream(entity);

            _fileSystem.AddFile(name, json.ResultStream, true);

            ((ICanBeDirty)entity).ResetDirtyProperties();
        }
Example #2
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new DocumentEntitySlim()
            {
                Id = 3,
                ContentTypeAlias = "test1",
                CreatorId        = 4,
                Key                  = Guid.NewGuid(),
                UpdateDate           = DateTime.Now,
                CreateDate           = DateTime.Now,
                Name                 = "Test",
                ParentId             = 5,
                SortOrder            = 6,
                Path                 = "-1,23",
                Level                = 7,
                ContentTypeIcon      = "icon",
                ContentTypeThumbnail = "thumb",
                HasChildren          = true,
                Edited               = true,
                Published            = true,
                NodeObjectType       = Guid.NewGuid()
            };

            item.AdditionalData.Add("test1", 3);
            item.AdditionalData.Add("test2", "valuie");

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json); // FIXME: compare with v7
        }
Example #3
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new DictionaryTranslation(new Language("en-AU")
            {
                CreateDate  = DateTime.Now,
                CultureName = "en",
                Id          = 11,
                IsoCode     = "AU",
                Key         = Guid.NewGuid(),
                UpdateDate  = DateTime.Now
            }, "colour")
            {
                CreateDate = DateTime.Now,
                Id         = 88,
                Key        = Guid.NewGuid(),
                UpdateDate = DateTime.Now
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var dtd = new DataType(new VoidEditor(Mock.Of <ILogger>()), 9)
            {
                CreateDate   = DateTime.Now,
                CreatorId    = 5,
                DatabaseType = ValueStorageType.Nvarchar,
                Id           = 4,
                Key          = Guid.NewGuid(),
                Level        = 7,
                Name         = "Test",
                ParentId     = 9,
                Path         = "-1,2",
                SortOrder    = 8,
                Trashed      = true,
                UpdateDate   = DateTime.Now
            };

            var result = ss.ToStream(dtd);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #5
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            // Arrange
            var contentType = MockedContentTypes.CreateTextPageContentType();

            contentType.Id = 99;
            var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
            var i       = 200;

            foreach (var property in content.Properties)
            {
                property.Id = ++i;
            }
            content.Id         = 10;
            content.CreateDate = DateTime.Now;
            content.CreatorId  = 22;
            content.Key        = Guid.NewGuid();
            content.Level      = 3;
            content.Path       = "-1,4,10";
            content.ContentSchedule.Add(DateTime.Now, DateTime.Now.AddDays(1));
            //content.ChangePublishedState(PublishedState.Publishing);
            content.SortOrder  = 5;
            content.TemplateId = 88;
            content.Trashed    = false;
            content.UpdateDate = DateTime.Now;
            content.WriterId   = 23;

            var result = ss.ToStream(content);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #6
0
        public void Can_Serialize_Media_Type_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            // Arrange
            var contentType = MockedContentTypes.CreateImageMediaType();

            contentType.Id = 99;

            var i = 200;

            foreach (var propertyType in contentType.PropertyTypes)
            {
                propertyType.Id = ++i;
            }
            contentType.Id          = 10;
            contentType.CreateDate  = DateTime.Now;
            contentType.CreatorId   = 22;
            contentType.Description = "test";
            contentType.Icon        = "icon";
            contentType.IsContainer = true;
            contentType.Thumbnail   = "thumb";
            contentType.Key         = Guid.NewGuid();
            contentType.Level       = 3;
            contentType.Path        = "-1,4,10";
            contentType.SortOrder   = 5;
            contentType.Trashed     = false;
            contentType.UpdateDate  = DateTime.Now;

            var result = ss.ToStream(contentType);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #7
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new Task(new TaskType("test")
            {
                Id = 3
            })
            {
                AssigneeUserId = 4,
                Closed         = true,
                Comment        = "blah",
                CreateDate     = DateTime.Now,
                EntityId       = 99,
                Id             = 2,
                Key            = Guid.NewGuid(),
                OwnerUserId    = 89,
                TaskType       = new TaskType("asdf")
                {
                    Id = 99
                },
                UpdateDate = DateTime.Now
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #8
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var pt = new PropertyType("TestPropertyEditor", DataTypeDatabaseType.Nvarchar, "test")
            {
                Id                   = 3,
                CreateDate           = DateTime.Now,
                DataTypeDefinitionId = 5,
                PropertyEditorAlias  = "propTest",
                Description          = "testing",
                Key                  = Guid.NewGuid(),
                Mandatory            = true,
                Name                 = "Test",
                PropertyGroupId      = new Lazy <int>(() => 11),
                SortOrder            = 9,
                UpdateDate           = DateTime.Now,
                ValidationRegExp     = "xxxx",
                DataTypeDatabaseType = DataTypeDatabaseType.Nvarchar
            };

            var result = ss.ToStream(pt);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var dtd = new DataTypeDefinition(9, Guid.NewGuid())
            {
                CreateDate   = DateTime.Now,
                CreatorId    = 5,
                DatabaseType = DataTypeDatabaseType.Nvarchar,
                Id           = 4,
                Key          = Guid.NewGuid(),
                Level        = 7,
                Name         = "Test",
                ParentId     = 9,
                Path         = "-1,2",
                SortOrder    = 8,
                Trashed      = true,
                UpdateDate   = DateTime.Now
            };

            var result = ss.ToStream(dtd);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #10
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var pg = new PropertyGroup(
                new PropertyTypeCollection(false, new[]
            {
                new PropertyType("TestPropertyEditor", ValueStorageType.Nvarchar, "test")
                {
                    Id                  = 3,
                    CreateDate          = DateTime.Now,
                    DataTypeId          = 5,
                    PropertyEditorAlias = "propTest",
                    Description         = "testing",
                    Key                 = Guid.NewGuid(),
                    Mandatory           = true,
                    Name                = "Test",
                    PropertyGroupId     = new Lazy <int>(() => 11),
                    SortOrder           = 9,
                    UpdateDate          = DateTime.Now,
                    ValidationRegExp    = "xxxx",
                    ValueStorageType    = ValueStorageType.Nvarchar
                },
                new PropertyType("TestPropertyEditor2", ValueStorageType.Nvarchar, "test2")
                {
                    Id                  = 4,
                    CreateDate          = DateTime.Now,
                    DataTypeId          = 6,
                    PropertyEditorAlias = "propTest",
                    Description         = "testing2",
                    Key                 = Guid.NewGuid(),
                    Mandatory           = true,
                    Name                = "Test2",
                    PropertyGroupId     = new Lazy <int>(() => 12),
                    SortOrder           = 10,
                    UpdateDate          = DateTime.Now,
                    ValidationRegExp    = "yyyy",
                    ValueStorageType    = ValueStorageType.Nvarchar
                }
            }))
            {
                Id         = 77,
                CreateDate = DateTime.Now,
                Key        = Guid.NewGuid(),
                Name       = "Group1",
                SortOrder  = 555,
                UpdateDate = DateTime.Now
            };

            var result = ss.ToStream(pg);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #11
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = Build();

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new DictionaryItem("blah")
            {
                CreateDate   = DateTime.Now,
                Id           = 8,
                ItemKey      = "blah",
                Key          = Guid.NewGuid(),
                ParentId     = Guid.NewGuid(),
                UpdateDate   = DateTime.Now,
                Translations = new[]
                {
                    new DictionaryTranslation(new Language("en-AU")
                    {
                        CreateDate  = DateTime.Now,
                        CultureName = "en",
                        Id          = 11,
                        IsoCode     = "AU",
                        Key         = Guid.NewGuid(),
                        UpdateDate  = DateTime.Now
                    }, "colour")
                    {
                        CreateDate = DateTime.Now,
                        Id         = 88,
                        Key        = Guid.NewGuid(),
                        UpdateDate = DateTime.Now
                    },
                    new DictionaryTranslation(new Language("en-US")
                    {
                        CreateDate  = DateTime.Now,
                        CultureName = "en",
                        Id          = 12,
                        IsoCode     = "US",
                        Key         = Guid.NewGuid(),
                        UpdateDate  = DateTime.Now
                    }, "color")
                    {
                        CreateDate = DateTime.Now,
                        Id         = 89,
                        Key        = Guid.NewGuid(),
                        UpdateDate = DateTime.Now
                    },
                }
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #13
0
        public void Can_Serialize_Content_Type_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            // Arrange
            var contentType = MockedContentTypes.CreateTextpageContentType();

            contentType.Id = 99;

            var i = 200;

            foreach (var propertyType in contentType.PropertyTypes)
            {
                propertyType.Id = ++i;
            }
            contentType.AllowedTemplates = new[] { new Template("-1,2", "Name", "name")
                                                   {
                                                       Id = 200
                                                   }, new Template("-1,3", "Name2", "name2")
                                                   {
                                                       Id = 201
                                                   } };
            contentType.AllowedContentTypes = new[] { new ContentTypeSort(new Lazy <int>(() => 888), 8, "sub"), new ContentTypeSort(new Lazy <int>(() => 889), 9, "sub2") };
            contentType.Id         = 10;
            contentType.CreateDate = DateTime.Now;
            contentType.CreatorId  = 22;
            contentType.SetDefaultTemplate(new Template("-1,2,3,4", "Test Template", "testTemplate")
            {
                Id = 88
            });
            contentType.Description = "test";
            contentType.Icon        = "icon";
            contentType.IsContainer = true;
            contentType.Thumbnail   = "thumb";
            contentType.Key         = Guid.NewGuid();
            contentType.Level       = 3;
            contentType.Path        = "-1,4,10";
            contentType.SortOrder   = 5;
            contentType.Trashed     = false;
            contentType.UpdateDate  = DateTime.Now;

            ((IUmbracoEntity)contentType).AdditionalData.Add("test1", 123);
            ((IUmbracoEntity)contentType).AdditionalData.Add("test2", "hello");

            var result = ss.ToStream(contentType);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #14
0
        public void Can_Resolve_ContentType_From_Decorated_Home_Model()
        {
            var modelType   = typeof(Home);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            Assert.That(contentType, Is.Not.Null);
            Assert.That(contentType.Value.PropertyGroups, Is.Not.Null);
            Assert.That(contentType.Value.PropertyTypes.Any(), Is.True);
            Assert.That(contentType.Value.PropertyTypes.Count(), Is.EqualTo(2));

            var result = SerializationService.ToStream(contentType.Value);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #15
0
        public void Can_Resolve_ContentType_From_PlainPocoType_Model()
        {
            var modelType   = typeof(PlainPocoType);
            var contentType = ContentTypeDefinitionFactory.GetContentTypeDefinition(modelType);

            Assert.That(contentType, Is.Not.Null);
            Assert.That(contentType.Value.PropertyGroups, Is.Not.Null);
            Assert.That(contentType.Value.PropertyTypes.Any(), Is.True);
            Assert.That(contentType.Value.PropertyGroups.Count(), Is.EqualTo(1));
            Assert.That(contentType.Value.PropertyTypes.Count(), Is.EqualTo(5));

            var result = SerializationService.ToStream(contentType.Value);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #16
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var stylesheet = new Stylesheet("/css/styles.css");

            stylesheet.Content = @"@media screen and (min-width: 600px) and (min-width: 900px) {
                                      .class {
                                        background: #666;
                                      }
                                    }";

            var result = ss.ToStream(stylesheet);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #17
0
        public void Can_Create_And_Serialize_Then_Deserialize_Macro()
        {
            // Arrange
            var serviceStackSerializer = new ServiceStackJsonSerializer();
            var serializationService   = new SerializationService(serviceStackSerializer);

            var macro = new Macro
            {
                Alias         = "test",
                CacheByPage   = false,
                CacheByMember = false,
                DontRender    = true,
                Name          = "Test",
                Xslt          = "/xslt/testMacro.xslt",
                UseInEditor   = false
            };

            macro.Properties = new List <IMacroProperty>();
            macro.Properties.Add(new MacroProperty {
                Alias = "level", Name = "Level", SortOrder = 0, PropertyType = new Umbraco.Core.Macros.PropertyTypes.Number()
            });
            macro.Properties.Add(new MacroProperty {
                Alias = "fixedTitle", Name = "Fixed Title", SortOrder = 1, PropertyType = new Umbraco.Core.Macros.PropertyTypes.Text()
            });

            // Act
            var    json       = serializationService.ToStream(macro);
            string jsonString = json.ResultStream.ToJsonString();

            var deserialized = serializationService.FromJson <Macro>(jsonString);

            var    stream        = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
            object o             = serializationService.FromStream(stream, typeof(Macro));
            var    deserialized2 = o as IMacro;

            // Assert
            Assert.That(json.Success, Is.True);
            Assert.That(jsonString, Is.Not.Empty);
            Assert.That(deserialized, Is.Not.Null);
            Assert.That(deserialized2, Is.Not.Null);
            Assert.That(deserialized.Name, Is.EqualTo(macro.Name));
            Assert.That(deserialized.Alias, Is.EqualTo(macro.Alias));
            Assert.That(deserialized2.Name, Is.EqualTo(macro.Name));
            Assert.That(deserialized2.Alias, Is.EqualTo(macro.Alias));
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new RelationType(Guid.NewGuid(), Guid.NewGuid(), "test")
            {
                Id = 66,
                CreateDate = DateTime.Now,
                IsBidirectional = true,
                Key = Guid.NewGuid(),
                Name = "Test",
                UpdateDate = DateTime.Now
            };

            var result = ss.ToStream(item);
            var json = result.ResultStream.ToJsonString();
            Console.WriteLine(json);
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new TaskType("test")
            {
                Id         = 3,
                Alias      = "test",
                CreateDate = DateTime.Now,
                Key        = Guid.NewGuid(),
                UpdateDate = DateTime.Now
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #20
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new UmbracoEntity()
            {
                Id = 3,
                ContentTypeAlias = "test1",
                CreatorId        = 4,
                Key                  = Guid.NewGuid(),
                UpdateDate           = DateTime.Now,
                CreateDate           = DateTime.Now,
                Name                 = "Test",
                ParentId             = 5,
                SortOrder            = 6,
                Path                 = "-1,23",
                Level                = 7,
                ContentTypeIcon      = "icon",
                ContentTypeThumbnail = "thumb",
                HasChildren          = true,
                HasPendingChanges    = true,
                IsDraft              = true,
                IsPublished          = true,
                NodeObjectTypeId     = Guid.NewGuid()
            };

            item.AdditionalData.Add("test1", 3);
            item.AdditionalData.Add("test2", "valuie");
            item.AdditionalData.Add("test3", new UmbracoEntity.EntityProperty()
            {
                Value = "test",
                PropertyEditorAlias = "TestPropertyEditor"
            });
            item.AdditionalData.Add("test4", new UmbracoEntity.EntityProperty()
            {
                Value = "test2",
                PropertyEditorAlias = "TestPropertyEditor2"
            });

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #21
0
        public void Can_Read_And_Deserialize_Macro_From_Disc()
        {
            // Arrange
            var serviceStackSerializer = new ServiceStackJsonSerializer();
            var serializationService   = new SerializationService(serviceStackSerializer);
            var fileSystem             = new PhysicalFileSystem("~/App_Data/Macros");

            var macro = new Macro
            {
                Alias         = "test",
                CacheByPage   = false,
                CacheByMember = false,
                DontRender    = true,
                Name          = "Test",
                Xslt          = "/xslt/testMacro.xslt",
                UseInEditor   = false
            };

            macro.Properties = new List <IMacroProperty>();
            macro.Properties.Add(new MacroProperty {
                Alias = "level", Name = "Level", SortOrder = 0, PropertyType = new Umbraco.Core.Macros.PropertyTypes.Number()
            });
            macro.Properties.Add(new MacroProperty {
                Alias = "fixedTitle", Name = "Fixed Title", SortOrder = 1, PropertyType = new Umbraco.Core.Macros.PropertyTypes.Text()
            });

            // Act
            var    json       = serializationService.ToStream(macro);
            string jsonString = json.ResultStream.ToJsonString();

            fileSystem.AddFile("test-serialized-Macro.macro", json.ResultStream, true);

            Stream stream       = fileSystem.OpenFile("test-serialized-Macro.macro");
            object o            = serializationService.FromStream(stream, typeof(Macro));
            var    deserialized = o as IMacro;

            // Assert
            Assert.That(json.Success, Is.True);
            Assert.That(jsonString, Is.Not.Empty);
            Assert.That(fileSystem.FileExists("test-serialized-Macro.macro"), Is.True);
            Assert.That(deserialized, Is.Not.Null);
            Assert.That(deserialized.Name, Is.EqualTo(macro.Name));
            Assert.That(deserialized.Alias, Is.EqualTo(macro.Alias));
        }
Example #22
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var memberType = MockedContentTypes.CreateSimpleMemberType("memberType", "Member Type");

            memberType.Id = 99;
            var member = MockedMember.CreateSimpleMember(memberType, "Name", "*****@*****.**", "pass", "user", Guid.NewGuid());
            var i      = 200;

            foreach (var property in member.Properties)
            {
                property.Id = ++i;
            }
            member.Id                     = 10;
            member.CreateDate             = DateTime.Now;
            member.CreatorId              = 22;
            member.Comments               = "comments";
            member.Key                    = Guid.NewGuid();
            member.FailedPasswordAttempts = 22;
            member.Level                  = 3;
            member.Path                   = "-1,4,10";
            member.Groups                 = new[] { "group1", "group2" };
            member.IsApproved             = true;
            member.IsLockedOut            = true;
            member.LastLockoutDate        = DateTime.Now;
            member.LastLoginDate          = DateTime.Now;
            member.LastPasswordChangeDate = DateTime.Now;
            member.PasswordQuestion       = "question";
            member.ProviderUserKey        = Guid.NewGuid();
            member.RawPasswordAnswerValue = "raw answer";
            member.RawPasswordValue       = "raw pass";
            member.SortOrder              = 5;
            member.Trashed                = false;
            member.UpdateDate             = DateTime.Now;
            member.Version                = Guid.NewGuid();
            ((IUmbracoEntity)member).AdditionalData.Add("test1", 123);
            ((IUmbracoEntity)member).AdditionalData.Add("test2", "hello");

            var result = ss.ToStream(member);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #23
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new Language("en-AU")
            {
                CreateDate  = DateTime.Now,
                CultureName = "AU",
                Id          = 11,
                IsoCode     = "en",
                Key         = Guid.NewGuid(),
                UpdateDate  = DateTime.Now
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            // Arrange
            var contentType = MockedContentTypes.CreateTextpageContentType();

            contentType.Id = 99;
            var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
            var i       = 200;

            foreach (var property in content.Properties)
            {
                property.Id = ++i;
            }
            content.Id          = 10;
            content.CreateDate  = DateTime.Now;
            content.CreatorId   = 22;
            content.ExpireDate  = DateTime.Now;
            content.Key         = Guid.NewGuid();
            content.Language    = "en";
            content.Level       = 3;
            content.Path        = "-1,4,10";
            content.ReleaseDate = DateTime.Now;
            content.ChangePublishedState(PublishedState.Published);
            content.SortOrder = 5;
            content.Template  = new Template("-1,2,3,4", "Test Template", "testTemplate")
            {
                Id = 88
            };
            content.Trashed    = false;
            content.UpdateDate = DateTime.Now;
            content.Version    = Guid.NewGuid();
            content.WriterId   = 23;

            ((IUmbracoEntity)content).AdditionalData.Add("test1", 123);
            ((IUmbracoEntity)content).AdditionalData.Add("test2", "hello");

            var result = ss.ToStream(content);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new UserType()
            {
                Id          = 3,
                Key         = Guid.NewGuid(),
                UpdateDate  = DateTime.Now,
                CreateDate  = DateTime.Now,
                Name        = "Test",
                Alias       = "test",
                Permissions = new[] { "a", "b", "c" }
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }
Example #26
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new Template("Test", "test")
            {
                Id                  = 3,
                CreateDate          = DateTime.Now,
                Key                 = Guid.NewGuid(),
                UpdateDate          = DateTime.Now,
                Content             = "blah",
                MasterTemplateAlias = "master",
                MasterTemplateId    = new Lazy <int>(() => 88)
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #27
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new Relation(9, 8, new RelationType(Guid.NewGuid(), Guid.NewGuid(), "test")
            {
                Id = 66
            })
            {
                Comment    = "test comment",
                CreateDate = DateTime.Now,
                Id         = 4,
                Key        = Guid.NewGuid(),
                UpdateDate = DateTime.Now
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #28
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var item = new User(new UserType()
            {
                Id = 3
            })
            {
                Id                     = 3,
                Key                    = Guid.NewGuid(),
                UpdateDate             = DateTime.Now,
                CreateDate             = DateTime.Now,
                Name                   = "Test",
                Comments               = "comments",
                DefaultPermissions     = new[] { "a", "b", "c" },
                DefaultToLiveEditing   = false,
                Email                  = "*****@*****.**",
                Language               = "en",
                FailedPasswordAttempts = 3,
                IsApproved             = true,
                IsLockedOut            = true,
                LastLockoutDate        = DateTime.Now,
                LastLoginDate          = DateTime.Now,
                LastPasswordChangeDate = DateTime.Now,
                //Password = "******",
                //PasswordAnswer = "answer",
                PasswordQuestion = "question",
                //ProviderUserKey = "user key",
                SessionTimeout = 5,
                StartContentId = 3,
                StartMediaId   = 8,
                Username       = "******"
            };

            var result = ss.ToStream(item);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #29
0
        public void Can_Serialize_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            var group = new MemberGroup()
            {
                CreateDate = DateTime.Now,
                CreatorId  = 4,
                Id         = 6,
                Key        = Guid.NewGuid(),
                UpdateDate = DateTime.Now,
                Name       = "asdf"
            };

            group.AdditionalData.Add("test1", 123);
            group.AdditionalData.Add("test2", "hello");

            var result = ss.ToStream(group);
            var json   = result.ResultStream.ToJsonString();

            Debug.Print(json);
        }
Example #30
0
        public void Can_Serialize_Member_Type_Without_Error()
        {
            var ss = new SerializationService(new JsonNetSerializer());

            // Arrange
            var contentType = MockedContentTypes.CreateSimpleMemberType();

            contentType.Id = 99;

            var i = 200;

            foreach (var propertyType in contentType.PropertyTypes)
            {
                propertyType.Id = ++i;
            }
            contentType.Id          = 10;
            contentType.CreateDate  = DateTime.Now;
            contentType.CreatorId   = 22;
            contentType.Description = "test";
            contentType.Icon        = "icon";
            contentType.IsContainer = true;
            contentType.Thumbnail   = "thumb";
            contentType.Key         = Guid.NewGuid();
            contentType.Level       = 3;
            contentType.Path        = "-1,4,10";
            contentType.SortOrder   = 5;
            contentType.Trashed     = false;
            contentType.UpdateDate  = DateTime.Now;
            contentType.SetMemberCanEditProperty("title", true);
            contentType.SetMemberCanViewProperty("bodyText", true);
            ((IUmbracoEntity)contentType).AdditionalData.Add("test1", 123);
            ((IUmbracoEntity)contentType).AdditionalData.Add("test2", "hello");

            var result = ss.ToStream(contentType);
            var json   = result.ResultStream.ToJsonString();

            Console.WriteLine(json);
        }