text:
#ifndef _SUNDIALS_LAPACK_H
#define _SUNDIALS_LAPACK_H

#include <sundials/sundials_types.h>

#ifdef __cplusplus  /* wrapper to enable C++ usage */
extern "C" {
#endif

/*
 * ==================================================================
 * Blas and Lapack functions
 * ==================================================================
 */

#if defined(SUNDIALS_F77_FUNC)

#define dcopy_f77       SUNDIALS_F77_FUNC(dcopy, DCOPY)
#define dscal_f77       SUNDIALS_F77_FUNC(dscal, DSCAL)
#define dgemv_f77       SUNDIALS_F77_FUNC(dgemv, DGEMV)
#define dtrsv_f77       SUNDIALS_F77_FUNC(dtrsv, DTRSV)
#define dsyrk_f77       SUNDIALS_F77_FUNC(dsyrk, DSKYR)

#define dgbtrf_f77      SUNDIALS_F77_FUNC(dgbtrf, DGBTRF)
#define dgbtrs_f77      SUNDIALS_F77_FUNC(dgbtrs, DGBTRS)
#define dgetrf_f77      SUNDIALS_F77_FUNC(dgetrf, DGETRF)
#define dgetrs_f77      SUNDIALS_F77_FUNC(dgetrs, DGETRS)
#define dgeqp3_f77      SUNDIALS_F77_FUNC(dgeqp3, DGEQP3)
#define dgeqrf_f77      SUNDIALS_F77_FUNC(dgeqrf, DGEQRF)
#define dormqr_f77      SUNDIALS_F77_FUNC(dormqr, DORMQR)
#define dpotrf_f77      SUNDIALS_F77_FUNC(dpotrf, DPOTRF)
#define dpotrs_f77      SUNDIALS_F77_FUNC(dpotrs, DPOTRS)

#define scopy_f77       SUNDIALS_F77_FUNC(scopy, SCOPY)
#define sscal_f77       SUNDIALS_F77_FUNC(sscal, SSCAL)
#define sgemv_f77       SUNDIALS_F77_FUNC(sgemv, SGEMV)
#define strsv_f77       SUNDIALS_F77_FUNC(strsv, STRSV)
#define ssyrk_f77       SUNDIALS_F77_FUNC(ssyrk, SSKYR)

#define sgbtrf_f77      SUNDIALS_F77_FUNC(sgbtrf, SGBTRF)
#define sgbtrs_f77      SUNDIALS_F77_FUNC(sgbtrs, SGBTRS)
#define sgetrf_f77      SUNDIALS_F77_FUNC(sgetrf, SGETRF)
#define sgetrs_f77      SUNDIALS_F77_FUNC(sgetrs, SGETRS)
#define sgeqp3_f77      SUNDIALS_F77_FUNC(sgeqp3, SGEQP3)
#define sgeqrf_f77      SUNDIALS_F77_FUNC(sgeqrf, SGEQRF)
#define sormqr_f77      SUNDIALS_F77_FUNC(sormqr, SORMQR)
#define spotrf_f77      SUNDIALS_F77_FUNC(spotrf, SPOTRF)
#define spotrs_f77      SUNDIALS_F77_FUNC(spotrs, SPOTRS)

#else

#define dcopy_f77       dcopy_
#define dscal_f77       dscal_
#define dgemv_f77       dgemv_
#define dtrsv_f77       dtrsv_
#define dsyrk_f77       dsyrk_

#define dgbtrf_f77      dgbtrf_
#define dgbtrs_f77      dgbtrs_
#define dgeqp3_f77      dgeqp3_
#define dgeqrf_f77      dgeqrf_
#define dgetrf_f77      dgetrf_
#define dgetrs_f77      dgetrs_
#define dormqr_f77      dormqr_
#define dpotrf_f77      dpotrf_
#define dpotrs_f77      dpotrs_

#define scopy_f77       scopy_
#define sscal_f77       sscal_
#define sgemv_f77       sgemv_
#define strsv_f77       strsv_
#define ssyrk_f77       ssyrk_

#define sgbtrf_f77      sgbtrf_
#define sgbtrs_f77      sgbtrs_
#define sgeqp3_f77      sgeqp3_
#define sgeqrf_f77      sgeqrf_
#define sgetrf_f77      sgetrf_
#define sgetrs_f77      sgetrs_
#define sormqr_f77      sormqr_
#define spotrf_f77      spotrf_
#define spotrs_f77      spotrs_

#endif

/* Level-1 BLAS */

extern void dcopy_f77(sunindextype *n, const double *x,
                      const sunindextype *inc_x, double *y,
                      const sunindextype *inc_y);

extern void dscal_f77(sunindextype *n, const double *alpha, double *x,
                      const sunindextype *inc_x);

extern void scopy_f77(sunindextype *n, const float *x,
                      const sunindextype *inc_x, float *y,
                      const sunindextype *inc_y);

extern void sscal_f77(sunindextype *n, const float *alpha, float *x,
                      const sunindextype *inc_x);

/* Level-2 BLAS */

extern void dgemv_f77(const char *trans, sunindextype *m, sunindextype *n,
                      const double *alpha, const double *a, sunindextype *lda,
                      const double *x, sunindextype *inc_x, const double *beta,
                      double *y, sunindextype *inc_y);

extern void dtrsv_f77(const char *uplo, const char *trans, const char *diag,
                      const sunindextype *n, const double *a,
                      const sunindextype *lda, double *x,
                      const sunindextype *inc_x);

extern void sgemv_f77(const char *trans, sunindextype *m, sunindextype *n,
                      const float *alpha, const float *a, sunindextype *lda,
                      const float *x, sunindextype *inc_x, const float *beta,
                      float *y, sunindextype *inc_y);

extern void strsv_f77(const char *uplo, const char *trans, const char *diag,
                      const sunindextype *n, const float *a,
                      const sunindextype *lda, float *x,
                      const sunindextype *inc_x);

/* Level-3 BLAS */

extern void dsyrk_f77(const char *uplo, const char *trans,
                      const sunindextype *n, const sunindextype *k,
                      const double *alpha, const double *a,
                      const sunindextype *lda, const double *beta,
                      const double *c, const sunindextype *ldc);

extern void ssyrk_f77(const char *uplo, const char *trans,
                      const sunindextype *n, const sunindextype *k,
                      const float *alpha, const float *a,
                      const sunindextype *lda, const float *beta,
                      const float *c, const sunindextype *ldc);

/* LAPACK */

extern void dgbtrf_f77(const sunindextype *m, const sunindextype *n,
                       const sunindextype *kl, const sunindextype *ku,
                       double *ab, sunindextype *ldab, sunindextype *ipiv,
                       sunindextype *info);

extern void dgbtrs_f77(const char *trans, const sunindextype *n,
                       const sunindextype *kl, const sunindextype *ku,
                       const sunindextype *nrhs, double *ab,
                       const sunindextype *ldab, sunindextype *ipiv,
                       double *b, const sunindextype *ldb, sunindextype *info);

extern void dgeqp3_f77(const sunindextype *m, const sunindextype *n, double *a,
                       const sunindextype *lda, sunindextype *jpvt, double *tau,
                       double *work, const sunindextype *lwork,
                       sunindextype *info);

extern void dgeqrf_f77(const sunindextype *m, const sunindextype *n, double *a,
                       const sunindextype *lda, double *tau, double *work,
                       const sunindextype *lwork, sunindextype *info);

extern void dgetrf_f77(const sunindextype *m, const sunindextype *n, double *a,
                       sunindextype *lda, sunindextype *ipiv,
                       sunindextype *info);

extern void dgetrs_f77(const char *trans, const sunindextype *n,
                       const sunindextype *nrhs, double *a,
                       const sunindextype *lda, sunindextype *ipiv, double *b,
                       const sunindextype *ldb, sunindextype *info);

extern void dormqr_f77(const char *side, const char *trans,
                       const sunindextype *m, const sunindextype *n,
                       const sunindextype *k, double *a,
                       const sunindextype *lda, double *tau, double *c,
                       const sunindextype *ldc, double *work,
                       const sunindextype *lwork, sunindextype *info);

extern void dpotrf_f77(const char *uplo, const sunindextype *n, double *a,
                       sunindextype *lda, sunindextype *info);

extern void dpotrs_f77(const char *uplo, const sunindextype *n,
                       const sunindextype *nrhs, double *a,
                       const sunindextype *lda, double *b,
                       const sunindextype *ldb, sunindextype *info);

extern void sgbtrf_f77(const sunindextype *m, const sunindextype *n,
                       const sunindextype *kl, const sunindextype *ku,
                       float *ab, sunindextype *ldab, sunindextype *ipiv,
                       sunindextype *info);

extern void sgbtrs_f77(const char *trans, const sunindextype *n,
                       const sunindextype *kl, const sunindextype *ku,
                       const sunindextype *nrhs, float *ab,
                       const sunindextype *ldab, sunindextype *ipiv,
                       float *b, const sunindextype *ldb, sunindextype *info);

extern void sgeqp3_f77(const sunindextype *m, const sunindextype *n, float *a,
                       const sunindextype *lda, sunindextype *jpvt, float *tau,
                       float *work, const sunindextype *lwork,
                       sunindextype *info);

extern void sgeqrf_f77(const sunindextype *m, const sunindextype *n, float *a,
                       const sunindextype *lda, float *tau, float *work,
                       const sunindextype *lwork, sunindextype *info);

extern void sgetrf_f77(const sunindextype *m, const sunindextype *n, float *a,
                       sunindextype *lda, sunindextype *ipiv,
                       sunindextype *info);

extern void sgetrs_f77(const char *trans, const sunindextype *n,
                       const sunindextype *nrhs, float *a,
                       const sunindextype *lda, sunindextype *ipiv,
                       float *b, const sunindextype *ldb, sunindextype *info);

extern void sormqr_f77(const char *side, const char *trans,
                       const sunindextype *m, const sunindextype *n,
                       const sunindextype *k, float *a, const sunindextype *lda,
                       float *tau, float *c, const sunindextype *ldc,
                       float *work, const sunindextype *lwork,
                       sunindextype *info);

extern void spotrf_f77(const char *uplo, const sunindextype *n, float *a,
                       sunindextype *lda, sunindextype *info);

extern void spotrs_f77(const char *uplo, const sunindextype *n,
                       const sunindextype *nrhs, float *a,
                       const sunindextype *lda, float *b,
                       const sunindextype *ldb, sunindextype *info);

#ifdef __cplusplus
}
#endif

#endif


text:
<?php
declare(strict_types = 1);

namespace Innmind\Neo4j\ONM\Exception;

interface Exception extends \Throwable
{
}

redpajama_set_name: RedPajamaGithub


text:
define({
  "_widgetLabel": "Uređivač atributa serije",
  "widgetIntroSelectByArea": "Upotrijebite jedan od alata u nastavku da biste stvorili odabrani skup geoobjekata za ažuriranje.  Ako je redak istaknut, premašen je maksimalni broj zapisa.",
  "widgetIntroSelectByFeature": "Upotrijebite alat u nastavku za odabir geoobjekta sa sloja ${0}.  Upotrebljavat će se ovaj geoobjekt. Odaberite i ažurirajte sve geoobjekte koje se presijecaju.  Ako je redak istaknut, premašen je maksimalni broj zapisa.",
  "widgetIntroSelectByFeatureQuery": "Upotrijebite alat u nastavku za odabir geoobjekta sa sloja ${0} .  Atribut ${1} ovog geoobjekta upotrebljavat će se za ispitivanje slojeva u nastavku i ažuriranje dobivenih geoobjekata.  Ako je redak istaknut, premašen je maksimalni broj zapisa.",
  "widgetIntroSelectByQuery": "Unesite vrijednost da biste stvorili skup odabira.  Ako je redak istaknut, premašen je maksimalni broj zapisa.",
  "layerTable": {
    "colLabel": "Naziv sloja",
    "numSelected": "#",
    "colSyncStatus": ""
  },
  "noConfiguredLayers": "Nema konfiguriranih slojeva koji se mogu uređivati",
  "editorPopupTitle": "Uređivač atributa serije",
  "editorPopupSaveBtn": "Spremi",
  "editorPopupMultipleValues": "",
  "clear": "Očisti",
  "featuresUpdated": "${0} / ${1} geoobjek(a)t(a) ažurirano",
  "featuresSelected": "${0} geoobjek(a)t(a) odabrano",
  "featuresSkipped": "Zaobiđeno",
  "search": "Pretraži",
  "queryInput": "Unesite vrijednost za upit",
  "noFilterTip": "Ako izraz za filtar nije definiran, ovaj zadatak upita izlistat će sve geoobjekte u određenom izvoru podataka.",
  "setFilterTip": "Ispravno postavite filtar.",
  "filterPopup": "Sloj za filtriranje",
  "cancel": "Odustani",
  "noValue": "Nema vrijednosti",
  "emptyString": "Prazan tekst",
  "existingValue": "Zadrži postojeću vrijednost",
  "newDate": "Novi datum",
  "valueChooser": "Odaberite/upišite vrijednost",
  "ok": "U redu",
  "drawBox": {
    "point": "Točka",
    "line": "Linija",
    "polyline": "Polilinija",
    "freehandPolyline": "Prostoručna polilinija",
    "extent": "Obuhvat",
    "polygon": "Poligon",
    "freehandPolygon": "Prostoručni poligon",
    "clear": "Očisti",
    "addPointToolTip": "Kliknite za odabir u ovom području",
    "addShapeToolTip": "Nacrtajte oblik da biste odabrali geoobjekt",
    "freehandToolTip": "Pritisnite i držite da biste nacrtali oblik za odabir geoobjekta",
    "startToolTip": "Nacrtajte oblik da biste odabrali geoobjekt"
  },
  "errors": {
    "layerNotFound": "Sloj ${0} s ID-om ${1} nije pronađen na karti, karta se možda promijenila od konfiguracije widgeta",
    "queryNullID": "Geoobjekt s ${0} vratio je nevažeći ID",
    "noSelectedLayers": "Nema odabranih slojeva sa zapisima koje treba ažurirati",
    "inputValueError": "Nevažeća vrijednost u obliku",
    "saveError": "Nije moguće spremiti ${0} geoobjekte, pojedinosti su dodane na konzolu",
    "requiredValue": "Obvezna vrijednost"
  }
});


text:
package in.arjsna.audiorecorder.di.scopes;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.inject.Scope;

/**
 * Created by arjun on 12/1/17.
 */

@Scope @Retention(RetentionPolicy.RUNTIME) public @interface FragmentScope {
}


text:
'use strict';

var clientFromConnectionString = require('azure-iot-device-mqtt').clientFromConnectionString;
var Message = require('azure-iot-device').Message;

// String containing hostname, gateway host name, device ID, device key in the following format:
//  "HostName=<iothub_hostname>;GatewayHostName=<gateway_hostname>;DeviceId=<device_id>;SharedAccessKey=<device_key>"
var connectionString = '[IoT Hub device connection string]';

var client = clientFromConnectionString(connectionString);

client.open(function () {
  // Create a message and send it to the IoT Hub every second
  setInterval(function () {
    var windSpeed = 10 + (Math.random() * 4); // range: [10, 14]
    var data = JSON.stringify({
      deviceId: 'myFirstDevice',
      windSpeed: windSpeed
    });
    var message = new Message(data);
    message.properties.add('myproperty', 'myvalue');
    console.log('Sending message: ' + message.getData());
    client.sendEvent(message);
  }, 1000);

  // Monitor messages from IoT Hub and print them in the console.
  client.receive(function (err, msg) {
    if (err) {
      console.error(err);
    } else {
      console.log('Received data: ' + msg.toString());
    }
  });
});


text:
<?php
/**
 * Created by PhpStorm.
 * User: bill
 * Date: 05.03.15
 * Time: 14:25
 */
use app\tests\codeception\_pages\mobile\number\IndexPage;
/* @var $scenario Codeception\Scenario */

$I = new AcceptanceTester($scenario);
$waitTime = 3;
$I->wantTo('ensure that searching Number models works');
$indexPage = IndexPage::openBy($I);

$I->amGoingTo('input mobile number');
$I->fillField('#searchTextInput','111');
$I->wait($waitTime);
$I->seeLink('1111111111');
$I->dontSeeLink('2222222222');
$I->dontSeeLink('3333333333');
$I->click('Сброс');

$I->amGoingTo('input employee name');
$I->fillField('#searchTextInput','пет');
$I->wait($waitTime);
$I->seeLink('3333333333');
$I->dontSeeLink('1111111111');
$I->dontSeeLink('2222222222');
$I->click('Сброс');

$I->amGoingTo('input no existing data');
$I->fillField('#searchTextInput','Я устал писать тесты !!!');
$I->wait($waitTime);
$I->see("Ничего не найдено.");
$I->click('Сброс');

$I->amGoingTo('choose mobile operator');
$indexPage->expandSearchParameters();
$I->selectOption('select','Оператор 1');
$I->wait($waitTime);
$I->seeLink('1111111111');
$I->seeLink('3333333333');
$I->dontSeeLink('2222222222');
$I->click('Сброс');

$I->amGoingTo('input comment for number');
$indexPage->expandSearchParameters();
$I->fillField('#numberCommentInput','1111111111');
$I->wait($waitTime);
$I->seeLink('1111111111');
$I->dontSeeLink('2222222222');
$I->dontSeeLink('3333333333');
$I->click('Сброс');

$I->amGoingTo('input combine search filters');
$indexPage->expandSearchParameters();
$I->fillField('#searchTextInput','Иванов');
$I->selectOption('select','Оператор 2');
$I->wait($waitTime);
$I->seeLink('2222222222');
$I->dontSeeLink('1111111111');
$I->dontSeeLink('3333333333');

$I->fillField('#numberCommentInput','111');
$I->wait($waitTime);
$I->see("Ничего не найдено.");

$I->selectOption('select','Оператор 1');
$I->wait($waitTime);
$I->seeLink('1111111111');
$I->dontSeeLink('2222222222');
$I->dontSeeLink('3333333333');


text:
@interface HelperMethods :  UIViewController
+(void) addAlert: (NSString*) message;
+(void) setPageTitle: (UIViewController*) page andTitle: (NSString*) title;
+(void) setSackBarButtonText: (UIViewController*) page andText: (NSString*) text;
+(NSDate*)getDateFromString: (NSString*) dateAsString;
+(NSString*)getShortDateString: (NSDate*) date;
+(UILabel *)resizeLabel:(UILabel*)label andText: (NSString*)text andTarget: (UIView*)view;
@end


text:
package org.diirt.vtype.next;

/**
 * Scalar number with alarm, timestamp, display and control information.
 * <p>
 * This class allows to use any scalar number (i.e. {@link VInt} or
 * {@link VDouble}) through the same interface.
 *
 * @author carcassi
 */
public abstract class VNumber extends Scalar implements DisplayProvider {

    /**
     * The numeric value.
     *
     * @return the value
     */
    @Override
    public abstract Number getValue();

    /**
     * Default toString implementation for VNumber.
     *
     * @return the string representation
     */
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        Class type = typeOf(this);
        builder.append(type.getSimpleName())
                .append('[')
                .append(getValue())
                .append(" ,")
                .append(getAlarm())
                .append(", ")
                .append(getTime())
                .append(']');
        return builder.toString();
    }

    /**
     * Creates a new VNumber based on the type of the data
     *
     * @param value the value
     * @param alarm the alarm
     * @param time the time
     * @param display the display
     * @return the new number
     */
    public static VNumber create(Number value, Alarm alarm, Time time, Display display){
        if (value instanceof Double) {
            return VDouble.create((Double) value, alarm, time, display);
        } else if (value instanceof Float) {
            return VFloat.create((Float) value, alarm, time, display);
        } else if (value instanceof Long) {
            return VLong.create((Long) value, alarm, time, display);
        } else if (value instanceof Integer) {
            return VInt.create((Integer) value, alarm, time, display);
        } else if (value instanceof Short) {
            return VShort.create((Short) value, alarm, time, display);
        } else if (value instanceof Byte) {
            return VByte.create((Byte) value, alarm, time, display);
        }
        throw new IllegalArgumentException("Only standard Java implementations of Number are supported");
    }

}


text:
import type {
	HeaderFooter,
	NavButton,
	NavButtonEventHandler,
	Notice,
	View,
	ViewControllerArgs
} from "controllers";
import type {
	SinonFakeTimers,
	SinonSpy,
	SinonStub
} from "sinon";
import ApplicationController from "../../../src/controllers/application-controller";
import SettingMock from "mocks/setting-model-mock";
import SyncMock from "mocks/sync-model-mock";
import TestController from "mocks/test-controller";
import WindowMock from "mocks/window-mock";
import sinon from "sinon";

describe("ApplicationController", (): void => {
	let contentWrapper: HTMLDivElement,
			content: HTMLDivElement,
			applicationController: ApplicationController;

	beforeEach((): void => {
		contentWrapper = document.createElement("div");
		contentWrapper.id = "contentWrapper";
		document.body.append(contentWrapper);

		content = document.createElement("div");
		content.id = "content";
		contentWrapper.append(content);

		sinon.spy(ApplicationController.prototype, "contentShown" as keyof ApplicationController);
		ApplicationController["singletonInstance"] = undefined;
		applicationController = new ApplicationController();
	});

	describe("object constructor", (): void => {
		it("should return an ApplicationController instance", (): Chai.Assertion => applicationController.should.be.an.instanceOf(ApplicationController));
		it("should make the instance a singleton", (): Chai.Assertion => applicationController.should.equal(ApplicationController["singletonInstance"]));
		it("should initialise the view stack", (): Chai.Assertion => applicationController.viewStack.should.deep.equal([]));
		it("should initialise the notice stack", (): Chai.Assertion => applicationController["noticeStack"].should.deep.equal({ height: -20, notice: [] }));
		it("should set the max data age days", (): Chai.Assertion => applicationController["maxDataAgeDays"].should.equal(7));

		it("should attach a transition end event handler", (): void => {
			contentWrapper.dispatchEvent(new Event("transitionend"));
			applicationController["contentShown"].should.have.been.called;
		});

		describe("instance already exists", (): void => {
			let anotherApplicationController: ApplicationController;

			beforeEach((): ApplicationController => (anotherApplicationController = new ApplicationController()));

			it("should return an ApplicationController instance", (): Chai.Assertion => anotherApplicationController.should.be.an.instanceOf(ApplicationController));
			it("should be the same instance", (): Chai.Assertion => anotherApplicationController.should.equal(applicationController));
		});
	});

	describe("start", (): void => {
		const lastSyncTime = new SettingMock("LastSyncTime", "1 Jan 2010");

		beforeEach(async (): Promise<void> => {
			sinon.stub(applicationController, "pushView");
			sinon.stub(applicationController, "showSyncNotice" as keyof ApplicationController);
			SettingMock.get.reset();
			SettingMock.get.withArgs("LastSyncTime").returns(lastSyncTime);
			SyncMock.syncList = [new SyncMock(null, null)];
			await applicationController.start();
		});

		it("should load all view controllers", (): Chai.Assertion => Object.keys(applicationController["viewControllers"]).length.should.equal(13));
		it("should display the schedule view", (): Chai.Assertion => applicationController.pushView.should.have.been.calledWith("schedule"));
		it("should get the last sync time", (): Chai.Assertion => applicationController["showSyncNotice"].should.have.been.calledWith(lastSyncTime, 1));
	});

	describe("popView", (): void => {
		beforeEach(async (): Promise<void> => {
			sinon.stub(applicationController, "clearFooter");
			sinon.stub(applicationController, "clearHeader" as keyof ApplicationController);
			sinon.stub(applicationController, "viewPopped" as keyof ApplicationController);
			sinon.stub(applicationController, "show" as keyof ApplicationController).yields({});
			applicationController["viewStack"] = [{ controller: new TestController(), scrollPos: 0 }];
			await applicationController.popView({} as ViewControllerArgs);
		});

		it("should clear the footer", (): Chai.Assertion => applicationController.clearFooter.should.have.been.called);
		it("should clear the header", (): Chai.Assertion => applicationController["clearHeader"].should.have.been.called);
		it("should pop the view off the view stack", (): Chai.Assertion => applicationController.viewStack.should.be.empty);
		it("should display the previous view", (): void => {
			applicationController["show"].should.have.been.calledWith(sinon.match.func, {});
			applicationController["viewPopped"].should.have.been.calledWith({});
		});
	});

	describe("getScrollPosition", (): void => {
		it("should save the current scroll position of the active view", (): void => {
			const scrollingElement = document.createElement("div"),
						item = document.createElement("div");

			item.style.height = "100px";
			scrollingElement.style.height = "50px";
			scrollingElement.style.overflowY = "scroll";
			scrollingElement.append(item);

			content.append(scrollingElement);
			scrollingElement.scrollTop = 10;

			applicationController.viewStack.push({ controller: new TestController(), scrollPos: 0 });
			applicationController.getScrollPosition();
			(applicationController.viewStack.pop() as View).scrollPos.should.equal(10);
		});
	});

	describe("setScrollPosition", (): void => {
		let scrollingElement: HTMLDivElement;

		beforeEach((): void => {
			const item1 = document.createElement("div"),
						item2 = document.createElement("div");

			item1.style.height = "100px";
			item2.style.height = "100px";

			scrollingElement = document.createElement("div");
			scrollingElement.style.height = "50px";
			scrollingElement.style.overflowY = "scroll";
			scrollingElement.append(item1, item2);

			content.append(scrollingElement);
		});

		describe("scroll position is -1", (): void => {
			it("should scroll to the bottom", (): void => {
				applicationController.viewStack.push({ controller: new TestController(), scrollPos: -1 });
				applicationController.setScrollPosition();
				scrollingElement.scrollTop.should.equal(100 + scrollingElement.offsetTop);
			});
		});

		describe("scoll position is not -1", (): void => {
			it("should restore the saved scroll position of the active view", (): void => {
				applicationController.viewStack.push({ controller: new TestController(), scrollPos: 20 });
				applicationController.setScrollPosition();
				scrollingElement.scrollTop.should.equal(20);
			});
		});
	});

	describe("setFooter", (): void => {
		let controller: TestController,
				leftButton: HTMLAnchorElement,
				rightButton: HTMLAnchorElement,
				label: HTMLElement;

		beforeEach((): void => {
			controller = new TestController();

			leftButton = document.createElement("a");
			leftButton.id = "footerLeftButton";
			leftButton.style.display = "none";

			rightButton = document.createElement("a");
			rightButton.id = "footerRightButton";
			rightButton.style.display = "none";

			label = document.createElement("footer");
			label.id = "footerLabel";
			label.style.display = "none";

			document.body.append(leftButton, label, rightButton);

			sinon.stub(applicationController, "setContentHeight" as keyof ApplicationController);
		});

		describe("without footer", (): void => {
			beforeEach((): void => {
				controller.footer = undefined;
				applicationController.viewStack.push({ controller, scrollPos: 0 });
				applicationController.setFooter();
			});

			it("should not show the footer label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should not update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.not.have.been.called);
		});

		describe("with footer", (): void => {
			let footer: HeaderFooter,
					leftButtonEventHandler: NavButtonEventHandler,
					rightButtonEventHandler: NavButtonEventHandler;

			beforeEach((): void => {
				applicationController.viewStack.push({ controller, scrollPos: 0 });
				footer = controller.footer as HeaderFooter;
				leftButtonEventHandler = (footer.leftButton as NavButton).eventHandler as NavButtonEventHandler;
				rightButtonEventHandler = (footer.rightButton as NavButton).eventHandler as NavButtonEventHandler;
			});

			describe("with left button", (): void => {
				describe("with event handler", (): void => {
					beforeEach((): void => applicationController.setFooter());

					it("should attach a click event handler", (): void => {
						leftButton.dispatchEvent(new MouseEvent("click"));
						leftButtonEventHandler.should.have.been.called;
					});

					it("should style the button", (): void => {
						leftButton.classList.contains("button").should.be.true;
						leftButton.classList.contains("footer").should.be.true;
						leftButton.classList.contains("left").should.be.true;
						leftButton.classList.contains("backButton").should.be.true;
					});

					it("should set the button label", (): Chai.Assertion => String(leftButton.textContent).should.equal("left-button"));
					it("should show the button", (): Chai.Assertion => leftButton.style.display.should.not.equal("none"));
					it("should show the footer label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
					it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
				});

				describe("without event handler", (): void => {
					it("should not attach a click event handler", (): void => {
						(footer.leftButton as NavButton).eventHandler = undefined;
						applicationController.setFooter();
						leftButton.dispatchEvent(new MouseEvent("click"));
						leftButtonEventHandler.should.not.have.been.called;
					});
				});

				describe("without button style", (): void => {
					it("should not style the button", (): void => {
						(footer.leftButton as NavButton).style = undefined;
						applicationController.setFooter();
						leftButton.classList.contains("backButton").should.be.false;
					});
				});
			});

			describe("without left button", (): void => {
				beforeEach((): void => {
					footer.leftButton = undefined;
					applicationController.setFooter();
				});

				it("should not attach a click event handler", (): void => {
					leftButton.dispatchEvent(new MouseEvent("click"));
					leftButtonEventHandler.should.not.have.been.called;
				});

				it("should not style the button", (): void => {
					leftButton.classList.contains("button").should.be.false;
					leftButton.classList.contains("footer").should.be.false;
					leftButton.classList.contains("left").should.be.false;
					leftButton.classList.contains("backButton").should.be.false;
				});

				it("should not set the button label", (): Chai.Assertion => String(leftButton.textContent).should.equal(""));
				it("should not show the button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
				it("should show the footer label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("with footer label", (): void => {
				beforeEach((): void => applicationController.setFooter());

				it("should set the footer label", (): Chai.Assertion => String(label.textContent).should.equal("test-footer"));
				it("should show the footer label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("without footer label", (): void => {
				beforeEach((): void => {
					footer.label = undefined;
					applicationController.setFooter();
				});

				it("should not set the footer label", (): Chai.Assertion => String(label.textContent).should.equal(""));
				it("should show the footer label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("with right button", (): void => {
				describe("with event handler", (): void => {
					beforeEach((): void => applicationController.setFooter());

					it("should attach a click event handler", (): void => {
						rightButton.dispatchEvent(new MouseEvent("click"));
						rightButtonEventHandler.should.have.been.called;
					});

					it("should style the button", (): void => {
						rightButton.classList.contains("button").should.be.true;
						rightButton.classList.contains("footer").should.be.true;
						rightButton.classList.contains("right").should.be.true;
						rightButton.classList.contains("confirmButton").should.be.true;
					});

					it("should set the button label", (): Chai.Assertion => String(rightButton.textContent).should.equal("right-button"));
					it("should show the button", (): Chai.Assertion => rightButton.style.display.should.not.equal("none"));
					it("should show the footer label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
					it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
				});

				describe("without event handler", (): void => {
					it("should not attach a click event handler", (): void => {
						(footer.rightButton as NavButton).eventHandler = undefined;
						applicationController.setFooter();
						rightButton.dispatchEvent(new MouseEvent("click"));
						rightButtonEventHandler.should.not.have.been.called;
					});
				});

				describe("without button style", (): void => {
					it("should not style the button", (): void => {
						(footer.rightButton as NavButton).style = undefined;
						applicationController.setFooter();
						rightButton.classList.contains("confirmButton").should.be.false;
					});
				});
			});

			describe("without right button", (): void => {
				beforeEach((): void => {
					footer.rightButton = undefined;
					applicationController.setFooter();
				});

				it("should not attach a click event handler", (): void => {
					rightButton.dispatchEvent(new MouseEvent("click"));
					rightButtonEventHandler.should.not.have.been.called;
				});

				it("should not style the button", (): void => {
					rightButton.classList.contains("button").should.be.false;
					rightButton.classList.contains("footer").should.be.false;
					rightButton.classList.contains("right").should.be.false;
					rightButton.classList.contains("confirmButton").should.be.false;
				});

				it("should not set the button label", (): Chai.Assertion => String(rightButton.textContent).should.equal(""));
				it("should not show the button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
				it("should show the footer label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});
		});

		afterEach((): void => {
			leftButton.remove();
			rightButton.remove();
			label.remove();
		});
	});

	describe("pushView", (): void => {
		interface Scenario {
			description: string;
			viewStack: View[];
		}

		const scenarios: Scenario[] = [
			{
				description: "initial view",
				viewStack: []
			},
			{
				description: "subsequent view",
				viewStack: [{ controller: new TestController(), scrollPos: 0 }]
			}
		];

		beforeEach((): void => {
			sinon.stub(applicationController, "getScrollPosition");
			sinon.stub(applicationController, "clearFooter");
			sinon.stub(applicationController, "clearHeader" as keyof ApplicationController);
			sinon.stub(applicationController, "viewPushed" as keyof ApplicationController);
			sinon.stub(applicationController, "show" as keyof ApplicationController).yields();
			applicationController["viewControllers"] = { test: TestController };
		});

		let view: View;

		scenarios.forEach((scenario: Scenario): void => {
			describe(scenario.description, (): void => {
				beforeEach(async (): Promise<void> => {
					applicationController.viewStack = scenario.viewStack;
					await applicationController.pushView("test", {} as ViewControllerArgs);
					view = applicationController.viewStack.pop() as View;
				});

				if (scenario.viewStack.length > 0) {
					it("should get the scroll position", (): Chai.Assertion => applicationController.getScrollPosition.should.have.been.called);
					it("should clear the footer", (): Chai.Assertion => applicationController.clearFooter.should.have.been.called);
					it("should clear the header", (): Chai.Assertion => applicationController["clearHeader"].should.have.been.called);
				} else {
					it("should not get the scroll position", (): Chai.Assertion => applicationController.getScrollPosition.should.not.have.been.called);
					it("should not clear the footer", (): Chai.Assertion => applicationController.clearFooter.should.not.have.been.called);
					it("should not clear the header", (): Chai.Assertion => applicationController["clearHeader"].should.not.have.been.called);
				}

				it("should push the view onto the view stack", (): void => {
					view.controller.should.be.an.instanceOf(TestController);
					view.scrollPos.should.equal(0);
				});

				it("should instantiate the view controller", (): Chai.Assertion => ((view.controller as TestController).args as ViewControllerArgs).should.deep.equal({}));

				it("should display the view", (): void => {
					applicationController["show"].should.have.been.called;
					applicationController["viewPushed"].should.have.been.called;
				});
			});
		});
	});

	describe("showNotice", (): void => {
		let notices: HTMLDivElement,
				notice: Notice,
				noticeContainer: HTMLDivElement,
				button: HTMLAnchorElement;

		beforeEach((): void => {
			notices = document.createElement("div");
			notices.id = "notices";
			notices.style.position = "absolute";
			notices.style.visibility = "hidden";
			notices.style.top = "0px";
			document.body.append(notices);

			sinon.stub(applicationController, "noticesMoved" as keyof ApplicationController);
			sinon.stub(applicationController, "hideNotice" as keyof ApplicationController);
			notice = { label: "test-notice" };
			applicationController["noticeStack"].height = 0;
			applicationController["noticeStack"].notice = [];
			WindowMock.innerHeight = 50;
		});

		describe("notice", (): void => {
			beforeEach((): void => {
				applicationController.showNotice(notice);
				noticeContainer = notices.querySelector("div") as HTMLDivElement;
				button = noticeContainer.querySelector("a") as HTMLAnchorElement;
				button.dispatchEvent(new MouseEvent("click"));
			});

			it("should create a new notice", (): void => {
				noticeContainer.innerHTML.should.equal("OK
test-notice
");
			});

			it("should attach a hide click event handler", (): Chai.Assertion => applicationController["hideNotice"].should.have.been.calledWith(sinon.match((element: HTMLDivElement): boolean => element === noticeContainer)));
		});

		describe("with notice id", (): void => {
			it("should set the notice id", (): void => {
				notice.id = "test-notice";
				applicationController.showNotice(notice);
				(null === notices.querySelector("div p#test-notice")).should.be.false;
			});
		});

		describe("without notice id", (): void => {
			it("should not set the notice id", (): void => {
				applicationController.showNotice(notice);
				(null === notices.querySelector("div p#test-notice")).should.be.true;
			});
		});

		describe("initial notice", (): void => {
			beforeEach((): void => applicationController.showNotice(notice));

			it("should position the notice stack off screen", (): Chai.Assertion => notices.style.top.should.equal("50px"));
			it("should make the notice stack visible", (): Chai.Assertion => notices.style.visibility.should.equal("visible"));
		});

		describe("subsequent notice", (): void => {
			beforeEach((): void => {
				applicationController["noticeStack"].notice.push(document.createElement("div"));
				applicationController.showNotice(notice);
			});

			it("should not position the notice stack off screen", (): Chai.Assertion => notices.style.top.should.equal("0px"));
			it("should make the notice stack visible", (): Chai.Assertion => notices.style.visibility.should.equal("hidden"));
		});

		it("should update the height of the notice stack to accomodate the new notice", (): void => {
			applicationController["noticeStack"].height = 0;
			applicationController.showNotice(notice);
			noticeContainer = notices.querySelector("div") as HTMLDivElement;
			applicationController["noticeStack"].height.should.equal(-noticeContainer.offsetHeight);
		});

		it("should push the notice onto the stack", (): void => {
			applicationController.showNotice(notice);
			noticeContainer = notices.querySelector("div") as HTMLDivElement;
			(applicationController["noticeStack"].notice.pop() as HTMLDivElement).should.equal(noticeContainer);
		});

		describe("animation", (): void => {
			beforeEach((done: Mocha.Done): void => {
				(applicationController["noticesMoved"] as SinonStub).callsFake((): void => done());
				sinon.spy(notices, "animate");
				applicationController["noticeStack"].height = 0;
				applicationController.showNotice(notice);
				notices.getAnimations().forEach((animation: Animation): void => animation.finish());
			});

			it("should slide up the notices container to reveal the notice", (): void => {
				noticeContainer = notices.querySelector("div") as HTMLDivElement;
				notices.animate.should.have.been.calledWith({ transform: `translateY(-${noticeContainer.offsetHeight}px)` });
			});

			it("should invoke the completed callback", (): Chai.Assertion => applicationController["noticesMoved"].should.have.been.called);

			afterEach((): void => (notices.animate as SinonSpy).restore());
		});

		afterEach((): void => notices.remove());
	});

	describe("clearFooter", (): void => {
		let controller: TestController,
				footer: HeaderFooter,
				leftButtonEventHandler: NavButtonEventHandler,
				rightButtonEventHandler: NavButtonEventHandler,
				leftButton: HTMLAnchorElement,
				rightButton: HTMLAnchorElement,
				label: HTMLElement;

		beforeEach((): void => {
			controller = new TestController();
			footer = controller.footer as HeaderFooter;
			leftButtonEventHandler = (footer.leftButton as NavButton).eventHandler as NavButtonEventHandler;
			rightButtonEventHandler = (footer.rightButton as NavButton).eventHandler as NavButtonEventHandler;

			leftButton = document.createElement("a");
			leftButton.id = "footerLeftButton";
			leftButton.addEventListener("click", leftButtonEventHandler);
			leftButton.style.display = "inline";

			rightButton = document.createElement("a");
			rightButton.id = "footerRightButton";
			rightButton.addEventListener("click", rightButtonEventHandler);
			rightButton.style.display = "inline";

			label = document.createElement("h1");
			label.id = "footerLabel";
			label.style.display = "block";
			label.textContent = "Test footer";

			document.body.append(leftButton, label, rightButton);

			sinon.stub(applicationController, "setContentHeight" as keyof ApplicationController);
		});

		describe("without footer", (): void => {
			beforeEach((): void => {
				controller.footer = undefined;
				applicationController.viewStack.push({ controller, scrollPos: 0 });
				applicationController.clearFooter();
			});

			it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
			it("should clear the footer label", (): Chai.Assertion => String(label.textContent).should.equal(""));
			it("should hide the footer label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("with footer", (): void => {
			beforeEach((): number => applicationController.viewStack.push({ controller, scrollPos: 0 }));

			describe("with left button", (): void => {
				beforeEach((): void => applicationController.clearFooter());

				it("should detach the click event handler", (): void => {
					leftButton.dispatchEvent(new MouseEvent("click"));
					leftButtonEventHandler.should.not.have.been.called;
				});

				it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
				it("should clear the footer label", (): Chai.Assertion => String(label.textContent).should.equal(""));
				it("should hide the footer label", (): Chai.Assertion => label.style.display.should.equal("none"));
				it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("without left button", (): void => {
				beforeEach((): void => {
					(applicationController["currentView"].controller.footer as HeaderFooter).leftButton = undefined;
					applicationController.clearFooter();
				});

				it("should not detach the click event handler", (): void => {
					leftButton.dispatchEvent(new MouseEvent("click"));
					leftButtonEventHandler.should.have.been.called;
				});

				it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
				it("should clear the footer label", (): Chai.Assertion => String(label.textContent).should.equal(""));
				it("should hide the footer label", (): Chai.Assertion => label.style.display.should.equal("none"));
				it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("with right button", (): void => {
				beforeEach((): void => applicationController.clearFooter());

				it("should detach the click event handler", (): void => {
					rightButton.dispatchEvent(new MouseEvent("click"));
					rightButtonEventHandler.should.not.have.been.called;
				});

				it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
				it("should clear the footer label", (): Chai.Assertion => String(label.textContent).should.equal(""));
				it("should hide the footer label", (): Chai.Assertion => label.style.display.should.equal("none"));
				it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("without right button", (): void => {
				beforeEach((): void => {
					(applicationController["currentView"].controller.footer as HeaderFooter).rightButton = undefined;
					applicationController.clearFooter();
				});

				it("should not detach the click event handler", (): void => {
					rightButton.dispatchEvent(new MouseEvent("click"));
					rightButtonEventHandler.should.have.been.called;
				});

				it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
				it("should clear the footer label", (): Chai.Assertion => String(label.textContent).should.equal(""));
				it("should hide the footer label", (): Chai.Assertion => label.style.display.should.equal("none"));
				it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});
		});

		afterEach((): void => {
			leftButton.remove();
			rightButton.remove();
			label.remove();
		});
	});

	describe("currentView", (): void => {
		it("should return the view on the top of the stack", (): void => {
			const view: View = { controller: new TestController(), scrollPos: 0 };

			applicationController["viewStack"] = [view];
			applicationController["currentView"].should.deep.equal(view);
		});
	});

	describe("viewPushed", (): void => {
		let controller: TestController;

		beforeEach(async (): Promise<void> => {
			controller = new TestController();
			applicationController.viewStack.push({ controller, scrollPos: 0 });
			await applicationController["viewPushed"]();
		});

		it("should setup the view controller", (): Chai.Assertion => controller.setup.should.have.been.called);
	});

	describe("viewPopped", (): void => {
		let controller: TestController,
				activate: SinonStub;

		beforeEach((): void => {
			controller = new TestController();
			activate = sinon.stub();
		});

		describe("without activate", (): void => {
			beforeEach(async (): Promise<void> => {
				applicationController.viewStack.push({ controller, scrollPos: 0 });
				await applicationController["viewPopped"]({} as ViewControllerArgs);
			});

			it("should not activate the view controller", (): Chai.Assertion => activate.should.not.have.been.called);
		});

		describe("with activate", (): void => {
			beforeEach(async (): Promise<void> => {
				Object.defineProperty(controller, "activate", { value: activate });
				applicationController.viewStack.push({ controller, scrollPos: 0 });
				await applicationController["viewPopped"]({} as ViewControllerArgs);
			});

			it("should activate the view controller", (): Chai.Assertion => activate.should.have.been.calledWith({}));
		});
	});

	describe("show", (): void => {
		let nowLoading: HTMLDivElement,
				callback: SinonSpy;

		beforeEach(async (): Promise<void> => {
			nowLoading = document.createElement("div");
			nowLoading.id = "nowLoading";
			document.body.append(nowLoading);

			sinon.stub(applicationController, "setHeader" as keyof ApplicationController);
			applicationController.viewStack.push({ controller: new TestController(), scrollPos: 0 });
			callback = sinon.spy();
			await applicationController["show"](callback, {} as ViewControllerArgs);
		});

		it("should show the now loading indicator", (): Chai.Assertion => nowLoading.classList.contains("loading").should.be.true);
		it("should load the view template", (): Chai.Assertion => content.innerHTML.should.equal("

"));
		it("should invoke the callback", (): Chai.Assertion => callback.should.have.been.calledWith({}));
		it("should slide the new view in from the right", (): Chai.Assertion => contentWrapper.classList.contains("loading").should.be.true);
		it("should set the header", (): Chai.Assertion => applicationController["setHeader"].should.have.been.called);

		afterEach((): void => nowLoading.remove());
	});

	describe("contentShown", (): void => {
		let nowLoading: HTMLDivElement;

		beforeEach((): void => {
			nowLoading = document.createElement("div");
			nowLoading.id = "nowLoading";
			nowLoading.classList.add("loading");
			document.body.append(nowLoading);
		});

		describe("loading", (): void => {
			beforeEach((): void => {
				contentWrapper.classList.add("loading");
				applicationController["contentShown"]();
			});

			it("should unmark the content wrapper as loading", (): Chai.Assertion => contentWrapper.classList.contains("loading").should.be.false);
			it("should mark the content wrapper as loaded", (): Chai.Assertion => contentWrapper.classList.contains("loaded").should.be.true);
			it("should hide the now loading indicator", (): Chai.Assertion => nowLoading.classList.contains("loading").should.be.false);
		});

		describe("loaded", (): void => {
			let controller: TestController,
					contentShown: SinonStub;

			beforeEach((): void => {
				controller = new TestController();
				contentShown = sinon.stub();
				contentWrapper.classList.add("loaded");
			});

			describe("without content shown", (): void => {
				beforeEach((): void => {
					applicationController.viewStack.push({ controller, scrollPos: 0 });
					applicationController["contentShown"]();
				});

				it("should unmark the content wrapper as loaded", (): Chai.Assertion => contentWrapper.classList.contains("loaded").should.be.false);
				it("should not call contentShown on the view controller", (): Chai.Assertion => contentShown.should.not.have.been.called);
			});

			describe("with content shown", (): void => {
				beforeEach((): void => {
					Object.defineProperty(controller, "contentShown", { value: contentShown });
					applicationController.viewStack.push({ controller, scrollPos: 0 });
					applicationController["contentShown"]();
				});

				it("should unmark the content wrapper as loaded", (): Chai.Assertion => contentWrapper.classList.contains("loaded").should.be.false);
				it("should call contentShown on the view controller", (): Chai.Assertion => contentShown.should.have.been.called);
			});
		});

		describe("unknown state", (): void => {
			it("should do nothing", (): void => {
				applicationController["contentShown"]();
				contentWrapper.classList.contains("loading").should.be.false;
				contentWrapper.classList.contains("loaded").should.be.false;
				nowLoading.classList.contains("loading").should.be.true;
			});
		});

		afterEach((): void => nowLoading.remove());
	});

	describe("setHeader", (): void => {
		let controller: TestController,
				header: HeaderFooter,
				leftButtonEventHandler: NavButtonEventHandler,
				rightButtonEventHandler: NavButtonEventHandler,
				leftButton: HTMLAnchorElement,
				rightButton: HTMLAnchorElement,
				label: HTMLHeadingElement;

		beforeEach((): void => {
			controller = new TestController();
			({ header } = controller);
			leftButtonEventHandler = (header.leftButton as NavButton).eventHandler as NavButtonEventHandler;
			rightButtonEventHandler = (header.rightButton as NavButton).eventHandler as NavButtonEventHandler;

			leftButton = document.createElement("a");
			leftButton.id = "headerLeftButton";
			leftButton.style.display = "none";

			rightButton = document.createElement("a");
			rightButton.id = "headerRightButton";
			rightButton.style.display = "none";

			label = document.createElement("h1");
			label.id = "headerLabel";
			label.style.display = "none";

			document.body.append(leftButton, label, rightButton);

			sinon.stub(applicationController, "setContentHeight" as keyof ApplicationController);
			applicationController.viewStack.push({ controller, scrollPos: 0 });
		});

		describe("with left button", (): void => {
			describe("with event handler", (): void => {
				beforeEach((): void => applicationController["setHeader"]());

				it("should attach a click event handler", (): void => {
					leftButton.dispatchEvent(new MouseEvent("click"));
					leftButtonEventHandler.should.have.been.called;
				});

				it("should style the button", (): void => {
					leftButton.classList.contains("button").should.be.true;
					leftButton.classList.contains("header").should.be.true;
					leftButton.classList.contains("left").should.be.true;
					leftButton.classList.contains("backButton").should.be.true;
				});

				it("should set the button label", (): Chai.Assertion => String(leftButton.textContent).should.equal("left-button"));
				it("should show the button", (): Chai.Assertion => leftButton.style.display.should.not.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("without event handler", (): void => {
				beforeEach((): void => {
					(header.leftButton as NavButton).eventHandler = undefined;
					applicationController["setHeader"]();
				});

				it("should not attach a click event handler", (): void => {
					leftButton.dispatchEvent(new MouseEvent("click"));
					leftButtonEventHandler.should.not.have.been.called;
				});
			});

			describe("without button style", (): void => {
				it("should not style the button", (): void => {
					(header.leftButton as NavButton).style = undefined;
					applicationController["setHeader"]();
					leftButton.classList.contains("backButton").should.be.false;
				});
			});
		});

		describe("without left button", (): void => {
			beforeEach((): void => {
				header.leftButton = undefined;
				applicationController["setHeader"]();
			});

			it("should not attach a click event handler", (): void => {
				leftButton.dispatchEvent(new MouseEvent("click"));
				leftButtonEventHandler.should.not.have.been.called;
			});

			it("should not style the button", (): void => {
				leftButton.classList.contains("button").should.be.false;
				leftButton.classList.contains("header").should.be.false;
				leftButton.classList.contains("left").should.be.false;
				leftButton.classList.contains("backButton").should.be.false;
			});

			it("should not set the button label", (): Chai.Assertion => String(leftButton.textContent).should.equal(""));
			it("should not show the button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("with header label", (): void => {
			beforeEach((): void => applicationController["setHeader"]());

			it("should set the header label", (): Chai.Assertion => String(label.textContent).should.equal("test-header"));
			it("should show the header label", (): Chai.Assertion => label.style.display.should.not.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("without header label", (): void => {
			beforeEach((): void => {
				header.label = undefined;
				applicationController["setHeader"]();
			});

			it("should not set the header label", (): Chai.Assertion => String(label.textContent).should.equal(""));
			it("should not show the header label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("with right button", (): void => {
			describe("with event handler", (): void => {
				beforeEach((): void => applicationController["setHeader"]());

				it("should attach a click event handler", (): void => {
					rightButton.dispatchEvent(new MouseEvent("click"));
					rightButtonEventHandler.should.have.been.called;
				});

				it("should style the button", (): void => {
					rightButton.classList.contains("button").should.be.true;
					rightButton.classList.contains("header").should.be.true;
					rightButton.classList.contains("right").should.be.true;
					rightButton.classList.contains("confirmButton").should.be.true;
				});

				it("should set the button label", (): Chai.Assertion => String(rightButton.textContent).should.equal("right-button"));
				it("should show the button", (): Chai.Assertion => rightButton.style.display.should.not.equal("none"));
				it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
			});

			describe("without event handler", (): void => {
				beforeEach((): void => {
					(header.rightButton as NavButton).eventHandler = undefined;
					applicationController["setHeader"]();
				});

				it("should not attach a click event handler", (): void => {
					rightButton.dispatchEvent(new MouseEvent("click"));
					rightButtonEventHandler.should.not.have.been.called;
				});
			});

			describe("without button style", (): void => {
				it("should not style the button", (): void => {
					(header.rightButton as NavButton).style = undefined;
					applicationController["setHeader"]();
					rightButton.classList.contains("confirmButton").should.be.false;
				});
			});
		});

		describe("without right button", (): void => {
			beforeEach((): void => {
				header.rightButton = undefined;
				applicationController["setHeader"]();
			});

			it("should not attach a click event handler", (): void => {
				rightButton.dispatchEvent(new MouseEvent("click"));
				rightButtonEventHandler.should.not.have.been.called;
			});

			it("should not style the button", (): void => {
				rightButton.classList.contains("button").should.be.false;
				rightButton.classList.contains("header").should.be.false;
				rightButton.classList.contains("right").should.be.false;
				rightButton.classList.contains("confirmButton").should.be.false;
			});

			it("should not set the button label", (): Chai.Assertion => String(rightButton.textContent).should.equal(""));
			it("should not show the button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		afterEach((): void => {
			leftButton.remove();
			rightButton.remove();
			label.remove();
		});
	});

	describe("clearHeader", (): void => {
		let controller: TestController,
				header: HeaderFooter,
				leftButtonEventHandler: NavButtonEventHandler,
				rightButtonEventHandler: NavButtonEventHandler,
				leftButton: HTMLAnchorElement,
				rightButton: HTMLAnchorElement,
				label: HTMLHeadingElement;

		beforeEach((): void => {
			controller = new TestController();
			({ header } = controller);
			leftButtonEventHandler = (header.leftButton as NavButton).eventHandler as NavButtonEventHandler;
			rightButtonEventHandler = (header.rightButton as NavButton).eventHandler as NavButtonEventHandler;

			leftButton = document.createElement("a");
			leftButton.id = "headerLeftButton";
			leftButton.addEventListener("click", leftButtonEventHandler);
			leftButton.style.display = "inline";

			rightButton = document.createElement("a");
			rightButton.id = "headerRightButton";
			rightButton.addEventListener("click", rightButtonEventHandler);
			rightButton.style.display = "inline";

			label = document.createElement("h1");
			label.id = "headerLabel";
			label.style.display = "block";
			label.textContent = "Test header";

			document.body.append(leftButton, label, rightButton);

			sinon.stub(applicationController, "setContentHeight" as keyof ApplicationController);
			applicationController.viewStack.push({ controller, scrollPos: 0 });
		});

		describe("with left button", (): void => {
			beforeEach((): void => applicationController["clearHeader"]());

			it("should detach the click event handler", (): void => {
				leftButton.dispatchEvent(new MouseEvent("click"));
				leftButtonEventHandler.should.not.have.been.called;
			});

			it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
			it("should hide the header label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("without left button", (): void => {
			beforeEach((): void => {
				applicationController["currentView"].controller.header.leftButton = undefined;
				applicationController["clearHeader"]();
			});

			it("should not detach the click event handler", (): void => {
				leftButton.dispatchEvent(new MouseEvent("click"));
				leftButtonEventHandler.should.have.been.called;
			});

			it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
			it("should hide the header label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("with right button", (): void => {
			beforeEach((): void => applicationController["clearHeader"]());

			it("should detach the click event handler", (): void => {
				rightButton.dispatchEvent(new MouseEvent("click"));
				rightButtonEventHandler.should.not.have.been.called;
			});

			it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
			it("should hide the header label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		describe("without right button", (): void => {
			beforeEach((): void => {
				applicationController["currentView"].controller.header.rightButton = undefined;
				applicationController["clearHeader"]();
			});

			it("should not detach the click event handler", (): void => {
				rightButton.dispatchEvent(new MouseEvent("click"));
				rightButtonEventHandler.should.have.been.called;
			});

			it("should hide the left button", (): Chai.Assertion => leftButton.style.display.should.equal("none"));
			it("should hide the header label", (): Chai.Assertion => label.style.display.should.equal("none"));
			it("should hide the right button", (): Chai.Assertion => rightButton.style.display.should.equal("none"));
			it("should update the content height", (): Chai.Assertion => applicationController["setContentHeight"].should.have.been.called);
		});

		afterEach((): void => {
			leftButton.remove();
			rightButton.remove();
			label.remove();
		});
	});

	describe("setContentHeight", (): void => {
		let header: HTMLDivElement,
				headerLabel: HTMLHeadingElement,
				footer: HTMLDivElement,
				footerLabel: HTMLElement,
				scrollingElement: HTMLDivElement;

		beforeEach((): void => {
			header = document.createElement("div");
			headerLabel = document.createElement("h1");
			footer = document.createElement("div");
			footerLabel = document.createElement("footer");
			scrollingElement = document.createElement("div");

			header.id = "header";
			header.style.height = "20px";
			headerLabel.id = "headerLabel";
			headerLabel.style.height = "15px";
			header.append(headerLabel);

			footer.id = "footer";
			footer.style.height = "20px";
			footerLabel.id = "footerLabel";
			footerLabel.style.height = "15px";
			footer.append(footerLabel);

			document.body.append(header, footer);

			scrollingElement.style.height = "40px";
			content.append(scrollingElement);

			WindowMock.innerHeight = 70;
		});

		describe("when the header label and footer label don't wrap", (): void => {
			it("should set the height of the content area minus the header and footer", (): void => {
				applicationController["setContentHeight"]();
				scrollingElement.offsetHeight.should.equal(17);
			});
		});

		describe("when the header label wraps", (): void => {
			it("should set the height of the content area minus the header label and footer", (): void => {
				headerLabel.style.height = "25px";
				applicationController["setContentHeight"]();
				scrollingElement.offsetHeight.should.equal(12);
			});
		});

		describe("when the footer label wraps", (): void => {
			it("should set the height of the content area minus the header and footer label", (): void => {
				footerLabel.style.height = "25px";
				applicationController["setContentHeight"]();
				scrollingElement.offsetHeight.should.equal(12);
			});
		});

		afterEach((): void => {
			header.remove();
			footer.remove();
		});
	});

	describe("hideNotice", (): void => {
		let notices: HTMLDivElement,
				notice: HTMLDivElement,
				otherNotice: HTMLDivElement;

		beforeEach((done: Mocha.Done): void => {
			applicationController["noticeStack"].height = -20;

			notices = document.createElement("div");
			notices.id = "notices";

			notice = document.createElement("div");
			notice.style.height = "10px";
			otherNotice = document.createElement("div");
			otherNotice.style.height = "10px";

			applicationController["noticeStack"].notice = [notice, otherNotice];
			notices.append(notice, otherNotice);

			document.body.append(notices);

			sinon.spy(notice, "animate");
			sinon.spy(notices, "animate");
			sinon.stub(applicationController, "noticesMoved" as keyof ApplicationController).callsFake((): void => done());

			applicationController["hideNotice"](notice);
			notice.getAnimations().forEach((animation: Animation): void => animation.finish());
			notices.getAnimations().forEach((animation: Animation): void => animation.finish());
		});

		it("should update the height of the notice stack to reclaim the space for the notice", (): Chai.Assertion => applicationController["noticeStack"].height.should.equal(-10));
		it("should slide out the notice to hide it", (): Chai.Assertion => notice.animate.should.have.been.calledWith({ transform: "translateX(100%)" }, { duration: 300, easing: "ease-in", fill: "forwards" }));
		it("should remove the notice from the DOM", (): Chai.Assertion => notices.children.length.should.equal(1));
		it("should remove the notice from the notice stack", (): Chai.Assertion => applicationController["noticeStack"].notice.should.not.include(notice));
		it("should slide down the notices container to the height of the notice stack", (): Chai.Assertion => notices.animate.should.have.been.calledWith({ transform: "translateY(-10px)" }, { duration: 500, delay: 300, easing: "ease", fill: "forwards" }));
		it("should invoke the completed callback", (): Chai.Assertion => applicationController["noticesMoved"].should.have.been.called);

		afterEach((): void => notices.remove());
	});

	describe("noticesMoved", (): void => {
		let	notices: HTMLDivElement;

		beforeEach((): void => {
			notices = document.createElement("div");
			notices.id = "notices";
			notices.style.visibility = "visible";
			document.body.append(notices);
		});

		it("should hide the notices container if there are no notices", (): void => {
			applicationController["noticesMoved"]();
			notices.style.visibility.should.equal("hidden");
		});

		it("should not hide the notices container if there are notices", (): void => {
			const notice = document.createElement("div");

			applicationController["noticeStack"].notice.push(notice);
			applicationController["noticesMoved"]();
			notices.style.visibility.should.equal("visible");
		});

		afterEach((): void => notices.remove());
	});

	describe("showSyncNotice", (): void => {
		beforeEach((): SinonStub => sinon.stub(applicationController, "showNotice" as keyof ApplicationController));

		describe("without local changes to sync", (): void => {
			it("should do nothing", (): void => {
				const clock = sinon.useFakeTimers(new Date().valueOf()),
							settingValue = new Date(new Date().valueOf() - (7 * 24 * 60 * 60 * 1000));

				applicationController["showSyncNotice"](new SettingMock(undefined, String(settingValue)), 0);
				applicationController["showSyncNotice"](new SettingMock(), 0);
				applicationController.showNotice.should.not.have.been.called;
				clock.restore();
			});
		});

		describe("without last sync time", (): void => {
			it("should do nothing", (): void => {
				applicationController["showSyncNotice"](new SettingMock(), 1);
				applicationController.showNotice.should.not.have.been.called;
			});
		});

		describe("with last sync time & local changes to sync", (): void => {
			let clock: SinonFakeTimers,
					settingValue: Date;

			beforeEach((): SinonFakeTimers => (clock = sinon.useFakeTimers(new Date().valueOf())));

			describe("younger than max data data age days", (): void => {
				it("should do nothing", (): void => {
					settingValue = new Date(new Date().valueOf() - (7 * 24 * 60 * 60 * 1000));
					applicationController["showSyncNotice"](new SettingMock(undefined, String(settingValue)), 1);
					applicationController.showNotice.should.not.have.been.called;
				});
			});

			describe("older than max data age days", (): void => {
				it("should display a sync notice", (): void => {
					settingValue = new Date(new Date().valueOf() - (9 * 24 * 60 * 60 * 1000));
					applicationController["showSyncNotice"](new SettingMock(undefined, String(settingValue)), 1);
					applicationController.showNotice.should.have.been.calledWith({ label: "The last data sync was over 7 days ago" });
				});
			});

			afterEach((): void => clock.restore());
		});
	});

	afterEach((): void => {
		contentWrapper.remove();
		(ApplicationController.prototype["contentShown"] as SinonSpy).restore();
	});
});


text:
/**
 * Created by ajitprak on 03-06-2016.
 */

var bcrypt = require('bcryptjs');
var errorLogger = require('../logHandle/errorLogHandle.js');

var bcryptUtil = {};

bcryptUtil.encrypt = function (password,callback) {
    bcrypt.genSalt(10,function(err, salt){
        bcrypt.hash(password,salt,function(err, hash){
            if(err == undefined){
                callback(hash);
            }
            else {
                errorLogger.error("Error occured while encrypting password, ERROR : " + err);
            }
        });
    });
};

module.exports = bcryptUtil;


text:
import MySQLdb
import mock
import optparse
from quotapolicyd.database import DBLink

@mock.patch('quotapolicyd.database.MySQLdb')
def test_instantiate_link_and_connect_to_database(mocksql):
  '''Test the SQL connection routine.'''
  mocksql.connect.return_value = mock.sentinel.dblink
  sql = DBLink()
  assert not sql.is_connected()

  sql.connect()

  assert mocksql.connect.call_count == 1
  assert sql.is_connected()

  sql.connect()

  assert mocksql.connect.call_count == 1
  assert sql.is_connected()

@mock.patch('quotapolicyd.database.MySQLdb')
def test_parse_command_line_options(mocksql):
  '''Check that command line parameters are passed on appropriately.'''
  parser = optparse.OptionParser()

  sql = DBLink()
  sql.add_command_line_options(parser)
  parser.parse_args([
    '--db-host', mock.sentinel.host,
    '--db-port', '1234',
    '--db-user', mock.sentinel.user,
    '--db-pass', mock.sentinel.password,
    '--db-name', mock.sentinel.database])

  sql.connect()

  assert mocksql.connect.call_count == 1
  args, kwargs = mocksql.connect.call_args
  assert kwargs['host'] == mock.sentinel.host
  assert kwargs['port'] == 1234
  assert kwargs['user'] == mock.sentinel.user
  assert kwargs['passwd'] == mock.sentinel.password
  assert kwargs['db'] == mock.sentinel.database

def test_add_command_line_help():
  '''Check that command line parameters are registered in the parser.'''
  parser = mock.MagicMock()

  DBLink().add_command_line_options(parser)

  assert parser.add_option.called
  assert parser.add_option.call_count > 4
  for call in parser.add_option.call_args_list:
    assert call[1]['action'] == 'callback'

@mock.patch('quotapolicyd.database.MySQLdb')
def test_check_config_file_behaviour(mocksql):
  '''Check that default parameters are not active when configuration file is used.'''
  parser = optparse.OptionParser()

  sql = DBLink()
  sql.add_command_line_options(parser)
  parser.parse_args([
    '--db-conf', mock.sentinel.config,
    '--db-user', mock.sentinel.user])

  sql.connect()

  assert mocksql.connect.call_count == 1
  args, kwargs = mocksql.connect.call_args
  assert kwargs['read_default_file'] == mock.sentinel.config
  assert kwargs['user'] == mock.sentinel.user
  for undefined in ['host', 'port', 'passwd', 'db']:
    assert undefined not in kwargs

@mock.patch('quotapolicyd.database.MySQLdb')
def test_retrieve_user_information(mocksql):
  '''Test the function to retrieve information from the database.'''
  mocksql.connect.return_value. \
    cursor.return_value. \
    fetchone.return_value = mock.sentinel.dbresults

  sql = DBLink()
  user_info = sql.get_user_info(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  args, kwargs = mocksql.connect().cursor().execute.call_args
  assert args[1] == (mock.sentinel.user,)
  assert args[0].startswith("SELECT")
  assert ';' not in args[0]
  assert mocksql.connect().cursor().close.call_count == 1
  assert user_info == mock.sentinel.dbresults

@mock.patch('quotapolicyd.database.MySQLdb')
def test_retrieve_user_information_error_handling(mocksql):
  '''Test error handling in the function to retrieve information from the database.'''
  mocksql.connect.return_value.cursor.return_value. \
    execute.side_effect = MySQLdb.Error()
  mocksql.MySQLError = MySQLdb.MySQLError

  sql = DBLink()
  user_info = sql.get_user_info(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert user_info is None

@mock.patch('quotapolicyd.database.MySQLdb')
def test_create_user(mocksql):
  '''Test creating a user in the database.'''
  sql = DBLink()
  retval = sql.create_user(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  args, kwargs = mocksql.connect().cursor().execute.call_args
  assert args[1] == (mock.sentinel.user,)
  assert args[0].startswith("INSERT INTO")
  assert ';' not in args[0]
  assert mocksql.connect().commit.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_create_user_error_handling(mocksql):
  '''Test error handling on creating a user in the database.'''
  mocksql.connect.return_value.cursor.return_value. \
    execute.side_effect = MySQLdb.Error()
  mocksql.MySQLError = MySQLdb.MySQLError

  sql = DBLink()
  retval = sql.create_user(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert not retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_increment_user_counter(mocksql):
  '''Test incrementing the counter of a user.'''
  sql = DBLink()
  retval = sql.increment_user(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  args, kwargs = mocksql.connect().cursor().execute.call_args
  assert args[1] == (mock.sentinel.user,)
  assert args[0].startswith("UPDATE")
  assert ';' not in args[0]
  assert mocksql.connect().commit.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_increment_user_counter_error_handling(mocksql):
  '''Test error handling on incrementing the counter of a user.'''
  mocksql.connect.return_value.cursor.return_value. \
    execute.side_effect = MySQLdb.Error()
  mocksql.MySQLError = MySQLdb.MySQLError

  sql = DBLink()
  retval = sql.increment_user(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert not retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_increment_user_counter_and_lock(mocksql):
  '''Test incrementing the counter of a user and locking the account.'''
  sql = DBLink()
  retval = sql.increment_lock_user(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  args, kwargs = mocksql.connect().cursor().execute.call_args
  assert args[1] == (mock.sentinel.user,)
  assert args[0].startswith("UPDATE")
  assert ';' not in args[0]
  assert mocksql.connect().commit.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_increment_user_counter_and_lock_error_handling(mocksql):
  '''Test error handling on incrementing the counter of a user and locking the account.'''
  mocksql.connect.return_value.cursor.return_value. \
    execute.side_effect = MySQLdb.Error()
  mocksql.MySQLError = MySQLdb.MySQLError

  sql = DBLink()
  retval = sql.increment_lock_user(mock.sentinel.user)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert not retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_unlock_user(mocksql):
  '''Test unlocking a user.'''
  sql = DBLink()
  retval = sql.unlock_user_increase_limit(mock.sentinel.user, mock.sentinel.limit)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  args, kwargs = mocksql.connect().cursor().execute.call_args
  assert args[1] == (mock.sentinel.limit, mock.sentinel.user, mock.sentinel.user)
  assert args[0].startswith("UPDATE")
  assert ';' not in args[0]
  assert mocksql.connect().commit.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert retval

@mock.patch('quotapolicyd.database.MySQLdb')
def test_unlock_user_error_handling(mocksql):
  '''Test error handling on unlocking a user.'''
  mocksql.connect.return_value.cursor.return_value. \
    execute.side_effect = MySQLdb.Error()
  mocksql.MySQLError = MySQLdb.MySQLError

  sql = DBLink()
  retval = sql.unlock_user_increase_limit(mock.sentinel.user, mock.sentinel.limit)

  assert sql.is_connected()
  assert mocksql.connect.call_count == 1
  assert mocksql.connect().cursor().execute.call_count == 1
  assert mocksql.connect().cursor().close.call_count == 1
  assert not retval

#
# To run the test below you need to pass a MySQL configuration file to py.test
# with the  --live-database-config=...  command line parameter. Note that this
# will modify an existing database, so do not use on production systems!
#

def test_using_live_database_connect(dbconfig):
  '''Run tests on a live database.'''
  import datetime
  parser = optparse.OptionParser()

  sql = DBLink()
  sql.add_command_line_options(parser)
  parser.parse_args(['--db-conf', dbconfig])

  sql.connect()

  non_existent_user = sql.get_user_info('pytest_dummy_user_nonext')
  assert non_existent_user is None

  user1_name = 'pytest_dummy_user_1'
  user1 = sql.get_user_info(user1_name)
  assert user1 == {'authcount': 0L, 'dynlimit': 3L, 'lastseen': datetime.datetime(2016, 3, 2, 21, 34, 8), 'limit': 3L, 'username': user1_name, 'reset': 1L, 'unseen': 0L, 'locked': 'N'}
  user1_lastseen = user1['lastseen']

  user2_name = 'pytest_dummy_user_2'
  user2 = sql.get_user_info(user2_name)
  assert user2 == {'authcount': None, 'dynlimit': None, 'lastseen': None, 'limit': None, 'username': user2_name, 'reset': None, 'unseen': 1L, 'locked': None}

  sql.create_user(user2_name)
  user2 = sql.get_user_info(user2_name)
  assert user2['lastseen'] is not None
  del user2['lastseen']
  assert user2 == {'authcount': 1L, 'dynlimit': 100L, 'limit': 100L, 'username': user2_name, 'reset': 0L, 'unseen': 0L, 'locked': 'N'}

  for inc in [1L, 2L, 3L]:
    sql.increment_user(user1_name)
    user1 = sql.get_user_info(user1_name)
    assert user1['lastseen'] is not None
    assert user1['lastseen'] != user1_lastseen
    del user1['lastseen']
    assert user1 == {'authcount': inc, 'dynlimit': 3L, 'limit': 3L, 'username': user1_name, 'reset': 1L, 'unseen': 0L, 'locked': 'N'}

  sql.increment_lock_user(user1_name)
  user1 = sql.get_user_info(user1_name)
  del user1['lastseen']
  assert user1 == {'authcount': 4L, 'dynlimit': 3L, 'limit': 3L, 'username': user1_name, 'reset': 1L, 'unseen': 0L, 'locked': 'Y'}

  sql.unlock_user_increase_limit(user1_name, 20)
  user1 = sql.get_user_info(user1_name)
  del user1['lastseen']
  assert user1 == {'authcount': 4L, 'dynlimit': 20L, 'limit': 3L, 'username': user1_name, 'reset': 0L, 'unseen': 0L, 'locked': 'N'}


text:
namespace IntegrationTests
{
    using System.Net.Http;
    using System.Threading.Tasks;
    using FluentAssertions;
    using Xunit;

    [Trait("Category", "Integration")]
    public sealed class LinkProviderTests : IClassFixture<WebFixture>
    {
        private readonly WebFixture fixture;

        public LinkProviderTests(WebFixture fixture)
        {
            this.fixture = fixture;
        }

        [Fact]
        public async Task EnsureLinkProviderResolvesTheCorrectValue()
        {
            using (HttpClient client = this.fixture.CreateAuthenticatedClient())
            {
                var message = new HttpRequestMessage(HttpMethod.Get, "/v1/links/to/test");

                dynamic result = await this.fixture.GetResultAsync(client, message);

                ((string)result.hRef).Should().Be("/v1/links/test");
            }
        }
    }
}


text:
package br.jus.trt3.poc.jee6.jsf;

import br.jus.trt3.poc.jee6.entity.Pessoa;
import br.jus.trt3.poc.jee6.entity.Telefone;
import br.jus.trt3.poc.jee6.jsf.util.JsfUtil;
import br.jus.trt3.poc.jee6.jsf.util.JsfUtil.PersistAction;
import br.jus.trt3.poc.jee6.repository.PessoaRepository;

import java.io.Serializable;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
import javax.ejb.EJBException;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import org.apache.deltaspike.jpa.api.transaction.Transactional;
import org.jboss.logging.Logger;

@ManagedBean(name = "pessoaController")
@SessionScoped
public class PessoaController implements Serializable {

    @Inject
    private PessoaRepository pessoaRepository;
    @Inject
    private EntityManager entityManager;
    @Inject
    private static Logger log;
    private List<Pessoa> items = null;
    private Pessoa selected;
    private String filtroNome;
    private String filtroTelefone;
    private Set<Telefone> telefones = null;
    private Telefone telefoneSelected;

    public PessoaController() {
    }

    public Pessoa getSelected() {
        return selected;
    }

    public void setSelected(Pessoa selected) {
        this.selected = selected;
    }

    public Set<Telefone> getTelefones() {
        return telefones;
    }

    public void setTelefones(Set<Telefone> telefones) {
        this.telefones = telefones;
    }

    public Telefone getTelefoneSelected() {
        return telefoneSelected;
    }

    public void setTelefoneSelected(Telefone telefoneSelected) {
        this.telefoneSelected = telefoneSelected;
    }

    public String getFiltroNome() {
        return filtroNome;
    }

    public void setFiltroNome(String filtroNome) {
        this.filtroNome = filtroNome;
    }

    public String getFiltroTelefone() {
        return filtroTelefone;
    }

    public void setFiltroTelefone(String filtroTelefone) {
        this.filtroTelefone = filtroTelefone;
    }

    private PessoaRepository getRepository() {
        return pessoaRepository;
    }

    public Pessoa prepareCreate() {
        selected = new Pessoa();
        return selected;
    }

    public void create() {
        persist(PersistAction.CREATE, ResourceBundle.getBundle("/Bundle").getString("PessoaCreated"));
        if (!JsfUtil.isValidationFailed()) {
            items = null;    // Invalidate list of items to trigger re-query.
        }
    }

    public void update() {
        persist(PersistAction.UPDATE, ResourceBundle.getBundle("/Bundle").getString("PessoaUpdated"));
    }

    public void destroy() {
        persist(PersistAction.DELETE, ResourceBundle.getBundle("/Bundle").getString("PessoaDeleted"));
        if (!JsfUtil.isValidationFailed()) {
            selected = null; // Remove selection
            items = null;    // Invalidate list of items to trigger re-query.
        }
    }

    public List<Pessoa> getItems() {
        if (items == null) {
            items = getRepository().findByNomeETelefone(filtroNome, filtroTelefone);
        }
        return items;
    }

    @Transactional
    private void persist(PersistAction persistAction, String successMessage) {
        if (selected != null) {
            try {
                if (persistAction != PersistAction.DELETE) {
                    getRepository().save(selected);
                } else {
                    entityManager.remove(entityManager.merge(selected));
                }
                items = getRepository().findByNomeETelefone(filtroNome, filtroTelefone);
                FacesContext ctxt = FacesContext.getCurrentInstance();
                ctxt.getPartialViewContext().getRenderIds().add("PessoaListForm");
                JsfUtil.addSuccessMessage(successMessage);
            } catch (EJBException ex) {
                String msg = "";
                Throwable cause = ex.getCause();
                if (cause != null) {
                    msg = cause.getLocalizedMessage();
                }
                if (msg.length() > 0) {
                    JsfUtil.addErrorMessage(msg);
                } else {
                    JsfUtil.addErrorMessage(ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
                }
            } catch (Exception ex) {
                log.error(null, ex);
                JsfUtil.addErrorMessage(ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
            }
        }
    }

    public List<Pessoa> getItemsAvailableSelectMany() {
        return getRepository().findAll();
    }

    public List<Pessoa> getItemsAvailableSelectOne() {
        return getRepository().findAll();
    }

    public Pessoa.Sexo[] getSexos() {
        return Pessoa.Sexo.values();
    }

    public void onPessoaSelected() {
        Set<Telefone> tels = null;
        if (getSelected() != null) {
            tels = getSelected().getTelefones();
        }
        setTelefones(tels);
    }

    public void onFiltroKeyUp() {
        this.items = null;
    }

    @FacesConverter(forClass = Pessoa.class)
    public static class PessoaControllerConverter implements Converter {

        @Override
        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
            if (value == null || value.length() == 0) {
                return null;
            }
            PessoaController controller = (PessoaController) facesContext.getApplication().getELResolver().
                    getValue(facesContext.getELContext(), null, "pessoaController");
            return controller.getRepository().findBy(getKey(value));
        }

        java.lang.Long getKey(String value) {
            java.lang.Long key;
            key = Long.valueOf(value);
            return key;
        }

        String getStringKey(java.lang.Long value) {
            StringBuilder sb = new StringBuilder();
            sb.append(value);
            return sb.toString();
        }

        @Override
        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
            if (object == null) {
                return null;
            }
            if (object instanceof Pessoa) {
                Pessoa o = (Pessoa) object;
                return getStringKey(o.getId());
            } else {
                log.errorv("object {0} is of type {1}; expected type: {2}", object,
                        object.getClass().getName(), Pessoa.class.getName());
                return null;
            }
        }

    }

}


text:
<?php

require_once 'PHPUnit/Framework.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');

/**
 * Extension to PHPUnit_Framework_AssertionFailedError to mark the special
 * case of a skipped test.
 *
 * @category   Testing
 * @package    PHPUnit
 * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
 * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    Release: @package_version@
 * @link       http://www.phpunit.de/
 * @since      Class available since Release 3.0.0
 */
class PHPUnit_Framework_SkippedTestError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_SkippedTest
{
}
?>


text:
	{validation_errors}

	<?= form_open('','id="frm_param" class="form-inline"'); ?>
	<?= form_hidden('sort', request('sort','')); ?>

		{_inventario_report_label_inventario_}
		<?= form_dropdown('inv_activo', $combo_inventarios, $id_inventario, 'id="sel_inv_activo" class="form-control input-sm"'); ?>

			<?= form_checkbox('elim_sin_dif', '1', request('elim_sin_dif'), 'id="elim_sin_dif"'); ?>
			{_inventario_report_check_ocultar_regs_}

			<?= form_checkbox('incl_ajustes', '1', request('incl_ajustes'), 'id="incl_ajustes"'); ?>
			{_inventario_report_check_incluir_ajustes_}

			<?= form_checkbox('incl_familias', '1', request('incl_familias'), 'id="incl_familias"'); ?>
			{_inventario_report_check_incluir_familias_}

				<?= form_input('filtrar_material', request('filtrar_material'), 'class="form-control input-sm" id="filtrar_material" placeholder="{_inventario_report_filter_}" onKeyPress="return event.keyCode!=13"'); ?>

	<?= form_close(); ?>

	{reporte}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.vault.v1.model;

/**
 * Options for Voice holds.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Google Vault API. For a detailed explanation see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class HeldVoiceQuery extends com.google.api.client.json.GenericJson {

  /**
   * A list of data types covered by the hold. Should be non-empty. Order does not matter and
   * duplicates are ignored.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.util.List<java.lang.String> coveredData;

  /**
   * A list of data types covered by the hold. Should be non-empty. Order does not matter and
   * duplicates are ignored.
   * @return value or {@code null} for none
   */
  public java.util.List<java.lang.String> getCoveredData() {
    return coveredData;
  }

  /**
   * A list of data types covered by the hold. Should be non-empty. Order does not matter and
   * duplicates are ignored.
   * @param coveredData coveredData or {@code null} for none
   */
  public HeldVoiceQuery setCoveredData(java.util.List<java.lang.String> coveredData) {
    this.coveredData = coveredData;
    return this;
  }

  @Override
  public HeldVoiceQuery set(String fieldName, Object value) {
    return (HeldVoiceQuery) super.set(fieldName, value);
  }

  @Override
  public HeldVoiceQuery clone() {
    return (HeldVoiceQuery) super.clone();
  }

}