text:
<?php

namespace Tlumx\Tests\Application;

use Tlumx\Application\Application;
use Tlumx\Application\ConfigureContainerInterface;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response;
use Tlumx\Application\Exception\BootstrapperClassNotFoundException;
use Tlumx\Application\Exception\InvalidBootstrapperClassException;
use Tlumx\Application\ApplicationEvent;
use Tlumx\View\TemplatesManager;

class ApplicationTest extends \PHPUnit\Framework\TestCase
{

    public function tearDown()
    {
        restore_error_handler();
        restore_exception_handler();
    }

    public function testInvalidInputParameter()
    {
        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessage('Invalid input parameter "containerOrConfig": '.
            '"expected a ContainerInterface or congiguration array".');
        $app = new Application('not_array_and_not_container');
    }

    public function testConstructorConfigureContainerNull()
    {
        $app = new Application([]);

        $class = new \ReflectionClass($app);
        $propertyConfigureContainer = $class->getProperty('configureContainer');
        $propertyConfigureContainer->setAccessible(true);
        $configureObj = $propertyConfigureContainer->getValue($app);

        $this->assertInstanceOf(ConfigureContainerInterface::class, $configureObj);
        $this->assertEquals($configureObj, $app->getConfigureContainerObj());
    }

    public function testConstructorConfigureContainer()
    {
        $configureObject = $this->prophesize(ConfigureContainerInterface::class)->reveal();

        $app = new Application([], $configureObject);

        $class = new \ReflectionClass($app);
        $propertyConfigureContainer = $class->getProperty('configureContainer');
        $propertyConfigureContainer->setAccessible(true);
        $configureObj = $propertyConfigureContainer->getValue($app);

        $this->assertEquals($configureObject, $configureObj);
        $this->assertEquals($configureObject, $app->getConfigureContainerObj());
    }

    public function testSetConfigureContainer()
    {
        $app = new Application([]);

        $class = new \ReflectionClass($app);
        $propertyConfigureContainer = $class->getProperty('configureContainer');
        $propertyConfigureContainer->setAccessible(true);
        $configureObj = $propertyConfigureContainer->getValue($app);

        $this->assertInstanceOf(ConfigureContainerInterface::class, $configureObj);
        $this->assertEquals($configureObj, $app->getConfigureContainerObj());

        $newConfigureObj = $this->prophesize(ConfigureContainerInterface::class)->reveal();
        $app->setConfigureContainerObj($newConfigureObj);

        $this->assertEquals($newConfigureObj, $app->getConfigureContainerObj());
    }

    public function testConstructorSetContainer()
    {
        $container = $this->prophesize(ContainerInterface::class)->reveal();
        $app = new Application($container);

        $class = new \ReflectionClass($app);
        $propertyContainer = $class->getProperty('container');
        $propertyContainer->setAccessible(true);
        $containerObj = $propertyContainer->getValue($app);

        $this->assertInstanceOf(ContainerInterface::class, $containerObj);
        $this->assertEquals($container, $containerObj);
        $this->assertEquals($container, $app->getContainer());
    }

    public function testConstructorDefaultContainer()
    {
        $app = new Application([]);

        $class = new \ReflectionClass($app);
        $propertyContainer = $class->getProperty('container');
        $propertyContainer->setAccessible(true);
        $containerObj = $propertyContainer->getValue($app);

        $this->assertInstanceOf(ContainerInterface::class, $containerObj);
        $this->assertEquals($containerObj, $app->getContainer());
    }

    public function testConstructorDefaultConfigArray()
    {
        $app = new Application([]);

        $class = new \ReflectionClass($app);
        $propertyDefaultConfig = $class->getProperty('defaultConfig');
        $propertyDefaultConfig->setAccessible(true);
        $defaultConfig = $propertyDefaultConfig->getValue($app);

        $configObj = $app->getContainer()->get('config');
        $config = $configObj->getAll();

        $this->assertEquals($defaultConfig, $config);
    }

    public function testConstructorConfigArray()
    {
        // change not all default options for test & add fixed options
        $conf = [
            'some option' => 'some value',
            'error_reporting' => '1',
            'display_errors' => '0',
            'display_exceptions' => false,
            'new_option1' => 'val1',
            'new_option2' => 'val2'
        ];
        $app = new Application($conf);

        $class = new \ReflectionClass($app);
        $propertyDefaultConfig = $class->getProperty('defaultConfig');
        $propertyDefaultConfig->setAccessible(true);
        $defaultConfig = $propertyDefaultConfig->getValue($app);

        $configObj = $app->getContainer()->get('config');
        $config = $configObj->getAll();

        $this->assertEquals(array_merge($defaultConfig, $conf), $config);
    }

    public function testGetConfig()
    {
        // change not all default options for test & add fixed options
        $conf = [
            'some option' => 'some value',
            'error_reporting' => '0',
            'display_errors' => '0',
            'display_exceptions' => false,
            'new_option1' => 'val1',
            'new_option2' => 'val2'
        ];
        $app = new Application($conf);

        $class = new \ReflectionClass($app);
        $propertyDefaultConfig = $class->getProperty('defaultConfig');
        $propertyDefaultConfig->setAccessible(true);
        $defaultConfig = $propertyDefaultConfig->getValue($app);

        $configObj = $app->getContainer()->get('config');
        $config = $configObj->getAll();

        $this->assertEquals($configObj, $app->getConfig());
        $this->assertEquals('some value', $app->getConfig('some option'));
        $this->assertNull($app->getConfig('no isset option'));
        $this->assertEquals('default value', $app->getConfig('no isset option', 'default value'));
    }

    /**
     * @runInSeparateProcess
     */
    public function testErrorHandler()
    {
        $app = new Application([]);
        error_reporting(-1);
        //$this->setExpectedException('ErrorException');
        $this->expectException(\ErrorException::class);
        $this->expectExceptionMessage('my error');
        $app->errorHandler(1, 'my error', 'file', 20);
    }

    /**
     * @runInSeparateProcess
     */
    public function testErrorHandlerNoException()
    {
        $app = new Application([]);
        error_reporting(0);
        $this->assertEquals(null, $app->errorHandler(1, 'my error', 'file', 20));
    }

    public function testBootstrapClassNotFound()
    {
        $app = new Application([
            'bootstrappers' => [
                'BootstrapClassNotFound'
            ]
        ]);
        $this->expectException(BootstrapperClassNotFoundException::class);
        $this->expectExceptionMessage(sprintf('Bootstrapper class "%s" not found', 'BootstrapClassNotFound'));

        $class = new \ReflectionClass($app);
        $methodBootstrap = $class->getMethod('bootstrap');
        $methodBootstrap->setAccessible(true);
        $methodBootstrap->invokeArgs($app, []);
    }

    public function testBootstrapClassNotExtendBootstrapper()
    {
        $app = new Application([
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\BootstrapClassNotExtendBootstrapper'
            ]
        ]);
        $this->expectException(InvalidBootstrapperClassException::class);
        $this->expectExceptionMessage(sprintf(
            "Bootstrapper class \"%s\" must extend from Tlumx\\Application\\Bootstrapper",
            'Tlumx\Tests\Application\Fixtures\BootstrapClassNotExtendBootstrapper'
        ));

        $class = new \ReflectionClass($app);
        $methodBootstrap = $class->getMethod('bootstrap');
        $methodBootstrap->setAccessible(true);
        $methodBootstrap->invokeArgs($app, []);
    }

    public function testBootstrapSuccess()
    {
        $app = new Application([
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\ABootstrapper',
                'Tlumx\Tests\Application\Fixtures\BBootstrapper'
            ],
            'a' => 'value_a',
            'b' => 'value_b',
            'c' => [
                'c1' => 'value_c1',
                'c2' => 'value_c2',
                'c3' => [
                    'c3_1' => 'value_c3_1',
                    'c3_2' => 'value_c3_3',
                ]
            ]
        ]);

        $class = new \ReflectionClass($app);
        $methodBootstrap = $class->getMethod('bootstrap');
        $methodBootstrap->setAccessible(true);
        $methodBootstrap->invokeArgs($app, []);

        // init()
        $this->assertTrue($app->getContainer()->has('init_service'));
        $this->assertEquals('init_service_value', $app->getContainer()->get('init_service'));

        // getServiceConfig
        $this->assertTrue($app->getContainer()->has('service1'));
        $this->assertEquals('value1', $app->getContainer()->get('service1'));

        // Bootstrapper not overide "main" config, can only add new options
        $config = $app->getConfig();
        $this->assertEquals([
            'a' => 'value_a',
            'b' => 'value_b',
            'c' => [
                'c1' => 'value_c1',
                'c2' => 'value_c2',
                'c3' => [
                    'c3_1' => 'value_c3_1',
                    'c3_2' => 'value_c3_3',
                    'c3_3' => 'value_c3_3_from_b',
                ]
            ],
            'd' => 'd_value',
            'error_reporting' => '-1',
            'display_errors' => '1',
            'display_exceptions' => true,
            'router_cache_enabled' => false,
            'router_cache_file' => 'routes.php.cache',
            'response_chunk_size' => 4096,
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\ABootstrapper',
                'Tlumx\Tests\Application\Fixtures\BBootstrapper'
            ]
        ], $config->getAll());

        // testEvents
        $em = $app->getContainer()->get('event_manager');
        $event = new ApplicationEvent(ApplicationEvent::EVENT_POST_BOOTSTRAP);
        $event->setContainer($app->getContainer());
        $this->assertEquals('postBootstrap', $em->trigger($event));
        $event->setName(ApplicationEvent::EVENT_PRE_ROUTING);
        $this->assertEquals('preRouting', $em->trigger($event));
        $event->setName(ApplicationEvent::EVENT_POST_ROUTING);
        $this->assertEquals('postRouting', $em->trigger($event));
        $event->setName(ApplicationEvent::EVENT_PRE_DISPATCH);
        $this->assertEquals('preDispatch', $em->trigger($event));
        $event->setName(ApplicationEvent::EVENT_POST_DISPATCH);
        $this->assertEquals('postDispatch', $em->trigger($event));
    }

    /**
     * @runInSeparateProcess
     */
    public function testSetErrorsRun()
    {
        $app = new Application([]);
        $app->run(false);

        $this->assertEquals('-1', ini_get('error_reporting'));
        $this->assertEquals('1', ini_get('display_errors'));

        $this->expectException(\ErrorException::class);
        $original = unserialize('foo');
    }

    /**
     * @runInSeparateProcess
     */
    public function testRunMustReturnResponse()
    {
        $app = new Application([]);
        $response = $app->run(false);
        $this->assertInstanceOf(ResponseInterface::class, $response);
    }

    public function getController($container)
    {
        // Set templates
        $tm = new TemplatesManager();
        $layout = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'SomeModule' .
                DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'main.phtml';
        $layout2 = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'SomeModule' .
                DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'main2.phtml';
        $tm->setTemplateMap([
            'main' => $layout,
            'main2' => $layout2
        ]);
        $tm->addTemplatePath('foo', __DIR__ . DIRECTORY_SEPARATOR . 'resources' .
            DIRECTORY_SEPARATOR . 'SomeModule' . DIRECTORY_SEPARATOR . 'views' .
            DIRECTORY_SEPARATOR . 'foo');
        $container->set('templates_manager', $tm);

        $config = $container->get('config');
        $config->set('layout', 'main');

        // Create controller object
        $fileController = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR .
            'SomeModule' . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR .
            'FooController.php';
        require_once $fileController;
        $class = 'Foo\\FooController';
    }

    /**
     * @runInSeparateProcess
     */
    public function testRunSuccess()
    {
        $_SERVER = [
            'SERVER_NAME'  => 'localhost',
            'SCRIPT_NAME' => 'index.php'
        ];
        $app = new Application([
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\ABootstrapper',
                'Tlumx\Tests\Application\Fixtures\BBootstrapper'
            ],
            'routes' => [
                'home' => [
                    'methods' => 'GET',
                    'pattern' => '/',
                    'middlewares' => [],
                    'handler' => ['controller' => 'FooController', 'action' => 'gamma'],
                ],
            ],
            'service_container' => [
                'factories' => [
                    'FooController' => 'Foo\\FooController',
                ]
            ]
        ]);

        $container = $app->getContainer();
        $em = $app->getContainer()->get('event_manager');
        $em->attach(ApplicationEvent::EVENT_POST_BOOTSTRAP, function (ApplicationEvent $e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_POST_BOOTSTRAP.'service', 'do1');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_PRE_ROUTING, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_PRE_ROUTING.'service', 'do2');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_POST_ROUTING, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_POST_ROUTING.'service', 'do3');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_PRE_DISPATCH, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_PRE_DISPATCH.'service', 'do4');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_POST_DISPATCH, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_POST_DISPATCH.'service', 'do5');
        }, 10);
        $this->getController($app->getContainer());

        // run
        $response = $app->run(false);
        $this->assertInstanceOf(ResponseInterface::class, $response);
        $body = $response->getBody();
        $body->rewind();
        $this->assertEquals('gamma', $body->getContents());

        // testEvents - all event was tregged
        $this->assertEquals('do1', $container->get(ApplicationEvent::EVENT_POST_BOOTSTRAP.'service'));
        $this->assertEquals('do2', $container->get(ApplicationEvent::EVENT_PRE_ROUTING.'service'));
        $this->assertEquals('do3', $container->get(ApplicationEvent::EVENT_POST_ROUTING.'service'));
        $this->assertEquals('do4', $container->get(ApplicationEvent::EVENT_PRE_DISPATCH.'service'));
        $this->assertEquals('do5', $container->get(ApplicationEvent::EVENT_POST_DISPATCH.'service'));
    }

    /**
     * @runInSeparateProcess
     */
    public function testRunWithoutOriginalDispatchMiddleware()
    {
        $_SERVER = [
            'SERVER_NAME'  => 'localhost',
            'SCRIPT_NAME' => 'index.php'
        ];
        $app = new Application([
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\ABootstrapper',
                'Tlumx\Tests\Application\Fixtures\BBootstrapper'
            ],
            'routes' => [
                'home' => [
                    'methods' => 'GET',
                    'pattern' => '/',
                    'middlewares' => [],
                    'handler' => ['controller' => 'FooController', 'action' => 'gamma'],
                ],
            ],
            'service_container' => [
                'factories' => [
                    'FooController' => 'Foo\\FooController',
                ]
            ]
        ]);

        $container = $app->getContainer();
        $em = $app->getContainer()->get('event_manager');
        $em->attach(ApplicationEvent::EVENT_POST_BOOTSTRAP, function (ApplicationEvent $e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_POST_BOOTSTRAP.'service', 'do1');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_PRE_ROUTING, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_PRE_ROUTING.'service', 'do2');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_POST_ROUTING, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_POST_ROUTING.'service', 'do3');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_PRE_DISPATCH, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_PRE_DISPATCH.'service', 'do4');
        }, 10);
        $em->attach(ApplicationEvent::EVENT_POST_DISPATCH, function ($e) {
            $e->getContainer()->set(ApplicationEvent::EVENT_POST_DISPATCH.'service', 'do5');
        }, 10);

        $this->getController($app->getContainer());

        $container->register(
            'DispatchMiddleware',
            "\Tlumx\Tests\Application\Fixtures\InvalidDispatchMiddleware"
        );

        $fileNotFoundHandler = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR .
            'MyNotFoundHandler.php';
        require_once $fileNotFoundHandler;
        $classNotFoundHandler = new \Tlumx\Tests\Application\MyNotFoundHandler();
        $container->set('not_found_handler', $classNotFoundHandler);

        // run
        $response = $app->run(false);
        $this->assertInstanceOf(ResponseInterface::class, $response);
        $body = $response->getBody();
        $body->rewind();
        $this->assertEquals('404', $body->getContents());

        // testEvents - all event was tregged
        $this->assertEquals('do1', $container->get(ApplicationEvent::EVENT_POST_BOOTSTRAP.'service'));
        $this->assertEquals('do2', $container->get(ApplicationEvent::EVENT_PRE_ROUTING.'service'));
        $this->assertEquals('do3', $container->get(ApplicationEvent::EVENT_POST_ROUTING.'service'));
        $this->assertEquals('do', $container->get('InvalidDispatchMiddlewareService'));
        $this->assertFalse($container->has(ApplicationEvent::EVENT_PRE_DISPATCH.'service'));
        $this->assertFalse($container->has(ApplicationEvent::EVENT_POST_DISPATCH.'service'));
    }

    /**
     * @runInSeparateProcess
     */
    public function testRunCatchBlock()
    {
        $app = new Application([
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\ABootstrapper',
                'Tlumx\Tests\Application\Fixtures\BBootstrapper'
            ]
        ]);

        $em = $app->getContainer()->get('event_manager');
        $em->attach(ApplicationEvent::EVENT_POST_BOOTSTRAP, function (ApplicationEvent $e) {
            // check to use "ob_end_clean()" in catch block
            $notObFlush = new \Tlumx\Tests\Application\Fixtures\NotObFlush();

            $e->getContainer()->set(ApplicationEvent::EVENT_POST_BOOTSTRAP.'service', 'do1');
            throw new \Exception("This is my test exception");
        }, 10);

        $fileExceptionHandler = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR .
            'MyErrorHandler.php';
        require_once $fileExceptionHandler;
        $classErrorHandler = new \Tlumx\Tests\Application\MyErrorHandler();
        $app->getContainer()->set('exception_handler', $classErrorHandler);

        // run
        $response = $app->run(false);
        $this->assertInstanceOf(ResponseInterface::class, $response);
        $body = $response->getBody();
        $body->rewind();
        $this->assertEquals('Error: This is my test exception', $body->getContents());
    }

    /**
     * @runInSeparateProcess
     */
    public function testRunAndSend()
    {
        $_SERVER = [
            'SERVER_NAME'  => 'localhost',
            'SCRIPT_NAME' => 'index.php'
        ];
        $app = new Application([
            'bootstrappers' => [
                'Tlumx\Tests\Application\Fixtures\ABootstrapper',
                'Tlumx\Tests\Application\Fixtures\BBootstrapper'
            ],
            'routes' => [
                'home' => [
                    'methods' => 'GET',
                    'pattern' => '/',
                    'middlewares' => [],
                    'handler' => ['controller' => 'FooController', 'action' => 'gamma'],
                ],
            ],
            'service_container' => [
                'factories' => [
                    'FooController' => 'Foo\\FooController',
                ]
            ]
        ]);
        $this->getController($app->getContainer());

        // run
        $app->run();
        $this->expectOutputString('gamma');
    }

    /**
     * @runInSeparateProcess
     */
    public function testSendResponse()
    {
        $response = new Response();
        $response = $response->withStatus(500);
        $response->getBody()->write('Error');
        $response->withHeader('Content-Type', 'text/html');

        $app = new Application([]);

        $app->sendResponse($response);
        $this->assertEquals(500, http_response_code());

        $this->expectOutputString('Error');
    }

    /**
     * @runInSeparateProcess
     */
    public function testSendResponseWithNoContentLength()
    {
        $response = new Response();
        $response = $response->withStatus(200);
        $response->getBody()->write('some content');
        $size = (string) $response->getBody()->getSize();

        $app = new Application([]);
        $app->sendResponse($response);

        $this->assertEquals(200, http_response_code());
        $this->expectOutputString('some content');
        $this->assertContains(
            'Content-Length: ' . $size,
            xdebug_get_headers()
        );
    }

    /**
     * @runInSeparateProcess
     */
    public function testSendResponseWithSetCookieHeaders()
    {
        $response = new Response();
        $response = $response->withStatus(200);
        $response->getBody()->write('some content');
        $response = $response->withHeader('Content-Type', 'text/html');
        $response = $response->withHeader('Set-Cookie', 'foo=bar');
        $response = $response->withAddedHeader('Set-Cookie', 'a=b');

        $app = new Application([]);
        $app->sendResponse($response);

        $this->assertEquals(200, http_response_code());
        $this->expectOutputString('some content');
        $this->assertContains('Content-Length: 12', xdebug_get_headers());
        $this->assertContains('Set-Cookie: foo=bar', xdebug_get_headers());
        $this->assertContains('Set-Cookie: a=b', xdebug_get_headers());
    }

    /**
     * @runInSeparateProcess
     */
    public function testSendResponseWhenHeadersSent()
    {
        require __DIR__ . '/functions/headers_sent_function_helper.php';

        $response = new Response();
        $response = $response->withStatus(500);
        $response->getBody()->write('Error');
        $response->withHeader('Content-Type', 'text/html');

        $app = new Application([]);
        $app->sendResponse($response);

        $this->expectOutputString('');
    }

    /**
     * @runInSeparateProcess
     */
    public function testSendResponseBreakOnNotCconnectionNormal()
    {
        require __DIR__ . '/functions/connection_status_function_helper.php';

        $response = new Response();
        $response = $response->withStatus(500);
        $response->getBody()->write('Error');
        $response->withHeader('Content-Type', 'text/html');

        $app = new Application([]);
        $config = $app->getConfig();
        $config->set('response_chunk_size', 4);
        $app->sendResponse($response);

        $this->expectOutputString('Erro');
    }
}


text:
import datetime
from django.test import TestCase
from ..utils import get_fiscal_year, Holiday
import logging
logger = logging.getLogger(__name__)
__author__ = 'lberrocal'

class TestUtils(TestCase):

    def test_get_fiscal_year(self):
        cdates = [[datetime.date(2015, 10, 1), 'AF16'],
                  [datetime.date(2015, 9, 30), 'AF15'],
                  [datetime.date(2016, 1, 5), 'AF16'],]
        for cdate in cdates:
            fy = get_fiscal_year(cdate[0])
            self.assertEqual(cdate[1], fy)

    def test_get_fiscal_year_datetime(self):
        cdates = [[datetime.datetime(2015, 10, 1, 16, 0), 'AF16'],
                  [datetime.datetime(2015, 9, 30, 2, 45), 'AF15'],
                  [datetime.datetime(2016, 1, 5, 3, 45), 'AF16'],]
        for cdate in cdates:
            fy = get_fiscal_year(cdate[0])
            self.assertEqual(cdate[1], fy)

class TestHolidays(TestCase):

    def test_is_holiday(self):
        holiday = datetime.date(2015,12,25)
        holiday_manager = Holiday()
        self.assertTrue(holiday_manager.is_holiday(holiday))

        non_holiday = datetime.date(2015,12,24)
        self.assertFalse(holiday_manager.is_holiday(non_holiday))

    def test_working_days_between(self):
        holiday_manager = Holiday()
        start_date = datetime.date(2016, 1,1)
        end_date = datetime.date(2016,1,31)
        self.assertEqual(19, holiday_manager.working_days_between(start_date, end_date))

redpajama_set_name: RedPajamaGithub


text:
#pragma config(UART_Usage, UART1, uartVEXLCD, baudRate19200, IOPins, None, None)
#pragma config(UART_Usage, UART2, uartNotUsed, baudRate4800, IOPins, None, None)
#pragma config(Sensor, in1,    leftLight,      sensorNone)
#pragma config(Sensor, in2,    midLight,       sensorLineFollower)
#pragma config(Sensor, in3,    rightLight,     sensorLineFollower)
#pragma config(Sensor, in4,    colorSelect,    sensorPotentiometer)
#pragma config(Sensor, in5,    autonomousNum,  sensorPotentiometer)
#pragma config(Sensor, dgtl1,  armenco,        sensorQuadEncoder)
#pragma config(Sensor, dgtl3,  auto,           sensorTouch)
#pragma config(Motor,  port1,           leftarmM1,     tmotorVex393, openLoop)
#pragma config(Motor,  port2,           frontleftM,    tmotorVex393, openLoop)
#pragma config(Motor,  port3,           backleftM,     tmotorVex393, openLoop)
#pragma config(Motor,  port4,           backrightM,    tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port5,           frontrightM,   tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port6,           intake1,       tmotorVex269, openLoop, reversed)
#pragma config(Motor,  port7,           intake2,       tmotorVex269, openLoop)
#pragma config(Motor,  port8,           leftarmM2,     tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port9,           rightarmM2,    tmotorVex393, openLoop)
#pragma config(Motor,  port10,          rightarmM1,    tmotorVex393, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "Chassis_Library.h"
#include "Arm.h"
#include "PID_Library.h"
#include "LCD_Display_Menu.h"
#include "Autonomous.h"
task main()
{
	while(true){
  	if(SensorValue(auto)==1){
		if(SensorValue(colorSelect)>= 0 && SensorValue(colorSelect)<= 2047 ){

		  if(SensorValue(autonomousNum)>=0&&SensorValue(autonomousNum)<=1365){
		 	 blueMid12();
		  }
		  else if(SensorValue(autonomousNum)>1365&&SensorValue(autonomousNum)<=2730){
		 	 blueMid15();
		  }
	}
	  }
  }

}


text:
FactoryGirl.define do

  factory :access_link, :class => Chouette::AccessLink do
    sequence(:name) { |n| "Access link #{n}" }
    sequence(:objectid) { |n| "test:AccessLink:#{n}" }
    link_type "Mixed"
    link_orientation "AccessPointToStopArea"

    association :stop_area, :factory => :stop_area
    association :access_point, :factory => :access_point
  end

end


text:
package storage

import (
	"errors"
	"fmt"

	storageDriver "github.com/docker/distribution/registry/storage/driver"
)

// SkipDir is used as a return value from onFileFunc to indicate that
// the directory named in the call is to be skipped. It is not returned
// as an error by any function.
var ErrSkipDir = errors.New("skip this directory")

// WalkFn is called once per file by Walk
// If the returned error is ErrSkipDir and fileInfo refers
// to a directory, the directory will not be entered and Walk
// will continue the traversal.  Otherwise Walk will return
type WalkFn func(fileInfo storageDriver.FileInfo) error

// Walk traverses a filesystem defined within driver, starting
// from the given path, calling f on each file
func Walk(driver storageDriver.StorageDriver, from string, f WalkFn) error {
	children, err := driver.List(from)
	if err != nil {
		return err
	}
	for _, child := range children {
		fileInfo, err := driver.Stat(child)
		if err != nil {
			return err
		}
		err = f(fileInfo)
		skipDir := (err == ErrSkipDir)
		if err != nil && !skipDir {
			return err
		}

		if fileInfo.IsDir() && !skipDir {
			Walk(driver, child, f)
		}
	}
	return nil
}

// pushError formats an error type given a path and an error
// and pushes it to a slice of errors
func pushError(errors []error, path string, err error) []error {
	return append(errors, fmt.Errorf("%s: %s", path, err))
}


text:
package com.theoryinpractice.testng.model;

import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.project.Project;

/**
 * @author Hani Suleiman Date: Jul 28, 2005 Time: 10:44:26 PM
 */
public class TestNodeDescriptor extends NodeDescriptor<TestProxy>
{
    private final TestProxy node;

    public TestNodeDescriptor(Project project, TestProxy node, NodeDescriptor<TestProxy> parent) {
        super(project, parent);
        this.node = node;
        myName = node.getName();
    }

    @Override
    public boolean update() {
        return false;
    }

    @Override
    public TestProxy getElement() {
        return node;
    }

    public boolean expandOnDoubleClick() {
        return !node.isResult();
    }
}


text:
package com.running.together.util;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;

public class ActivityControler {
	public static List<Activity> activities = new ArrayList<Activity>();

	public static void addActivity(Activity activity) {
		activities.add(activity);
	}

	public static void removeActivity(Activity activity) {
		activities.remove(activity);
	}

	public static void finishAll() {
		for (Activity activity : activities) {
			if (!activity.isFinishing()) {
				activity.finish();
			}
		}
	}

}


text:
<?php
/**
 * Created by JetBrains PhpStorm.
 * User: JanGolle
 * Date: 05.11.14
 * Time: 18:37
 * To change this template use File | Settings | File Templates.
 */

namespace app\components;

use app\models\Escort;
use Yii;
use yii\base\Component;
use yii\web\NotFoundHttpException;

class Rating extends Component
{
    /**
     * @var \app\components\FastData;
     */
    private $data;

    public function init(){
        $this->data = Yii::$app->fastData;
    }

    public function get($id){
        if($id === null)
            return false;

        return $this->data->hget(Stats::KEY_ESCORT_STATS.$id, Stats::FIELD_RATING);
    }

    public function set($id, $value){
        if($id != null){
            $this->data->hset(Stats::KEY_ESCORT_STATS.$id, Stats::FIELD_RATING, $value);
        }
    }

    public function add($id,$delta){
        $this->data->hincr(Stats::KEY_ESCORT_STATS.$id, Stats::FIELD_RATING, $delta);
    }

    public function save($id){
        if($id === null)
            return false;

        return Yii::$app->data->getRepository('Escort')->updateRating($id, $this->get($id));
    }
}


text:
package com.orientechnologies.lucene.engine;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.index.OIndexDefinition;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OProperty;
import com.orientechnologies.orient.core.metadata.schema.OSchema;
import com.orientechnologies.orient.core.record.impl.ODocument;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OLuceneClassIndexContext {

  protected final OIndexDefinition definition;
  protected final String name;
  protected final boolean automatic;
  protected final ODocument metadata;
  protected final Map<String, Boolean> fieldsToStore = new HashMap<String, Boolean>();
  protected final OClass indexClass;

  public OLuceneClassIndexContext(
      OSchema schema,
      OIndexDefinition definition,
      String name,
      boolean automatic,
      ODocument metadata) {
    this.definition = definition;
    this.name = name;
    this.automatic = automatic;
    this.metadata = metadata;

    OLogManager.instance().info(this, "index definition:: " + definition);

    indexClass = schema.getClass(definition.getClassName());

    updateFieldToStore(definition);
  }

  private void updateFieldToStore(OIndexDefinition indexDefinition) {

    List<String> fields = indexDefinition.getFields();

    for (String field : fields) {
      OProperty property = indexClass.getProperty(field);

      if (property.getType().isEmbedded() && property.getLinkedType() != null) {
        fieldsToStore.put(field, true);
      } else {
        fieldsToStore.put(field, false);
      }
    }
  }

  public boolean isFieldToStore(String field) {
    if (fieldsToStore.containsKey(field)) return fieldsToStore.get(field);
    return false;
  }
}


text:
namespace ash {

int DefaultUserWallpaperDelegate::GetAnimationType() {
  return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
}

int DefaultUserWallpaperDelegate::GetAnimationDurationOverride() {
  return 0;
}

void DefaultUserWallpaperDelegate::SetAnimationDurationOverride(
    int animation_duration_in_ms) {
}

bool DefaultUserWallpaperDelegate::ShouldShowInitialAnimation() {
  return false;
}

void DefaultUserWallpaperDelegate::UpdateWallpaper(bool clear_cache) {
}

void DefaultUserWallpaperDelegate::InitializeWallpaper() {
  ash::Shell::GetInstance()->desktop_background_controller()->
      CreateEmptyWallpaper();
}

void DefaultUserWallpaperDelegate::OpenSetWallpaperPage() {
}

bool DefaultUserWallpaperDelegate::CanOpenSetWallpaperPage() {
  return false;
}

void DefaultUserWallpaperDelegate::OnWallpaperAnimationFinished() {
}

void DefaultUserWallpaperDelegate::OnWallpaperBootAnimationFinished() {
}

}  // namespace ash


text:
<?php

namespace backend\modules\banner\controllers;

use Yii;
use backend\modules\banner\models\Banner;
use backend\modules\banner\models\BannerSearch;
use yii\web\Controller;
use yii\filters\AccessControl;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

class DefaultController extends Controller
{

    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['index', 'create', 'update', 'delete'],
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['admin'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['post'],
                ],
            ],
        ];
    }

    /**
     * Lists all Banner models.
     * @return mixed
     */
    public function actionIndex()
    {
        $searchModel = new BannerSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

    /**
     * Creates a new Banner model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
        $model = new Banner();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['index']);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Updates an existing Banner model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     */
    public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', [
                'type' => 'success',
                'duration' => 5000,
                'icon' => 'fa fa-check fa-fw',
                'title' => 'Сохранено',
                'message' => 'Информация сохранена успешно',
                'positonY' => 'top',
                'positonX' => 'right',

             ]);

            return $this->render('update', [
                'model' => $model,
            ]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Deletes an existing Banner model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param integer $id
     * @return mixed
     */
    public function actionDelete($id)
    {
        $this->findModel($id)->delete();

        return $this->redirect(['index']);
    }

    /**
     * Finds the Banner model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param integer $id
     * @return Banner the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = Banner::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}


text:
using System;
using System.Windows.Forms;
using System.Drawing;

namespace Calculator
{
	public class Calculator : Form
	{
		private Button[] buttons = new Button[16];
		private TextBox textBox = new TextBox();

		private int leftValue = 0;
		private char operation = '+';
		private int rightValue = 0;

		private static string nullWarning = "You shall not divide by zero!";

		public Calculator ()
		{
			DisplayGUI ();
		}

		private void DisplayGUI ()
		{
			this.Name = "Calculator";
			this.Text = "Calculator";
			this.Size = new Size (165, 225);
			this.StartPosition = FormStartPosition.CenterScreen;

			AddAllButtons();

			textBox = new TextBox();
			textBox.Name = "TextBox";
			textBox.Text = "0";
			textBox.Size = new Size(160, 40);
			textBox.Location = new Point();
			textBox.KeyPress += new KeyPressEventHandler(
				(object sender, KeyPressEventArgs args) =>
				{args.Handled = true;});

			this.Controls.Add(textBox);
			this.FormBorderStyle = FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
		}

		private void AddAllButtons()
		{
			Size sizeOfButton = new Size(40, 40);
			for (int i = 1; i < 10; ++i)
			{
				buttons[i] = AddButton("button_" + i.ToString(), i.ToString(), sizeOfButton,
					new Point(40 * ((i - 1) % 3), 40 * ((i - 1) / 3 + 1)));
			}
			buttons[0] = AddButton("button_0", 0.ToString(), sizeOfButton,
				new Point(40 * 1, 40 * 4));

			buttons[10] = AddButton("button_+", "+", sizeOfButton,
				new Point(40 * 3, 40 * 1));
			buttons[11] = AddButton("button_-", "-", sizeOfButton,
				new Point(40 * 3, 40 * 2));
			buttons[12] = AddButton("button_*", "*", sizeOfButton,
				new Point(40 * 3, 40 * 3));
			buttons[13] = AddButton("button_/", "/", sizeOfButton,
				new Point(40 * 3, 40 * 4));
			buttons[14] = AddButton("button_=", "=", sizeOfButton,
				new Point(40 * 2, 40 * 4));
			buttons[15] = AddButton("button_C", "C", sizeOfButton,
				new Point(40 * 0, 40 * 4));

			for (int i = 0; i < 10; ++i)
			{
				buttons[i].Click += AddDigit;
			}

			for (int i = 10; i < 15; ++i)
			{
				buttons[i].Click += AddChar;
			}

			buttons [15].Click += DeleteAll;
		}

		private Button AddButton(String name, String text, Size size, Point point)
		{
			var result = new Button();
			result.Name = name;
			result.Text = text;
			result.Size = size;
			result.Location = point;
			this.Controls.Add(result);
			return result;
		}

		private void AddDigit(object sender, EventArgs args)
		{
			if (textBox.Text == nullWarning)
			{
				textBox.Text = "";
			}
			else if (textBox.Text[0] == '0')
			{
				textBox.Text = "";
				operation = '+';
			}
			var button = sender as Button;
			textBox.Text += button.Text[0];
			rightValue *= 10;
			rightValue += (int)button.Text[0] - '0';
		}

		private void AddChar(object sender, EventArgs args)
		{
			var button = sender as Button;
			if (!(textBox.Text [0] <= '9'
			    && textBox.Text [0] >= '0')) {
				if (leftValue != 0) {
					textBox.Text = leftValue.ToString ();
				}
				textBox.Text += button.Text[0];
				operation = button.Text[0];
			} else {
				switch (operation) {
				case '+':
					{
						leftValue += rightValue;
						break;
					}
				case '-':
					{
						leftValue -= rightValue;
						break;
					}
				case '*':
					{
						leftValue *= rightValue;
						break;
					}
				case '/':
					{
						if (rightValue == 0) {
							textBox.Text = nullWarning;
							return;
						}
						leftValue /= rightValue;
						break;
					}
				}
				textBox.Text = leftValue.ToString ();
				textBox.Text += button.Text[0];
				operation = button.Text[0];
				rightValue = 0;
			}
		}

		public void DeleteAll(object sender, EventArgs args)
		{
			textBox.Text = "0";
			leftValue = 0;
			operation = '+';
			rightValue = 0;
		}
	}
}


text:
/*
 * bkoCombinedPlot
 * This is the output display component for displaying multiple Plots
 */

(function() {
  'use strict';
  var retfunc = function(plotUtils, combinedplotFormatter, bkCellMenuPluginManager) {
    var CELL_TYPE = "bko-combinedplot";
    return {
      template :
          "<canvas></canvas>" +
          "

" +
          "
" +
          "<bk-output-display type='Plot' ng-repeat='m in models' model='m'></bk-output-display>" +
          "
",
      controller : function($scope) {
        $scope.getShareMenuPlugin = function() {
          return bkCellMenuPluginManager.getPlugin(CELL_TYPE);
        };
        $scope.$watch("getShareMenuPlugin()", function() {
          var newItems = bkCellMenuPluginManager.getMenuItems(CELL_TYPE, $scope);
          $scope.model.resetShareMenuItems(newItems);
        });
        $scope.model.saveAsSvg = function(){
          return $scope.saveAsSvg();
        };
        $scope.model.saveAsPng = function(){
          return $scope.saveAsPng();
        };
      },
      link : function(scope, element, attrs) {
        scope.canvas = element.find("canvas")[0];
        scope.canvas.style.display="none";

        scope.initLayout = function() {
          var model = scope.stdmodel;
          if (model.title != null) {
            element.find("#combplotTitle").text(model.title).css("width", scope.width || scope.stdmodel.plotSize.width);
          }
        };

        scope.standardizeData = function() {
          var model = scope.model.getCellModel();
          scope.stdmodel = combinedplotFormatter.standardizeModel(model, scope.prefs);
        };

        scope.prepareSavedState = function(state) {
          state.focus = scope.calcRange();
          scope.width = scope.stdmodel.plotSize.width;
        };

        scope.applySavedState = function(state) {
          scope.state = state;
          scope.width = state.width;
        };

        scope.preparePlotModels = function() {
          var models = [];
          var plots = scope.stdmodel.plots;

          // create a plot model and a saved state for each plot
          for (var i = 0; i < plots.length; i++) {

            var plotmodel = plots[i];
            plotmodel.plotIndex = i;
            var pl = {
              model : plotmodel,
              state : { },
              getCellModel : function() {
                return this.model;
              },
              getDumpState: function() {
                return this.state;
              },
              setDumpState: function(s) {
                this.state = s;
                if (scope.model.setDumpState !== undefined) {
                  scope.model.setDumpState(scope.dumpState());
                }
              },
              resetShareMenuItems : function() {
              },
              getFocus : function() {
                return scope.focus;
              },
              updateFocus : function(focus) {
                scope.focus = {};
                _(scope.focus).extend(focus);
                scope.$apply();
              },
              updateWidth : function(width) {
                scope.width = width;
                element.find("#combplotTitle").css("width", width);
                scope.$apply();
              },
              updateMargin : function() {
                // if any of plots has left-positioned legend we should update left margin (with max value)
                // for all plots (to adjust vertical position)
                var plots = element.find("#plotContainer");
                var maxMargin = 0;

                plots.each(function() {
                  var value = parseFloat($(this).css('margin-left'));
                  maxMargin = _.max([value, maxMargin]);
                });
                plots.css("margin-left", maxMargin);

                //increase margin if two next plots have bottom and top legends
                var plotsCount = plots.size();
                plots.each(function(index) {
                  if(index + 1 < plotsCount){
                    var bottomMargin = parseFloat($(this).css('margin-bottom'));
                    var nextPlotTopMargin = parseFloat($(plots[index + 1]).css('margin-top'));
                    $(this).css("margin-bottom", bottomMargin + nextPlotTopMargin);
                    $(plots[index + 1]).css('margin-top', 0);
                  }
                });
              },
              getWidth : function() {
                return scope.width;
              }
            };
            models.push(pl);
          }
          scope.models = models;
        };

        scope.calcRange = function() {
          var xl = 1E100, xr = 0;
          var plots = scope.stdmodel.plots;
          for (var i = 0; i < plots.length; i++) {
            var plotmodel = plots[i]; // models are already standardized at this point
            var ret = plotUtils.getDefaultFocus(plotmodel);
            xl = Math.min(xl, ret.defaultFocus.xl);
            xr = Math.max(xr, ret.defaultFocus.xr);
          }
          return {
            "xl" : xl,
            "xr" : xr
          };
        };

        scope.dumpState = function() {
          var ret = { };
          ret.focus = scope.focus;
          ret.width = scope.width;
          ret.subplots = [];
          for (var i = 0; i < scope.models.length; i++) {
            ret.subplots.push(scope.models[i].state);
          }
          return ret;
        };

        scope.init = function() {
          scope.standardizeData();
          scope.preparePlotModels();
          scope.initLayout();
          scope.calcRange();

          if (scope.model.getDumpState !== undefined) {
            var savedstate = scope.model.getDumpState();
            if (savedstate !== undefined && savedstate.subplots !== undefined) {
              for (var i = 0; i < scope.models.length; i++) {
                scope.models[i].state = savedstate.subplots[i];
              }
              scope.width = savedstate.width;
              scope.focus = savedstate.focus;
            } else if (scope.models !== undefined) {
              scope.focus = scope.calcRange();
              for (var i = 0; i < scope.models.length; i++) {
                scope.models[i].state = { };
              }
              scope.model.setDumpState(scope.dumpState());
            }
          }
        };

        if (scope.model.getDumpState !== undefined) {
          scope.getDumpState = function() {
            return scope.model.getDumpState();
          };
        }

        scope.init();

        if (scope.model.getDumpState !== undefined) {
          scope.$watch('getDumpState()', function(result) {
            if (result !== undefined && result.subplots === undefined && scope.models !== undefined) {
              for (var i = 0; i < scope.models.length; i++) {
                scope.models[i].state = { };
              }
              scope.model.setDumpState(scope.dumpState());
            }
          });
        }

        scope.getCellModel = function() {
          return scope.model.getCellModel();
        };
        scope.$watch('getCellModel()', function() {
          scope.init();
        });

        scope.getSvgToSave = function(){
          var plots = scope.stdmodel.plots;

          var combinedSvg = $("<svg></svg>").attr('xmlns', 'http://www.w3.org/2000/svg').attr('class', 'svg-export');

          var plotTitle = element.find("#combplotTitle");

          plotUtils.addTitleToSvg(combinedSvg[0], plotTitle, {
            width: plotTitle.width(),
            height: plotUtils.getElementActualHeight(plotTitle)
          });

          var combinedSvgHeight = plotUtils.getElementActualHeight(plotTitle, true);
          for (var i = 0; i < plots.length; i++) {
            var svg = plots[i].getSvgToSave();
            plotUtils.translateChildren(svg, 0, combinedSvgHeight);
            combinedSvgHeight += $(svg).outerHeight(true);
            combinedSvg.append(svg.children);
          }
          combinedSvg.attr("width", scope.width || scope.stdmodel.plotSize.width);
          combinedSvg.attr("height", combinedSvgHeight);
          return combinedSvg[0];
        };

        scope.saveAsSvg = function() {
          var html = scope.getSvgToSave().outerHTML;
          var fileName = _.isEmpty(scope.stdmodel.title) ? 'combinedplot' : scope.stdmodel.title;
          plotUtils.download('data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(html))), fileName + '.svg');
        };

        scope.saveAsPng = function() {
          var svg = scope.getSvgToSave();

          scope.canvas.width = svg.getAttribute("width");
          scope.canvas.height = svg.getAttribute("height");

          var imgsrc = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg.outerHTML)));
          var fileName = _.isEmpty(scope.stdmodel.title) ? 'combinedplot' : scope.stdmodel.title;
          plotUtils.drawPng(scope.canvas, imgsrc, fileName + '.png');
        };

      }
    };
  };
  beaker.bkoDirective("CombinedPlot",
      ["plotUtils", "combinedplotFormatter", "bkCellMenuPluginManager", retfunc]);
})();


text:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Categories on Hana Fatima</title>
    <link>/categories/</link>
    <description>Recent content in Categories on Hana Fatima</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>&copy; 2018 Hana Fatima</copyright>

	<atom:link href="/categories/index.xml" rel="self" type="application/rss+xml" />

  </channel>
</rss>


text:
import {RegionState} from '../regions/models';

/**
 * Represents all state for an application.
 *
 * Given all views are displayed in Regions, the state is therefore modeled around the regions.
 */
export interface AppState {
    regionState: RegionState[];
}

/**
 * Provides a users state for the first time they load the application.
 */
export interface AppDefaultStateProvider {
    getDefaultAppState(): AppState;
}

/**
 * A 'no op' sate provider.
 */
export const NoopAppDefaultStateProvider: AppDefaultStateProvider = {
    getDefaultAppState(): AppState {
        return {
            regionState: []
        };
    }
};