public static void TemporaryStoreAsync_GivenInvalidTemporaryStoreLocationValue_ThrowsArgumentException() { var connection = CreateConnectionFactory(); var connPragma = CreateConnectionPragma(connection); const TemporaryStoreLocation tempStore = (TemporaryStoreLocation)55; Assert.That(() => connPragma.TemporaryStoreAsync(tempStore), Throws.ArgumentException); }
/// <summary> /// Creates a query that sets the temporary store pragma. /// </summary> /// <param name="tempLocation">The temporary location.</param> /// <returns>A SQL query.</returns> /// <exception cref="ArgumentException"><paramref name="tempLocation"/> is an invalid enum.</exception> protected virtual string TemporaryStoreSetQuery(TemporaryStoreLocation tempLocation) { if (!tempLocation.IsValid()) { throw new ArgumentException($"The { nameof(TemporaryStoreLocation) } provided must be a valid enum.", nameof(tempLocation)); } var value = tempLocation.ToString().ToUpperInvariant(); return(PragmaPrefix + "temp_store = " + value); }
/// <summary> /// Sets the temporary storage location. /// </summary> /// <param name="tempLocation">The temporary location.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A task indicating the completion of this query.</returns> public Task TemporaryStoreAsync(TemporaryStoreLocation tempLocation, CancellationToken cancellationToken = default) => DbConnection.ExecuteAsync(TemporaryStoreSetQuery(tempLocation), cancellationToken);