text:
using System;
using System.Collections.Generic;
using System.Text;

namespace WoundifyShared
{
    public class Settings
    {
        // this class is a concrete implementation of the settings json file. It is converted automatically by copying WoundifyDefaultSettings.json to clipboard, then in Visual Studio: Edit->Paste Special->Paste JSON as Classes.
        // comments within the json file seem to be causing "object" data type where it should be a concrete type ("services", "response", ...). This needs looking into.

        public class Rootobject
        {
            public string version { get; set; }
            public int debugLevel { get; set; }
            public string tempFolderPath { get; set; }
            public string logFilePath { get; set; }
            public string curlFilePath { get; set; }
            public string curlDefaults { get; set; }
            public float pauseSecondsDefault { get; set; }
            public Audio audio { get; set; }
            public Command[] commands { get; set; }
            public Commandservice[] commandServices { get; set; }
            public Geolocaton geolocaton { get; set; }
            public Locale locale { get; set; }
            public Wakeup wakeup { get; set; }
            public Apis APIs { get; set; }
            public Service[] services { get; set; }
        }

        public class Audio
        {
            public string transCodeFileName { get; set; }
            public string speechSynthesisFileName { get; set; }
            public int bitDepth { get; set; }
            public int channels { get; set; }
            public int samplingRate { get; set; }
            public Naudio NAudio { get; set; }
        }

        public class Naudio
        {
            public int desiredLatencyMilliseconds { get; set; }
            public int inputDeviceNumber { get; set; }
            public int waveInBufferMilliseconds { get; set; }
        }

        public class Geolocaton
        {
            public float longitude { get; set; }
            public float latitude { get; set; }
            public int accuracyInMeters { get; set; }
            public string town { get; set; }
            public string region { get; set; }
            public string regionCode { get; set; }
            public string country { get; set; }
            public string countryCode { get; set; }
        }

        public class Locale
        {
            public string language { get; set; }
        }

        public class Wakeup
        {
            public float confidence { get; set; }
            public float endSilenceTimeout { get; set; }
            public int initialSilenceTimeout { get; set; }
            public float listenTimeOut { get; set; }
            public bool preferLoopUntilWakeUpWordFound { get; set; }
            public string[] words { get; set; }
        }

        public class Apis
        {
            public bool preferSystemNet { get; set; }
            public bool preferChunkedEncodedRequests { get; set; }
        }

        public class Command
        {
            public string key { get; set; }
            public string name { get; set; }
            public string classInterface { get; set; }
            public string help { get; set; }
            public string commandService { get; set; }
            public string source { get; set; }
            public string target { get; set; }
        }

        public class Commandservice
        {
            public string key { get; set; }
            public string name { get; set; }
            public string[] preferredServices { get; set; }
            public int voiceAge { get; set; }
            public int voiceGender { get; set; }
            public int sampleRate { get; set; }
        }

        public class Service
        {
            public string name { get; set; }
            public string classInterface { get; set; }
            public Request[] requests { get; set; }
        }

        public class Request
        {
            public string argType { get; set; }
            public string method { get; set; }
            public bool preferChunkedEncodedRequests { get; set; }
            public bool PartialTranscriptsDesired { get; set; }
            public Uri uri { get; set; }
            public Header[] headers { get; set; }
            public Data data { get; set; }
            public Response response { get; set; }
        }

        public class Uri
        {
            public string scheme { get; set; }
            public string host { get; set; }
            public string path { get; set; }
            public string query { get; set; }
        }

        public class Data
        {
            public string type { get; set; }
            public string value { get; set; }
            public string source { get; set; }
            public string target { get; set; }
        }

        public class Response
        {
            public string missingResponse { get; set; }
            public string jsonPath { get; set; }
            public string xpath { get; set; }
            public string jq { get; set; }
            public string type { get; set; }
        }

        public class Header
        {
            public string Name { get; set; }
            public string Generic { get; set; }
            public string OcpApimSubscriptionKey { get; set; }
            public BearerAuthentication BearerAuthentication { get; set; }
            public HoundifyAuthentication HoundifyAuthentication { get; set; }
            public BasicAuthentication BasicAuthentication { get; set; }
        }

        public class BearerAuthentication
        {
            public string type { get; set; }
            public string clientID { get; set; }
            public string clientSecret { get; set; }
            public string uri { get; set; }
            public string grant { get; set; }
            public string key { get; set; }
            public string bearer { get; set; }
        }

        public class HoundifyAuthentication
        {
            public string ClientID { get; set; }
            public string ClientKey { get; set; }
            public string UserID { get; set; }
        }

        public class BasicAuthentication
        {
            public string type { get; set; }
            public string username { get; set; }
            public string password { get; set; }
        }

    }
}


text:
#include "config.h"
#include "modules/webdatabase/SQLStatementSync.h"

#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/platform/sql/SQLValue.h"
#include "core/platform/sql/SQLiteDatabase.h"
#include "core/platform/sql/SQLiteStatement.h"
#include "modules/webdatabase/DatabaseSync.h"
#include "modules/webdatabase/SQLError.h"
#include "modules/webdatabase/SQLResultSet.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"

namespace WebCore {

SQLStatementSync::SQLStatementSync(const String& statement, const Vector<SQLValue>& arguments, int permissions)
    : m_statement(statement)
    , m_arguments(arguments)
    , m_permissions(permissions)
{
    ASSERT(!m_statement.isEmpty());
}

PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionState& es)
{
    db->setAuthorizerPermissions(m_permissions);

    SQLiteDatabase* database = &db->sqliteDatabase();

    SQLiteStatement statement(*database, m_statement);
    int result = statement.prepare();
    if (result != SQLResultOk) {
        if (result == SQLResultInterrupt)
            es.throwDOMException(SQLDatabaseError);
        else
            es.throwDOMException(SyntaxError, SQLError::syntaxErrorMessage);
        db->setLastErrorMessage("could not prepare statement", result, database->lastErrorMsg());
        return 0;
    }

    if (statement.bindParameterCount() != m_arguments.size()) {
        if (db->isInterrupted())
            es.throwDOMException(SQLDatabaseError);
        else
            es.throwDOMException(SyntaxError, SQLError::syntaxErrorMessage);
        db->setLastErrorMessage("number of '?'s in statement string does not match argument count");
        return 0;
    }

    for (unsigned i = 0; i < m_arguments.size(); ++i) {
        result = statement.bindValue(i + 1, m_arguments[i]);
        if (result == SQLResultFull) {
            es.throwDOMException(QuotaExceededError, SQLError::quotaExceededErrorMessage);
            db->setLastErrorMessage("there was not enough remaining storage space");
            return 0;
        }

        if (result != SQLResultOk) {
            es.throwDOMException(SQLDatabaseError);
            db->setLastErrorMessage("could not bind value", result, database->lastErrorMsg());
            return 0;
        }
    }

    RefPtr<SQLResultSet> resultSet = SQLResultSet::create();

    // Step so we can fetch the column names.
    result = statement.step();
    if (result == SQLResultRow) {
        int columnCount = statement.columnCount();
        SQLResultSetRowList* rows = resultSet->rows();

        for (int i = 0; i < columnCount; i++)
            rows->addColumn(statement.getColumnName(i));

        do {
            for (int i = 0; i < columnCount; i++)
                rows->addResult(statement.getColumnValue(i));

            result = statement.step();
        } while (result == SQLResultRow);

        if (result != SQLResultDone) {
            es.throwDOMException(SQLDatabaseError);
            db->setLastErrorMessage("could not iterate results", result, database->lastErrorMsg());
            return 0;
        }
    } else if (result == SQLResultDone) {
        // Didn't find anything, or was an insert.
        if (db->lastActionWasInsert())
            resultSet->setInsertId(database->lastInsertRowID());
    } else if (result == SQLResultFull) {
        // Quota error, the delegate will be asked for more space and this statement might be re-run.
        es.throwDOMException(QuotaExceededError, SQLError::quotaExceededErrorMessage);
        db->setLastErrorMessage("there was not enough remaining storage space");
        return 0;
    } else if (result == SQLResultConstraint) {
        es.throwDOMException(ConstraintError, "A constraint was violated.");
        db->setLastErrorMessage("statement failed due to a constraint failure");
        return 0;
    } else {
        es.throwDOMException(SQLDatabaseError);
        db->setLastErrorMessage("could not execute statement", result, database->lastErrorMsg());
        return 0;
    }

    resultSet->setRowsAffected(database->lastChanges());
    return resultSet.release();
}

} // namespace WebCore

redpajama_set_name: RedPajamaGithub


text:
#region license
// Copyright (c) 2005 - 2007 Ayende Rahien (ayende@ayende.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Ayende Rahien nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

using System;
using Xunit;
using Rhino.Mocks.Exceptions;

namespace Rhino.Mocks.Tests
{

    public class WithTestFixture
    {
        [Fact]
        public void SetupMyOwnRepository()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();
            With.Mocks(mocks,delegate
            {
                Expect.Call(demo.ReturnStringNoArgs()).Return("Hi");
                Mocker.Current.ReplayAll();
                Assert.Equal("Hi", demo.ReturnStringNoArgs());
            });
        }
        [Fact]
        public void UsingTheWithMocksConstruct()
        {
            With.Mocks(new MockRepository(),delegate
            {
                IDemo demo = Mocker.Current.StrictMock<IDemo>();
                Expect.Call(demo.ReturnIntNoArgs()).Return(5);
                Mocker.Current.ReplayAll();
                Assert.Equal(5, demo.ReturnIntNoArgs());
            });
        }

    	[Fact]
		public void CannotUseMockerOutsideOfWithMocks()
    	{
    		Assert.Throws<InvalidOperationException>(
    			"You cannot use Mocker.Current outside of a With.Mocks block",
    			() => GC.KeepAlive(Mocker.Current));

    	}

    	[Fact]
        public void UsingTheWithMocksConstruct_ThrowsIfExpectationIsMissed()
        {
    		Assert.Throws<ExpectationViolationException>("IDemo.ReturnIntNoArgs(); Expected #1, Actual #0.",
    		                                             () =>

    		                                             With.Mocks(delegate
    		                                             {
    		                                             	IDemo demo = Mocker.Current.StrictMock<IDemo>();
    		                                             	Expect.Call(demo.ReturnIntNoArgs()).Return(5);
    		                                             	Mocker.Current.ReplayAll();
    		                                             }));
        }

        [Fact]
        public void UsingTheWithMocksConstruct_ThrowsIfReplayAllNotCalled()
        {
        	Assert.Throws<InvalidOperationException>(
        		"This action is invalid when the mock object {Rhino.Mocks.Tests.IDemo} is in record state.",
        		() =>
        		{
        			With.Mocks(delegate
        			{
        				IDemo demo = Mocker.Current.StrictMock<IDemo>();
        				Expect.Call(demo.ReturnIntNoArgs()).Return(5);
        			});
        		});
        }

        [Fact]
        public void UsingTheWithMocksConstruct_GiveCorrectExceptionWhenMocking()
        {
        	Assert.Throws<IndexOutOfRangeException>("foo", () =>
        	{
        		With.Mocks(delegate
        		{
        			IDemo demo = Mocker.Current.StrictMock<IDemo>();
        			Expect.Call(demo.ReturnIntNoArgs()).Return(5);
        			Mocker.Current.ReplayAll();
        			throw new IndexOutOfRangeException("foo");
        		});
        	});
        }

        [Fact]
        public void UsingTheWithMocksConstruct_GiveCorrectExceptionWhenMockingEvenIfReplayAllNotCalled()
        {
        	Assert.Throws<IndexOutOfRangeException>("foo", () =>
        	                                               With.Mocks(delegate
        	                                               {
        	                                               	IDemo demo = Mocker.Current.StrictMock<IDemo>();
        	                                               	Expect.Call(demo.ReturnIntNoArgs()).Return(5);
        	                                               	throw new IndexOutOfRangeException("foo");
        	                                               }));
        }

        [Fact]
        public void UsingTheWithMocksExceptingVerifyConstruct()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();

            With.Mocks(mocks)
            .Expecting(delegate
            {
                Expect.Call(demo.ReturnIntNoArgs()).Return(5);
            })
            .Verify(delegate
            {
                Assert.Equal(5, demo.ReturnIntNoArgs());
            });
        }

        [Fact]
        public void UsingTheWithMocksExceptingVerifyConstruct_ThrowsIfExpectationIsMissed()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();

        	Assert.Throws<ExpectationViolationException>("IDemo.ReturnIntNoArgs(); Expected #1, Actual #0.",
        	                                             () =>
        	                                             With.Mocks(mocks)
        	                                             	.Expecting(delegate
        	                                             	{
        	                                             		Expect.Call(demo.ReturnIntNoArgs()).Return(5);
        	                                             	})
        	                                             	.Verify(delegate
        	                                             	{
        	                                             	}));
        }

        [Fact]
        public void UsingTheWithMocksExceptingVerifyConstruct_GiveCorrectExceptionWhenMocking()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();

        	Assert.Throws<IndexOutOfRangeException>("foo", () =>
        	                                               With.Mocks(mocks)
        	                                               	.Expecting(delegate
        	                                               	{
        	                                               		Expect.Call(demo.ReturnIntNoArgs()).Return(5);
        	                                               	})
        	                                               	.Verify(delegate
        	                                               	{
        	                                               		throw new IndexOutOfRangeException("foo");
        	                                               	}));
        }

        [Fact]
        public void UsingTheWithMocksExceptingInSameOrderVerifyConstruct_ShouldTakeCareOfOrder()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.StrictMock<IDemo>();
            bool verificationFailed;

            try
            {
                With.Mocks(mocks).ExpectingInSameOrder(delegate
                {
                    Expect.Call(demo.ReturnIntNoArgs()).Return(1);
                    Expect.Call(demo.ReturnStringNoArgs()).Return("2");
                })
                .Verify(delegate
                {
                    demo.ReturnStringNoArgs();
                    demo.ReturnIntNoArgs();
                });
                verificationFailed = false;
            }
            catch (ExpectationViolationException)
            {
                verificationFailed = true;
            }

            Assert.True(verificationFailed,
                "Verification was supposed to fail, because the mocks are called in the wrong order");
        }
    }
}