public void ConfCRUD()
        {
            Service service;
            string  app   = "sdk-tests";
            string  owner = "nobody";

            // Create a fresh app to use as the container for confs that we will
            // create in this test. There is no way to delete a conf once it's
            // created so we make sure to create in the context of this test app
            // and then we delete the app when we are done to make everything go
            // away.
            this.CreateApp(app);
            service = this.Connect();
            var apps = service.GetApplicationsAsync().Result;

            Assert.True(apps.Any(a => a.ResourceName.Title == app), assertRoot + "#8");

            Namespace ns = new Namespace(owner, app);

            // Create an app specific service instance
            //Args args = new Args(this.SetUp().Opts);
            //args.Add("app", app);
            //args.Add("owner", owner);

            service = this.Connect(ns);
            //service = Service.Connect(args);

            //Context context = new Context(Scheme.Https, this.SetUp().Host, this.SetUp().Port);
            //service = new Service(context);
            //service.LoginAsync(this.SetUp().Username, this.SetUp().Password).Wait();

            //service = this.Connect();
            ConfigurationCollection confs = service.GetConfigurationsAsync().Result;

            //if below failed, remove the file C:\Program Files\Splunk\etc\system\local\testconf.conf, serverInfo should provide home  path etc?
            Assert.False(confs.Any(a => a.Name == "testconf"), assertRoot + "#9");

            Configuration testconf = service.CreateConfigurationAsync("testconf").Result;

            confs.GetAsync().Wait();
            Assert.True(confs.Any(a => a.Name == "testconf"), assertRoot + "#10");

            testconf = service.GetConfigurationAsync("testconf").Result;

            //ConfigurationStanza stanzas = service.GetConfigurationStanzaAsync("testconf", "stanza1").Result;
            //Assert.Equal(0, stanzas.Count);

            service.CreateConfigurationStanzaAsync("testconf", "stanza1").Wait();
            service.CreateConfigurationStanzaAsync("testconf", "stanza2").Wait();
            service.CreateConfigurationStanzaAsync("testconf", "stanza3").Wait();

            testconf.GetAsync().Wait();
            Assert.Equal(4, testconf.Count);
            Assert.NotNull(testconf.GetStanzaAsync("stanza1").Result.Name);
            Assert.NotNull(testconf.GetStanzaAsync("stanza2").Result.Name);
            Assert.NotNull(testconf.GetStanzaAsync("stanza3").Result.Name);

            //EntityCollection<Entity> stanzas = confs.Get("testconf");

            //// Grab the new stanza and check its content
            ConfigurationStanza stanza1 = testconf.GetStanzaAsync("stanza1").Result;
            //Assert.False(stanza1.Any(), "Expected stanza1 to be non-empty");
            //Assert.Equal(5, stanza1.Count);//, "Expected stanza1 to have 5 elements");
            //Assert.Equal("nobody", stanza1.GetSettingAsync("eai:userName").Result.Name);
            //Assert.Equal(app, stanza1.GetSettingAsync("eai:appName").Result.Name);
            //Assert.False(stanza1.ContainsKey("key1"), assertRoot + "#18");
            //Assert.False(stanza1.ContainsKey("key2"), assertRoot + "#19");
            //Assert.False(stanza1.ContainsKey("key3"), assertRoot + "#20");

            // Add a couple of properties
            Argument args  = new Argument("key1", "value1");
            Argument args1 = new Argument("key2", "42");

            stanza1.UpdateAsync(args, args1).Wait();
            stanza1 = testconf.GetStanzaAsync("stanza1").Result;

            // Make sure the properties showed up
            ConfigurationSetting x = stanza1.GetSettingAsync("key1").Result;

//            Assert.Equal("value1", stanza1.GetSettingAsync("key1").Result.Value);
            Assert.Equal("42", stanza1.GetSettingAsync("key2").Result.Value);
            //Assert.False(stanza1.ContainsKey("key3"), assertRoot + "#23");

            //// Update an existing property
            args = new Argument("key1", "value2");
            stanza1.UpdateAsync(args, args1).Wait();

            // Make sure the updated property shows up (and no other changes).
            Assert.Equal("value2", stanza1.GetSettingAsync("key1").Result.Value);
            Assert.Equal("42", stanza1.GetSettingAsync("key2").Result.Value);
            //Assert.False(stanza1.ContainsKey("key3"), assertRoot + "#26");
            //Assert.True(stanza1.ContainsValue("value2"), "Expected stanza1 to contain the value value2");
            //Assert.True(stanza1.ContainsValue("42"), "Expected stanza1 to contain the value 42");

            // Delete the stanzas
            testconf.RemoveStanzaAsync("stanza3").Wait();
            Assert.Equal(3, testconf.Count);
            //Assert.True(stanzas.ContainsKey("stanza1"), assertRoot + "#28");
            //Assert.True(stanzas.ContainsKey("stanza2"), assertRoot + "#29");
            //Assert.False(stanzas.ContainsKey("stanza3"), assertRoot + "#30");

            //stanzas.Remove("stanza2");
            //Assert.Equal(1, stanzas.Size, assertRoot + "#31");
            //Assert.True(stanzas.ContainsKey("stanza1"), assertRoot + "#32");
            //Assert.False(stanzas.ContainsKey("stanza2"), assertRoot + "#33");
            //Assert.False(stanzas.ContainsKey("stanza3"), assertRoot + "#34");

            //stanzas.Remove("stanza1");
            //Assert.Equal(0, stanzas.Size, assertRoot + "#35");
            //Assert.False(stanzas.ContainsKey("stanza1"), assertRoot + "#36");
            //Assert.False(stanzas.ContainsKey("stanza2"), assertRoot + "#37");
            //Assert.False(stanzas.ContainsKey("stanza3"), assertRoot + "#38");

            // Cleanup after ourselves
            this.RemoveApp(app);
        }
        public async Task Configuration()
        {
            const string app = "sdk-tests"; // Provides a removable jail for the configuration changes we'll make

            using (var service = await SdkHelper.CreateService())
            {
                await service.Applications.RecreateAsync(app);

                await service.Server.RestartAsync(2 * 60 * 1000);
            }

            using (var service = await SdkHelper.CreateService(new Namespace(user: "******", app: app)))
            {
                ConfigurationCollection confs = service.Configurations;
                await confs.GetAllAsync();

                //// If this assesrt fails, remove the file C:\Program Files\Splunk\etc\system\local\testconf.conf.
                Assert.False(confs.Any(a => a.Name == "testconf"));

                Configuration testconf = await confs.CreateAsync("testconf");

                testconf = await confs.GetOrNullAsync("testconf");

                Assert.NotNull(testconf);

                ConfigurationStanza stanza1 = await testconf.CreateAsync("stanza1");

                ConfigurationStanza stanza2 = await testconf.CreateAsync("stanza2");

                ConfigurationStanza stanza3 = await testconf.CreateAsync("stanza3");

                await testconf.GetAllAsync();

                Assert.Equal(4, testconf.Count);
                Assert.NotNull(testconf.SingleOrDefault(conf => conf.Name == "default"));
                Assert.NotNull(testconf.SingleOrDefault(conf => conf.Name == stanza1.Name));
                Assert.NotNull(testconf.SingleOrDefault(conf => conf.Name == stanza2.Name));
                Assert.NotNull(testconf.SingleOrDefault(conf => conf.Name == stanza3.Name));

                //// Grab one of the new stanzas and check its content

                stanza1 = await testconf.GetAsync("stanza1");

                // Add a couple of properties

                await stanza1.UpdateAsync(
                    new Argument("key1", "string"),
                    new Argument("key2", (byte)2),
                    new Argument("key3", 'c'),
                    new Argument("key4", 4.00M),
                    new Argument("key5", 5.0),
                    new Argument("key6", 6.0F),
                    new Argument("key7", 7),
                    new Argument("key8", 8L),
                    new Argument("key9", stanza1),
                    new Argument("key10", (sbyte)10),
                    new Argument("key11", (uint)11),
                    new Argument("key12", (ulong)12));

                stanza1 = await testconf.GetAsync("stanza1");

                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key1" && setting.Value == "string"));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key2" && setting.Value == ((byte)2).ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key3" && setting.Value == 'c'.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key4" && setting.Value == 4.00M.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key5" && setting.Value == 5.0.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key6" && setting.Value == 6.0F.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key7" && setting.Value == 7.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key8" && setting.Value == 8L.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key9" && setting.Value == stanza1.ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key10" && setting.Value == ((sbyte)10).ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key11" && setting.Value == ((uint)11).ToString()));
                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key12" && setting.Value == ((ulong)12).ToString()));

                string value;

                value = await stanza1.GetAsync("key1");

                Assert.Equal("string", value);

                value = await stanza1.GetAsync("key2");

                Assert.Equal(((byte)2).ToString(), value);

                value = await stanza1.GetAsync("key3");

                Assert.Equal('c'.ToString(), value);

                value = await stanza1.GetAsync("key4");

                Assert.Equal(4.00M.ToString(), value);

                value = await stanza1.GetAsync("key5");

                Assert.Equal(5.0.ToString(), value);

                value = await stanza1.GetAsync("key6");

                Assert.Equal(6.0F.ToString(), value);

                value = await stanza1.GetAsync("key7");

                Assert.Equal(7.ToString(), value);

                value = await stanza1.GetAsync("key8");

                Assert.Equal(8L.ToString(), value);

                value = await stanza1.GetAsync("key9");

                Assert.Equal(stanza1.ToString(), value);

                value = await stanza1.GetAsync("key10");

                Assert.Equal(((sbyte)10).ToString(), value);

                value = await stanza1.GetAsync("key11");

                Assert.Equal(((uint)11).ToString(), value);

                value = await stanza1.GetAsync("key12");

                Assert.Equal(((ulong)12).ToString(), value);

                //// Update an existing setting

                bool updatedSnapshot = await stanza1.UpdateAsync(new Argument("key1", "value2"));

                Assert.False(updatedSnapshot);
                await stanza1.GetAsync();

                Assert.NotNull(stanza1.SingleOrDefault(setting => setting.Title == "key1" && setting.Value == "value2"));
                value = await stanza1.GetAsync("key1");

                Assert.Equal("value2", value);
                value = await stanza1.GetAsync("key1");

                Assert.Equal("value2", value);

                //// Remove the stanzas

                // Stanza 1
                await stanza1.RemoveAsync();

                await testconf.GetAllAsync(); // because remove gives no data back

                Assert.Equal(3, testconf.Count);
                Assert.NotNull(testconf.SingleOrDefault(stanza => stanza.Name == "default"));
                Assert.Null(testconf.SingleOrDefault(stanza => stanza.Name == "stanza1"));
                Assert.NotNull(testconf.SingleOrDefault(stanza => stanza.Name == "stanza2"));
                Assert.NotNull(testconf.SingleOrDefault(stanza => stanza.Name == "stanza3"));

                // Stanza 2
                await stanza2.RemoveAsync();

                await testconf.GetAllAsync(); // because remove gives no data back

                Assert.Equal(2, testconf.Count);
                Assert.NotNull(testconf.SingleOrDefault(stanza => stanza.Name == "default"));
                Assert.Null(testconf.SingleOrDefault(stanza => stanza.Name == "stanza1"));
                Assert.Null(testconf.SingleOrDefault(stanza => stanza.Name == "stanza2"));
                Assert.NotNull(testconf.SingleOrDefault(stanza => stanza.Name == "stanza3"));

                // Stanza 3
                await stanza3.RemoveAsync();

                await testconf.GetAllAsync(); // because remove gives no data back

                Assert.Equal(1, testconf.Count);
                Assert.NotNull(testconf.SingleOrDefault(stanza => stanza.Name == "default"));
                Assert.Null(testconf.SingleOrDefault(stanza => stanza.Name == "stanza1"));
                Assert.Null(testconf.SingleOrDefault(stanza => stanza.Name == "stanza2"));
                Assert.Null(testconf.SingleOrDefault(stanza => stanza.Name == "stanza3"));
            }

            using (var service = await SdkHelper.CreateService())
            {
                Assert.True(await service.Applications.RemoveAsync(app));
                await service.Server.RestartAsync(2 * 60 * 1000);
            }
        }