Esempio n. 1
0
        public void SetActive_RequestForSetActive_SetActiveState()
        {
            GroupSettings _settings    = new GroupSettings(_mockService.Object, _parameterName, null);
            string        stubSettings =
                "<?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 xsi:type=\"GroupSettingsGroup\">\r\n              <Name>Group2</Name>\r\n              <Items>\r\n                <string>Account1</string>\r\n              </Items>\r\n            </GroupSettingsItem>\r\n          </Items>\r\n        </GroupSettingsItem>\r\n      </Items>\r\n    </GroupSettingsItem>\r\n  </Items>\r\n</GroupSettingsContainer>";
            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>false</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 xsi:type=\"GroupSettingsGroup\">\r\n              <Name>Group2</Name>\r\n              <Items>\r\n                <string>Account1</string>\r\n              </Items>\r\n            </GroupSettingsItem>\r\n          </Items>\r\n        </GroupSettingsItem>\r\n      </Items>\r\n    </GroupSettingsItem>\r\n  </Items>\r\n</GroupSettingsContainer>";

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

            _settings.SetActive(new List <string>(), "MainContainer", false);

            _mockService.Verify(settings => settings.SetValueAsString(_parameterName, expectedStringForSave),
                                Occurred.Once());
        }
Esempio n. 2
0
        public void LoadGroupTree_RequestForLoadGroup_LoadGroupTree()
        {
            GroupSettings _settings = new GroupSettings(_mockService.Object, _parameterName, null);

            string stub =
                "<?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  <IsActive>false</IsActive>\r\n  <Items>\r\n    <GroupSettingsItem xsi:type=\"GroupSettingsContainer\">\r\n      <Name>Container1</Name>\r\n      <IsActive>true</IsActive>\r\n      <Items>\r\n        <GroupSettingsItem xsi:type=\"GroupSettingsContainer\">\r\n          <Name>Container2</Name>\r\n          <IsActive>false</IsActive>\r\n        </GroupSettingsItem>\r\n        <GroupSettingsItem xsi:type=\"GroupSettingsGroup\">\r\n          <Name>Group2</Name>\r\n        </GroupSettingsItem>\r\n      </Items>\r\n    </GroupSettingsItem>\r\n    <GroupSettingsItem xsi:type=\"GroupSettingsGroup\">\r\n      <Name>Group</Name>\r\n      <Items>\r\n        <string>Account1</string>\r\n      </Items>\r\n    </GroupSettingsItem>\r\n  </Items>\r\n</GroupSettingsContainer>";
            var expected = new GroupSettingsContainer()
            {
                Items = new List <GroupSettingsItem>()
                {
                    new GroupSettingsContainer()
                    {
                        Name  = "Container1",
                        Items = new List <GroupSettingsItem>()
                        {
                            new GroupSettingsContainer()
                            {
                                Name = "Container2", Items = new List <GroupSettingsItem>()
                            },
                            new GroupSettingsGroup()
                            {
                                Name = "Group2", Items = new List <string>()
                            }
                        },
                        IsActive = true
                    },
                    new GroupSettingsGroup()
                    {
                        Name = "Group", Items = new List <string>()
                        {
                            "Account1"
                        }
                    }
                }
            };

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

            Assert.IsNotNull(actuality);
            Assert.IsNotNull(actuality.Items);
            Assert.AreEqual(expected, actuality);
        }
Esempio n. 3
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);
        }