public App() { //Validate configuration on AppSettings.cs has been changed if (AppSettings.account.StartsWith("your-cloudant") || AppSettings.username.StartsWith("your-cloudant") || AppSettings.password.StartsWith("your-cloudant")) { MainPage = new ConfigErrorPage("To run this sample, you must first modify AppSettings.cs to provide your Cloudant account."); } else { try { CloudantClient client = new CloudantClientBuilder(AppSettings.account) { username = AppSettings.username, password = AppSettings.password }.GetResult(); MainPage = new HomePage(client); } catch (Exception e) { MainPage = new ConfigErrorPage("Unable to create a CloudantClient. One or more account parameter in AppSettings.cs is incorrect. " + e.Message); } } }
public void BuilderStripsUserNameAndPassword() { var builder = new CloudantClientBuilder(new Uri("https://*****:*****@username.cloudant.com")); Assert.AreEqual("username", builder.username); Assert.AreEqual("password", builder.password); Assert.AreEqual(new Uri("https://username.cloudant.com"), builder.accountUri); }
public void TestClientCreationValidAccount() { //Test CloudantClient creation with valid accountUri CloudantClient testClient = null; Uri validUri = new Uri(string.Format("https://{0}", TestConstants.account)); Assert.DoesNotThrow(() => testClient = new CloudantClientBuilder(validUri).GetResult(), "Test failed while instantiationg a CloudantClient using a valid uri."); Assert.IsNotNull(testClient, "Test failed because client object must not be null after it has been built with a valid uri."); }
public void TestGreenPath() { //Test CloudantClient creation with valid parms. CloudantClient testClient = null; Assert.DoesNotThrow(() => testClient = new CloudantClientBuilder(TestConstants.account) { username = TestConstants.username, password = TestConstants.password }.GetResult(), "Test failed while instantiationg a CloudantClient using valid parameters."); Assert.IsNotNull(testClient, "Test failed because client object must not be null after it has been built with valid parms."); }
public void BuilderPassesThroughURIWithNoCreds() { var builder = new CloudantClientBuilder(new Uri("https://username.cloudant.com")); Assert.AreEqual(new Uri("https://username.cloudant.com"), builder.accountUri); }