public void Should_Return_MergedEmptyOptions_ForEdit_Successfully()
        {
            var service = new DefaultOptionService(null);
            var optionValues = new List<IOption>();
            var options = new List<IOption>();

            var result = service.GetMergedOptionValuesForEdit(options, optionValues);
            Assert.NotNull(result);
            Assert.IsEmpty(result);
        }
Exemplo n.º 2
0
        public void Should_Return_MergedEmptyOptions_ForEdit_Successfully()
        {
            var service      = new DefaultOptionService(null, new HttpRuntimeCacheService());
            var optionValues = new List <IOption>();
            var options      = new List <IOption>();

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

            Assert.NotNull(result);
            Assert.IsEmpty(result);
        }
Exemplo n.º 3
0
        public void Should_Return_MergedOptionsAndValues_ForEdit_Successfully()
        {
            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.GetMergedOptionValuesForEdit(options, optionValues);

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 8);
            // 3 of 5 values has no equivalent option, so they can be edited
            Assert.AreEqual(result.Count(o => o.CanEditOption), 3);
            // 4 of 5 options has default values
            Assert.AreEqual(result.Count(o => o.OptionDefaultValue == null), 4);
            // 4 of 5 option values has default values
            Assert.AreEqual(result.Count(o => o.OptionValue == o.OptionDefaultValue), 4);
            // 1 option and option value are equal
            Assert.AreEqual(result.Count(o => o.OptionKey == option1.Key &&
                                         o.OptionDefaultValue == option1.DefaultValue &&
                                         o.OptionValue == optionValue1.Value), 1);
            // 2 option and option value are equal
            Assert.AreEqual(result.Count(o => o.OptionKey == option2.Key &&
                                         o.OptionDefaultValue == option2.DefaultValue &&
                                         o.OptionValue == optionValue2.Value), 1);
        }
Exemplo n.º 4
0
        public void Should_Return_MergedOptionValues_ForEdit_Successfully()
        {
            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.GetMergedOptionValuesForEdit(options, optionValues);

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
        }
Exemplo n.º 5
0
        public void Should_Return_MergedOptions_ForEdit_Successfully()
        {
            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.GetMergedOptionValuesForEdit(options, optionValues);

            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
        }
        public void Should_Return_MergedOptionsAndValues_ForEdit_Successfully()
        {
            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.GetMergedOptionValuesForEdit(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 8);
            // 3 of 5 values has no equivalent option, so they can be edited
            Assert.AreEqual(result.Count(o => o.CanEditOption), 3);
            // 4 of 5 options has default values
            Assert.AreEqual(result.Count(o => o.OptionDefaultValue == null), 4);
            // 4 of 5 option values has default values
            Assert.AreEqual(result.Count(o => o.OptionValue == o.OptionDefaultValue), 4);
            // 1 option and option value are equal
            Assert.AreEqual(result.Count(o => o.OptionKey == option1.Key
                && o.OptionDefaultValue == option1.DefaultValue
                && o.OptionValue == optionValue1.Value), 1);
            // 2 option and option value are equal
            Assert.AreEqual(result.Count(o => o.OptionKey == option2.Key
                && o.OptionDefaultValue == option2.DefaultValue
                && o.OptionValue == optionValue2.Value), 1);
        }
        public void Should_Return_MergedOptionValues_ForEdit_Successfully()
        {
            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);
            var optionValues = new List<IOption>();
            var options = new List<IOption> { option1, option2, option3 };

            var result = service.GetMergedOptionValuesForEdit(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
        }
        public void Should_Return_MergedOptions_ForEdit_Successfully()
        {
            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, new HttpRuntimeCacheService());
            var optionValues = new List<IOption> { optionValue1, optionValue2, optionValue3 };
            var options = new List<IOption>();

            var result = service.GetMergedOptionValuesForEdit(options, optionValues);
            Assert.NotNull(result);
            Assert.AreEqual(result.Count, 3);
        }