Exemplo n.º 1
0
            public void ReloadFromStream(Stream stream)
            {
                if (stream.Length > 0)
                {
                    RadGridViewApplicationSettings loaded = (RadGridViewApplicationSettings)serializer.ReadObject(stream);

                    FrozenColumnCount = loaded.FrozenColumnCount;

                    ColumnSettings.Clear();
                    foreach (ColumnSetting cs in loaded.ColumnSettings)
                    {
                        ColumnSettings.Add(cs);
                    }

                    FilterSettings.Clear();
                    foreach (FilterSetting fs in loaded.FilterSettings)
                    {
                        FilterSettings.Add(fs);
                    }

                    GroupSettings.Clear();
                    foreach (GroupSetting gs in loaded.GroupSettings)
                    {
                        GroupSettings.Add(gs);
                    }

                    SortSettings.Clear();
                    foreach (SortSetting ss in loaded.SortSettings)
                    {
                        SortSettings.Add(ss);
                    }
                }
            }
Exemplo n.º 2
0
        public void Add_RequestForAddContainer_AddNewContainer()
        {
            GroupSettings _settings             = new GroupSettings(_mockService.Object, _parameterName, null);
            string        expectedStringForSave =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<GroupSettingsContainer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n  <Name>Room</Name>\r\n  <IsActive>false</IsActive>\r\n  <Items>\r\n    <GroupSettingsItem xsi:type=\"GroupSettingsContainer\">\r\n      <Name>MainContainer</Name>\r\n      <IsActive>true</IsActive>\r\n      <Items>\r\n        <GroupSettingsItem xsi:type=\"GroupSettingsGroup\">\r\n          <Name>Group</Name>\r\n          <Items>\r\n            <string>Account1</string>\r\n            <string>Account2</string>\r\n          </Items>\r\n        </GroupSettingsItem>\r\n        <GroupSettingsItem xsi:type=\"GroupSettingsContainer\">\r\n          <Name>Container</Name>\r\n          <IsActive>true</IsActive>\r\n          <Items />\r\n        </GroupSettingsItem>\r\n      </Items>\r\n    </GroupSettingsItem>\r\n  </Items>\r\n</GroupSettingsContainer>";

            var expected = new GroupSettingsContainer()
            {
                Name  = "MainContainer", IsActive = true,
                Items = new List <GroupSettingsItem>()
                {
                    new GroupSettingsGroup()
                    {
                        Items = new List <string>()
                        {
                            "Account1", "Account2"
                        },
                        Name = "Group"
                    },
                    new GroupSettingsContainer()
                    {
                        Name     = "Container",
                        Items    = new List <GroupSettingsItem>(),
                        IsActive = true
                    }
                }
            };

            _mockService.Setup(settings => settings.GetValueAsString(_parameterName)).Returns(String.Empty);
            GroupSettingsContainer actuality = _settings.LoadGroupTree();

            _settings.Add(new List <string>(), expected);

            _mockService.Verify(settings => settings.SetValueAsString(_parameterName, expectedStringForSave),
                                Occurred.Once());

            Assert.IsNotNull(actuality);
            Assert.IsNotNull(actuality.Items);
        }