public async Task MultiQueryJSONIsolation() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" }, new InputQuery { InputQueryString = "SELECT * FROM HodorTest" }, new InputQuery { InputQueryString = "INSERT INTO HodorTest values('test', 890)" }, new InputQuery { InputQueryString = "DELETE FROM HodorTest WHERE value = 890" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties(), OutputToFile = false, }; var options = new QueryOptions { ThrowErrorOnFailure = true, IsolationLevel = Oracle_IsolationLevel.Serializable }; var result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); Assert.AreEqual(result.Results.First?["Output"]?.ToString(), "[\r\n {\r\n \"DECIMALVALUE\": 1.123456789123456789123456789\r\n }\r\n]"); Assert.AreEqual(true, result.Success); }
public async Task MultiQuerRollback() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "insert into DecimalTest(DecimalValue) values(10.6)" }, new InputQuery { InputQueryString = "SELECT * FROM foo" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties(), OutputToFile = true, OutputFile = new OutputFileProperties { Path = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString() + ".json") } }; var options = new QueryOptions { ThrowErrorOnFailure = true, IsolationLevel = Oracle_IsolationLevel.Serializable }; var result = new MultiQueryOutput(); try { result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); } catch (Exception) { } var multiQueryProperties2 = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" } }, ConnectionString = ConnectionString }; var outputProperties2 = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties() }; var options2 = new QueryOptions { ThrowErrorOnFailure = true }; var result2 = await OracleTasks.TransactionalMultiQuery(multiQueryProperties2, outputProperties2, options2, new CancellationToken()); Assert.That(() => OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()), Throws.TypeOf <OracleException>()); Assert.AreEqual(false, result.Success); Assert.AreNotEqual(2, result2.Results.Count); File.Delete(outputProperties.OutputFile.Path); }
public async Task MultiqueryShouldWriteXMLFile() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" }, new InputQuery { InputQueryString = "SELECT * FROM HodorTest" }, new InputQuery { InputQueryString = "INSERT INTO HodorTest values('test', 890)" }, new InputQuery { InputQueryString = "DELETE FROM HodorTest WHERE value = 890" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Xml, OutputToFile = true, XmlOutput = new XmlOutputProperties { RootElementName = "items", RowElementName = "item" }, OutputFile = new OutputFileProperties { Path = Path.Combine(outputDirectory, Guid.NewGuid().ToString() + ".json") } }; var options = new QueryOptions { ThrowErrorOnFailure = true }; var result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); Assert.IsTrue(File.Exists(outputProperties.OutputFile.Path)); Assert.IsTrue(File.ReadAllText(result.Results.First?["OutputPath"]?.ToString()).Contains("<DECIMALVALUE>1.12345678912345678912345678912345678</DECIMALVALUE>")); File.Delete(outputProperties.OutputFile.Path); }
public async Task MultiQueryJSON() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" }, new InputQuery { InputQueryString = "SELECT * FROM HodorTest" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties() }; var options = new QueryOptions { ThrowErrorOnFailure = true }; var result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); Assert.AreNotEqual("", result.Results); Assert.AreEqual(true, result.Success); }