public void SaveGroupTree_RequestForSave_Save() { string expected = "<?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 forSave = new GroupSettingsContainer() { Items = new List <GroupSettingsItem>() { new GroupSettingsContainer() { Name = "Container1", Items = new List <GroupSettingsItem>() { new GroupSettingsContainer() { Name = "Container2" }, new GroupSettingsGroup() { Name = "Group2" } }, IsActive = true }, new GroupSettingsGroup() { Name = "Group", Items = new List <string>() { "Account1" } } } }; GroupSettings _settings = new GroupSettings(_mockService.Object, _parameterName, forSave); _settings.SaveGroupTree(); _mockService.Verify(settings => settings.SetValueAsString(_parameterName, expected), Occurred.Once()); }