Example #1
0
        public void Should_Remove_ContentOptions_From_Content()
        {
            var content        = TestDataProvider.CreateNewContent();
            var contentOptions = new[]
            {
                TestDataProvider.CreateNewContentOption(content),
                TestDataProvider.CreateNewContentOption(content)
            };

            content.ContentOptions = contentOptions;

            RunActionInTransaction(
                session =>
            {
                session.SaveOrUpdate(content);
                session.Flush();
                Guid contentId = content.Id;
                session.Clear();

                session.Delete(content.ContentOptions[0]);
                session.Flush();
                session.Clear();

                var dbContent = session.Query <Content>().FetchMany(f => f.ContentOptions).FirstOrDefault(f => f.Id == contentId);
                Assert.IsNotNull(dbContent);
                Assert.AreEqual(content, dbContent);
                Assert.AreEqual(1, dbContent.ContentOptions.Count);
            });
        }
Example #2
0
        public void ShouldReturnCorrectOptionValueForSpecificLanguage7()
        {
            var lang = new Language();

            lang.Id = Guid.NewGuid();
            var option1 = TestDataProvider.CreateNewContentOption();

            option1.Type = OptionType.Text;
            var optionValue1 = TestDataProvider.CreateNewChildContentOption();

            optionValue1.Key  = option1.Key;
            optionValue1.Type = option1.Type;
            var valueTranslation = new ChildContentOptionTranslation();

            valueTranslation.Language           = lang;
            valueTranslation.Value              = TestDataProvider.ProvideRandomString(100);
            valueTranslation.ChildContentOption = optionValue1;
            optionValue1.Translations.Add(valueTranslation);
            var service = CreateOptionService();
            var options = new List <IOptionEntity> {
                option1
            };
            var optionValues = new List <IOptionValueEntity> {
                optionValue1
            };

            var result = service.GetMergedOptionValues(options, optionValues, lang.Id);

            Assert.NotNull(result);
            Assert.AreEqual(valueTranslation.Value, result[0].Value);
        }
Example #3
0
        public void ShouldReturnCorrectOptionValueForSpecificLanguage3()
        {
            Language lang = new Language();

            lang.Id = Guid.NewGuid();
            var option1 = TestDataProvider.CreateNewContentOption();

            option1.Type = OptionType.Text;
            var optionValue1 = TestDataProvider.CreateNewChildContentOption();

            optionValue1.Key  = option1.Key;
            optionValue1.Type = option1.Type;

            var service = CreateOptionService();
            var options = new List <IOptionEntity> {
                option1
            };
            var optionValues = new List <IOptionValueEntity> {
                optionValue1
            };

            var result = service.GetMergedOptionValues(options, optionValues, lang.Id);

            Assert.NotNull(result);
            Assert.AreEqual(optionValue1.Value, result[0].Value);
        }
        protected void FillContentWithOptions(Content content)
        {
            var option1 = TestDataProvider.CreateNewContentOption(content);
            var option2 = TestDataProvider.CreateNewContentOption(content);
            var option3 = TestDataProvider.CreateNewContentOption(content);

            content.ContentOptions = new List <ContentOption>();
            content.ContentOptions.Add(option1);
            content.ContentOptions.Add(option2);
            content.ContentOptions.Add(option3);
        }
Example #5
0
        public void ShouldReturnCorrectOptionValueForDefaultLanguage()
        {
            var option1 = TestDataProvider.CreateNewContentOption();

            option1.Type = OptionType.Text;
            var service = CreateOptionService();
            var options = new List <IOptionEntity> {
                option1
            };
            var result = service.GetMergedOptionValues(options, new List <IOptionValueEntity>());

            Assert.NotNull(result);
            Assert.AreEqual(option1.DefaultValue, result[0].Value);
        }
Example #6
0
        public void Should_Insert_And_Retrieve_Content_ContentOptions_Successfully()
        {
            var content        = TestDataProvider.CreateNewContent();
            var contentOptions = new[]
            {
                TestDataProvider.CreateNewContentOption(content),
                TestDataProvider.CreateNewContentOption(content)
            };

            content.ContentOptions = contentOptions;

            SaveEntityAndRunAssertionsInTransaction(
                content,
                result =>
            {
                Assert.AreEqual(content, result);
                Assert.AreEqual(contentOptions.OrderBy(f => f.Id), result.ContentOptions.OrderBy(f => f.Id));
            });
        }
Example #7
0
        public void ShouldReturnCorrectOptionValueForDefaultLanguage2()
        {
            Language lang = new Language();

            lang.Id = Guid.NewGuid();
            var option1 = TestDataProvider.CreateNewContentOption();

            option1.Type = OptionType.Text;
            var translation = new ContentOptionTranslation();

            translation.ContentOption = option1;
            translation.Value         = TestDataProvider.ProvideRandomString(100);
            translation.Language      = lang;
            option1.Translations.Add(translation);
            var service = CreateOptionService();
            var options = new List <IOptionEntity> {
                option1
            };
            var result = service.GetMergedOptionValues(options, new List <IOptionValueEntity>());

            Assert.NotNull(result);
            Assert.AreEqual(option1.DefaultValue, result[0].Value);
        }
        public void Should_Insert_And_Retrieve_ContentOption_Successfully()
        {
            var contentOption = TestDataProvider.CreateNewContentOption();

            RunEntityMapTestsInTransaction(contentOption);
        }