public void Setup() { DBName = TestConstants.defaultDatabaseName + DateTime.Now.Ticks; client = new CloudantClientBuilder(TestConstants.account) { username = TestConstants.username, password = TestConstants.password }.GetResult(); // create the database try { db = client.Database(DBName); db.EnsureExistsAsync().Wait(); Assert.NotNull(db); } catch (AggregateException ae) { Assert.Fail("Create remote database failed. Cause: " + ae.Message); } catch (Exception e) { Assert.Fail("Unexpected failure: " + e.Message); } }
public void FixtureSetUp() { client = new CloudantClientBuilder(TestConstants.account) { username = TestConstants.username, password = TestConstants.password }.GetResult(); }
/// <summary> /// Initializes a new instance of the <see cref="IBM.Cloudant.Client.Database"/> class. /// </summary> /// <param name="client">The CloudantClient instance.</param> /// <param name="name">The name of the database.</param> public Database(CloudantClient client, String name) { //validate the dbName Regex strPattern = new Regex("^[a-z][a-z0-9_" + Regex.Escape("$") + Regex.Escape("(") + Regex.Escape(")") + Regex.Escape("+") + Regex.Escape("/") + "-]*$"); if (!strPattern.IsMatch(name)) { throw new ArgumentException("A database must be named with all lowercase letters (a-z), digits (0-9)," + " or any of the _$()+-/ characters. The name has to start with a lowercase letter (a-z). "); } this.client = client; dbname = name; dbNameUrlEncoded = WebUtility.UrlEncode(name); }
public void testBasicAuthInterceptor() { BasicAuthenticationInterceptor basicAuthInterceptor = new BasicAuthenticationInterceptor(TestConstants.username, TestConstants.password); client = new CloudantClientBuilder(TestConstants.account) { interceptors = new List<IHttpConnectionInterceptor>(){ basicAuthInterceptor } }.GetResult(); db = client.Database(DBName); Assert.DoesNotThrow(async () => { await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false); }, "Exception thrown while creating database using BasicAuth interceptor. "); Assert.NotNull(db); }
/// <summary> /// Initializes a new instance of the <see cref="CrossPlatformSample.HomePage"/> class. /// </summary> /// <param name="client">Valid CloudantClient object initialized with the account information.</param> public HomePage(CloudantClient client) { this.client = client; //List of sample items. List<CommandItem> items = new List<CommandItem> { new CommandItem { Title = " 1. Create Database", ItemSelected = OnCreateDB }, new CommandItem { Title = " 2. Save Document", ItemSelected = OnSaveDocument }, new CommandItem { Title = " 3. Retrieve Document", ItemSelected = OnRetrieveDocument }, new CommandItem { Title = " 4. Update Document", ItemSelected = OnUpdateDocument }, new CommandItem { Title = " 5. Create Index", ItemSelected = OnCreateIndex }, new CommandItem { Title = " 6. List Indexes", ItemSelected = OnListIndexes }, new CommandItem { Title = " 7. Query Index", ItemSelected = OnQuery }, new CommandItem { Title = " 8. Delete Index", ItemSelected = OnDeleteIndex }, new CommandItem { Title = " 9. Delete Database", ItemSelected = OnDeleteDB } }; InitializeUserInterface(items); }
public void setup() { client = new CloudantClientBuilder(TestConstants.account) { username = TestConstants.username, password = TestConstants.password }.GetResult(); string DBName = "httphelpertests" + DateTime.Now.Ticks; db = client.Database(DBName); db.EnsureExistsAsync().Wait(); }