public void Should_Return_MergedOptionsAndValuesSuccessfully()
        {
            var option1 = TestDataProvider.CreateNewLayoutOption();
            var option2 = TestDataProvider.CreateNewLayoutOption();
            var option3 = TestDataProvider.CreateNewLayoutOption();
            var option4 = TestDataProvider.CreateNewLayoutOption();
            var option5 = TestDataProvider.CreateNewLayoutOption();

            var optionValue1 = TestDataProvider.CreateNewPageOption();
            var optionValue2 = TestDataProvider.CreateNewPageOption();
            var optionValue3 = TestDataProvider.CreateNewPageOption();
            var optionValue4 = TestDataProvider.CreateNewPageOption();
            var optionValue5 = TestDataProvider.CreateNewPageOption();

            optionValue1.Key = option1.Key;
            optionValue2.Key = option2.Key;
            option1.Type = option2.Type = option3.Type = option4.Type = option5.Type = OptionType.Text;
            optionValue1.Type = optionValue2.Type = optionValue3.Type = optionValue4.Type = optionValue5.Type = OptionType.Text;

            option3.DefaultValue = null;
            optionValue4.Value = null;

            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption> { optionValue1, optionValue2, optionValue3, optionValue4, optionValue5 };
            var options = new List<IOption> { option1, option2, option3, option4, option5 };

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 8);
            Assert.AreEqual(6, result.Count(o => o.Value != null));
        }
        public void Should_By_Xml_And_Binary_Serializable()
        {
            var pageContent = TestDataProvider.CreateNewPageContent();
            pageContent.Content = TestDataProvider.CreateNewHtmlContent();
            pageContent.Options = new[]
                                                 {
                                                     TestDataProvider.CreateNewPageContentOption(pageContent),
                                                     TestDataProvider.CreateNewPageContentOption(pageContent),
                                                     TestDataProvider.CreateNewPageContentOption(pageContent)
                                                 };

            var cmsConfiguration = new Mock<ICmsConfiguration>();
            var optionService = new DefaultOptionService(null, new HttpRuntimeCacheService(), cmsConfiguration.Object);
            var optionValues = optionService.GetMergedOptionValues(pageContent.Options, null);

            PageContentProjection original = new PageContentProjection(
                pageContent, pageContent.Content, new HtmlContentAccessor((HtmlContent)pageContent.Content, optionValues));

            RunSerializationAndDeserialization(original,
                projection =>
                    {
                        Assert.AreEqual(original.ContentId, projection.ContentId);
                        Assert.AreEqual(original.Order, projection.Order);
                        Assert.AreEqual(original.RegionId, projection.RegionId);
                    });
        }       
        public void Should_By_Xml_And_Binary_Serializable()
        {
            var pageContent = TestDataProvider.CreateNewPageContent();

            pageContent.Content = TestDataProvider.CreateNewHtmlContent();
            pageContent.Options = new[]
            {
                TestDataProvider.CreateNewPageContentOption(pageContent),
                TestDataProvider.CreateNewPageContentOption(pageContent),
                TestDataProvider.CreateNewPageContentOption(pageContent)
            };

            var cmsConfiguration = new Mock <ICmsConfiguration>();
            var optionService    = new DefaultOptionService(null, new HttpRuntimeCacheService(), cmsConfiguration.Object);
            var optionValues     = optionService.GetMergedOptionValues(pageContent.Options, null);

            var original = new PageContentProjection(
                pageContent, pageContent.Content, new HtmlContentAccessor((HtmlContent)pageContent.Content, optionValues));

            RunSerializationAndDeserialization(original,
                                               projection =>
            {
                Assert.AreEqual(original.ContentId, projection.ContentId);
                Assert.AreEqual(original.Order, projection.Order);
                Assert.AreEqual(original.RegionId, projection.RegionId);
            });
        }
        public void Should_Return_MergedEmptyOptionsSuccessfully()
        {
            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.IsEmpty(result);
        }
Пример #5
0
        public void Should_Return_MergedEmptyOptionsSuccessfully()
        {
            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

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

            Assert.NotNull(result);
            Assert.IsEmpty(result);
        }
Пример #6
0
        public void Should_Return_Null_Values_Not_ConvertedToDateTime()
        {
            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();

            option.DefaultValue = "not-datetime";
            option.Type         = OptionType.DateTime;
            options.Add(option);

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

            Assert.NotNull(result);
            Assert.IsNull(result[0].Value);
        }
Пример #7
0
        public void Should_Return_Null_Values_Not_ConvertedToInteger()
        {
            var service      = new DefaultOptionService(null);
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();

            option.DefaultValue = "not-integer";
            option.Type         = OptionType.Integer;
            options.Add(option);

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

            Assert.NotNull(result);
            Assert.IsNull(result[0].Value);
        }
Пример #8
0
        public void Should_Return_ValuesConvertedToFloat()
        {
            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();

            option.DefaultValue = "10.5";
            option.Type         = OptionType.Float;
            options.Add(option);

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

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Value is decimal, true);
            Assert.AreEqual(result[0].Value, 10.5M);
        }
Пример #9
0
        public void Should_Return_ValuesConvertedToLongInteger()
        {
            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();

            option.DefaultValue = "4294967296";
            option.Type         = OptionType.Integer;
            options.Add(option);

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

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Value is long, true);
            Assert.AreEqual(result[0].Value, 4294967296);
        }
        public void Should_Return_MergedOptionValuesSuccessfully()
        {
            var option1 = TestDataProvider.CreateNewLayoutOption();
            var option2 = TestDataProvider.CreateNewLayoutOption();
            var option3 = TestDataProvider.CreateNewLayoutOption();

            option1.Type = option2.Type = option3.Type = OptionType.Text;
            
            option3.DefaultValue = null;

            var service = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List<IOption>();
            var options = new List<IOption> { option1, option2, option3 };

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
            Assert.AreEqual(2, result.Count(o => o.Value != null));
        }
Пример #11
0
        public void Should_Return_ValuesConvertedToBoolean()
        {
            var service      = new DefaultOptionService(null);
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();

            option.DefaultValue = "true";
            option.Type         = OptionType.Boolean;
            options.Add(option);

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

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Value is bool, true);
            Assert.AreEqual(result[0].Value, true);
        }
Пример #12
0
        public void Should_Return_MergedOptionsSuccessfully()
        {
            var optionValue1 = TestDataProvider.CreateNewPageOption();
            var optionValue2 = TestDataProvider.CreateNewPageOption();
            var optionValue3 = TestDataProvider.CreateNewPageOption();

            optionValue1.Type = optionValue2.Type = optionValue3.Type = OptionType.Text;

            optionValue3.Value = null;

            var service      = new DefaultOptionService(null);
            var optionValues = new List <IOption> {
                optionValue1, optionValue2, optionValue3
            };
            var options = new List <IOption>();

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

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
            Assert.AreEqual(2, result.Count(o => o.Value != null));
        }
Пример #13
0
        public void Should_Return_MergedOptionValuesSuccessfully()
        {
            var option1 = TestDataProvider.CreateNewLayoutOption();
            var option2 = TestDataProvider.CreateNewLayoutOption();
            var option3 = TestDataProvider.CreateNewLayoutOption();

            option1.Type = option2.Type = option3.Type = OptionType.Text;

            option3.DefaultValue = null;

            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption>();
            var options      = new List <IOption> {
                option1, option2, option3
            };

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

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
            Assert.AreEqual(2, result.Count(o => o.Value != null));
        }
Пример #14
0
        public void Should_Return_MergedOptionsAndValuesSuccessfully()
        {
            var option1 = TestDataProvider.CreateNewLayoutOption();
            var option2 = TestDataProvider.CreateNewLayoutOption();
            var option3 = TestDataProvider.CreateNewLayoutOption();
            var option4 = TestDataProvider.CreateNewLayoutOption();
            var option5 = TestDataProvider.CreateNewLayoutOption();

            var optionValue1 = TestDataProvider.CreateNewPageOption();
            var optionValue2 = TestDataProvider.CreateNewPageOption();
            var optionValue3 = TestDataProvider.CreateNewPageOption();
            var optionValue4 = TestDataProvider.CreateNewPageOption();
            var optionValue5 = TestDataProvider.CreateNewPageOption();

            optionValue1.Key  = option1.Key;
            optionValue2.Key  = option2.Key;
            option1.Type      = option2.Type = option3.Type = option4.Type = option5.Type = OptionType.Text;
            optionValue1.Type = optionValue2.Type = optionValue3.Type = optionValue4.Type = optionValue5.Type = OptionType.Text;

            option3.DefaultValue = null;
            optionValue4.Value   = null;

            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption> {
                optionValue1, optionValue2, optionValue3, optionValue4, optionValue5
            };
            var options = new List <IOption> {
                option1, option2, option3, option4, option5
            };

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

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 8);
            Assert.AreEqual(6, result.Count(o => o.Value != null));
        }
        public void Should_Return_ValuesConvertedToBoolean()
        {
            var service = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();
            option.DefaultValue = "true";
            option.Type = OptionType.Boolean;
            options.Add(option);

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Value is bool, true);
            Assert.AreEqual(result[0].Value, true);
        }
Пример #16
0
        public void Should_Return_ValuesConvertedToInteger()
        {
            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();
            option.DefaultValue = "580";
            option.Type = OptionType.Integer;
            options.Add(option);

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Value is long, true);
            Assert.AreEqual(result[0].Value, 580);
        }
Пример #17
0
        public void Should_Return_ValuesConvertedToDateTime()
        {
            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();
            option.DefaultValue = "10/10/2010";
            option.Type = OptionType.DateTime;
            options.Add(option);

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Value is DateTime, true);
            Assert.AreEqual(result[0].Value, new DateTime(2010, 10, 10));
        }
Пример #18
0
        public void Should_Return_Null_Values_Not_ConvertedToInteger()
        {
            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();
            option.DefaultValue = "not-integer";
            option.Type = OptionType.Integer;
            options.Add(option);

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.IsNull(result[0].Value);
        }
        public void Should_Return_Null_Values_Not_ConvertedToFloat()
        {
            var service = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var option = TestDataProvider.CreateNewLayoutOption();
            option.DefaultValue = "not-float";
            option.Type = OptionType.Float;
            options.Add(option);

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 1);
            Assert.IsNull(result[0].Value);
        }
Пример #20
0
        public void Should_Return_MergedOptionsSuccessfully()
        {
            var optionValue1 = TestDataProvider.CreateNewPageOption();
            var optionValue2 = TestDataProvider.CreateNewPageOption();
            var optionValue3 = TestDataProvider.CreateNewPageOption();

            optionValue1.Type = optionValue2.Type = optionValue3.Type = OptionType.Text;

            optionValue3.Value = null;

            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption> { optionValue1, optionValue2, optionValue3 };
            var options = new List<IOption>();

            var result = service.GetMergedOptionValues(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
            Assert.AreEqual(2, result.Count(o => o.Value != null));
        }