text:
const moment = require('moment');
const columnify = require('columnify');
const plasma = require('plasma');
const _ = require('lodash');

module.exports = function (verb) {
  verb.options = verb.options || {};
  var data = {};

  exports.changelog = function (changelog) {
    var opts = _.extend({}, verb.options, {changelog: changelog});

    var dataFile = opts.changelog || verb.cwd('CHANGELOG');
    data = plasma({src: dataFile}, {lang: 'yaml'});

    try {
      var changes = [];

      // Convert changelog object to an array. We want the
      // version key to convert to `version: "v0.1.0"`
      for (var i in data) {
        changes.push({
          date: ' * ' + moment(data[i].date).format('YYYY-MM-DD'),
          version: i,
          changes: data[i].changes
        });
      }

      // Prettify the changelog with columnify
      changes = columnify(changes, _.extend({
        columnSplitter: '   ',
        headingTransform: function (key) {
          return ('**' + key + '**').toUpperCase();
        },
        config: {
          changes: {
            maxWidth: 75,
          }
        }
      }, opts));

      // Print out the changes
      return changes;

    } catch (err) {
      verb.verbose(err);
      verb.context.changes = {};
    }
  };
  // Add raw `history` to the context
  verb.context.history = exports.history = data;
  return exports;
};


text:
package org.jbpm.test.regression.event;

import java.util.Arrays;
import java.util.Collection;

import org.jbpm.test.JbpmTestCase;
import org.jbpm.workflow.instance.WorkflowRuntimeException;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.runtime.process.WorkItem;
import org.kie.api.runtime.process.WorkItemHandler;
import org.kie.api.runtime.process.WorkItemManager;
import qa.tools.ikeeper.annotation.BZ;

@BZ("1175689")
@RunWith(Parameterized.class)
public class BoundaryErrorEventTest extends JbpmTestCase {

    private static final String PROCESS_PREFIX = "org/jbpm/test/regression/event/BoundaryErrorEvent-";
    private static final String PROCESS_ID = "org.jbpm.test.regression.event.BoundaryErrorEvent";

    private KieSession ksession;

    public BoundaryErrorEventTest(boolean persistence) {
        super(persistence);
    }

    @Parameterized.Parameters
    public static Collection<Object[]> persistence() {
        Object[][] data = new Object[][]{{false}, {true}};
        return Arrays.asList(data);
    }

    @Override
    @After
    public void tearDown() throws Exception {
        if (ksession != null) {
            ksession.dispose();
            ksession = null;
        }
        super.tearDown();
    }

    @Test
    public void testBoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRef() {
        try {
            startInstance("WithErrorCodeWithStructureRef.bpmn2");
            fail("This is not a default handler. So WorkflowRuntimeException must be thrown");
        } catch (WorkflowRuntimeException e) {
            //Pass test when thrown
        }
    }

    @Test
    public void testBoundaryErrorEventDefaultHandlerWithErrorCodeWithoutStructureRef() {
        try {
            startInstance("WithErrorCodeWithoutStructureRef.bpmn2");
            fail("This is not a default handler. So WorkflowRuntimeException must be thrown");
        } catch (WorkflowRuntimeException e) {
            //Pass test when thrown
        }
    }

    @Test
    public void testBoundaryErrorEventDefaultHandlerWithErrorCodeMatchWithStructureRef() {
        ProcessInstance processInstance = startInstance("WithErrorCodeMatchWithStructureRef.bpmn2");
        assertNodesTriggered(processInstance);
    }

    @Test
    public void testBoundaryErrorEventDefaultHandlerWithErrorCodeMatchWithoutStructureRef() {
        ProcessInstance processInstance = startInstance("WithErrorCodeMatchWithoutStructureRef.bpmn2");
        assertNodesTriggered(processInstance);
    }

    @Test
    public void testBoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRef() {
        ProcessInstance processInstance = startInstance("WithoutErrorCodeWithStructureRef.bpmn2");
        assertNodesTriggered(processInstance);
    }

    @Test
    public void testBoundaryErrorEventDefaultHandlerWithoutErrorCodeWithoutStructureRef() {
        ProcessInstance processInstance = startInstance("WithoutErrorCodeWithoutStructureRef.bpmn2");
        assertNodesTriggered(processInstance);
    }

    private ProcessInstance startInstance(String resourceSuffix) {
        ksession = createKSession(PROCESS_PREFIX + resourceSuffix);
        ExceptionWorkItemHandler handler = new ExceptionWorkItemHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
        return ksession.startProcess(PROCESS_ID);
    }

    private void assertNodesTriggered(ProcessInstance pi) {
        assertNodeTriggered(pi.getId(), "Start", "User Task", "MyBoundaryErrorEvent", "Script Task 1");
    }

    private class ExceptionWorkItemHandler implements WorkItemHandler {

        @Override
        public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
            throw new RuntimeException();
        }

        @Override
        public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {

        }

    }

}

redpajama_set_name: RedPajamaGithub


text:
import wios
import unittest
import mock

class TestConfig(unittest.TestCase):

    def run_config(self, return_value):
        wios.xml_http_request = mock.MagicMock(return_value=return_value)
        return wios.Config('someurl')

    def test_update_no_config_key(self):
        with self.assertRaises(wios.ResponseError):
            self.run_config({})

    def test_get_raw_config_sunny_day(self):
        config = self.run_config({'config': {}})
        self.assertEqual({}, config.get_raw_config(), 'Config should be empty')

    def test_get_raw_stations_no_stations_key(self):
        config = self.run_config({'config': {}})
        with self.assertRaises(wios.ResponseError):
            config.get_raw_stations()

    def test_get_raw_stations_sunny_day(self):
        config = self.run_config({'config': {'stations': []}})
        self.assertEqual([], config.get_raw_stations(), 'Config should be empty')

    def test_get_raw_channels_no_channels_key(self):
        config = self.run_config({'config': {}})
        with self.assertRaises(wios.ResponseError):
            config.get_raw_channels()

    def test_get_raw_channels_sunny_day(self):
        config = self.run_config({'config': {'channels': []}})
        self.assertEqual([], config.get_raw_channels(), 'Config should be empty')

    def test_get_raw_params_no_params_key(self):
        config = self.run_config({'config': {}})
        with self.assertRaises(wios.ResponseError):
            config.get_raw_params()

    def test_get_raw_params_sunny_day(self):
        config = self.run_config({'config': {'params': []}})
        self.assertEqual([], config.get_raw_params(), 'Config should be empty')

    def test_get_raw_thresholds_no_thresholds_key(self):
        config = self.run_config({'config': {}})
        with self.assertRaises(wios.ResponseError):
            config.get_raw_thresholds()

    def test_get_raw_thresholds_sunny_day(self):
        config = self.run_config({'config': {'thresholds': []}})
        self.assertEqual([], config.get_raw_thresholds(), 'Config should be empty')


text:
layout: has-masthead
---

Contact

Please contact us for further information or sign up for our newsletter to stay up to date with our latest news.

Email info@carlislephoto.org.uk

Phone +44 (0) 1234 567890


text:
using System.Runtime.Serialization;

namespace Cielo4NetApi.Enumerators
{
    public enum Provider
    {
        [EnumMember(Value = "Bradesco")]
        Bradesco,
        [EnumMember(Value = "BancoDoBrasil")]
        BancoDoBrasil,
        [EnumMember(Value = "Simulado")]
        Simulado,
        [EnumMember(Value = "Cielo")]
        Cielo
    }
}


text:
package com.fireflysource.net.http.common.model;

import com.fireflysource.common.string.StringUtils;

import java.util.Objects;

public class HttpField {

    private final static String ZERO_QUALITY = "q=0";
    private final HttpHeader header;
    private final String name;
    private final String value;
    // cached hashcode for case insensitive name
    private int hash = 0;

    public HttpField(HttpHeader header, String name, String value) {
        this.header = header;
        this.name = name;
        this.value = value;
    }

    public HttpField(HttpHeader header, String value) {
        this(header, header.getValue(), value);
    }

    public HttpField(HttpHeader header, HttpHeaderValue value) {
        this(header, header.getValue(), value.getValue());
    }

    public HttpField(String name, String value) {
        this(HttpHeader.CACHE.get(name), name, value);
    }

    public HttpHeader getHeader() {
        return header;
    }

    public String getName() {
        return name;
    }

    public String getLowerCaseName() {
        return header != null ? header.getLowerCaseValue() : StringUtils.asciiToLowerCase(name);
    }

    public String getValue() {
        return value;
    }

    public int getIntValue() {
        return Integer.parseInt(value);
    }

    public long getLongValue() {
        return Long.parseLong(value);
    }

    public String[] getValues() {
        if (value == null)
            return null;

        QuotedCSV list = new QuotedCSV(false, value);
        return list.getValues().toArray(new String[list.size()]);
    }

    /**
     * Look for a value in a possible multi valued field
     *
     * @param search Values to search for (case insensitive)
     * @return True iff the value is contained in the field value entirely or
     * as an element of a quoted comma separated list. List element parameters (eg qualities) are ignored,
     * except if they are q=0, in which case the item itself is ignored.
     */
    public boolean contains(String search) {
        if (search == null)
            return value == null;
        if (search.length() == 0)
            return false;
        if (value == null)
            return false;
        if (search.equals(value))
            return true;

        search = StringUtils.asciiToLowerCase(search);

        int state = 0;
        int match = 0;
        int param = 0;

        for (int i = 0; i < value.length(); i++) {
            char c = value.charAt(i);
            switch (state) {
                case 0: // initial white space
                    switch (c) {
                        case '"': // open quote
                            match = 0;
                            state = 2;
                            break;

                        case ',': // ignore leading empty field
                            break;

                        case ';': // ignore leading empty field parameter
                            param = -1;
                            match = -1;
                            state = 5;
                            break;

                        case ' ': // more white space
                        case '\t':
                            break;

                        default: // character
                            match = Character.toLowerCase(c) == search.charAt(0) ? 1 : -1;
                            state = 1;
                            break;
                    }
                    break;

                case 1: // In token
                    switch (c) {
                        case ',': // next field
                            // Have we matched the token?
                            if (match == search.length())
                                return true;
                            state = 0;
                            break;

                        case ';':
                            param = match >= 0 ? 0 : -1;
                            state = 5; // parameter
                            break;

                        default:
                            if (match > 0) {
                                if (match < search.length())
                                    match = Character.toLowerCase(c) == search.charAt(match) ? (match + 1) : -1;
                                else if (c != ' ' && c != '\t')
                                    match = -1;
                            }
                            break;

                    }
                    break;

                case 2: // In Quoted token
                    switch (c) {
                        case '\\': // quoted character
                            state = 3;
                            break;

                        case '"': // end quote
                            state = 4;
                            break;

                        default:
                            if (match >= 0) {
                                if (match < search.length())
                                    match = Character.toLowerCase(c) == search.charAt(match) ? (match + 1) : -1;
                                else
                                    match = -1;
                            }
                    }
                    break;

                case 3: // In Quoted character in quoted token
                    if (match >= 0) {
                        if (match < search.length())
                            match = Character.toLowerCase(c) == search.charAt(match) ? (match + 1) : -1;
                        else
                            match = -1;
                    }
                    state = 2;
                    break;

                case 4: // WS after end quote
                    switch (c) {
                        case ' ': // white space
                        case '\t': // white space
                            break;

                        case ';':
                            state = 5; // parameter
                            break;

                        case ',': // end token
                            // Have we matched the token?
                            if (match == search.length())
                                return true;
                            state = 0;
                            break;

                        default:
                            // This is an illegal token, just ignore
                            match = -1;
                    }
                    break;

                case 5:  // parameter
                    switch (c) {
                        case ',': // end token
                            // Have we matched the token and not q=0?
                            if (param != ZERO_QUALITY.length() && match == search.length())
                                return true;
                            param = 0;
                            state = 0;
                            break;

                        case ' ': // white space
                        case '\t': // white space
                            break;

                        default:
                            if (param >= 0) {
                                if (param < ZERO_QUALITY.length())
                                    param = Character.toLowerCase(c) == ZERO_QUALITY.charAt(param) ? (param + 1) : -1;
                                else if (c != '0' && c != '.')
                                    param = -1;
                            }

                    }
                    break;

                default:
                    throw new IllegalStateException();
            }
        }

        return param != ZERO_QUALITY.length() && match == search.length();
    }

    @Override
    public String toString() {
        String v = getValue();
        return getName() + ": " + (v == null ? "" : v);
    }

    public boolean isSameName(HttpField field) {
        @SuppressWarnings("ReferenceEquality")
        boolean sameObject = (field == this);

        if (field == null)
            return false;
        if (sameObject)
            return true;
        if (header != null && header == field.getHeader())
            return true;
        if (name.equalsIgnoreCase(field.getName()))
            return true;
        return false;
    }

    private int nameHashCode() {
        int h = this.hash;
        int len = name.length();
        if (h == 0 && len > 0) {
            for (int i = 0; i < len; i++) {
                // simple case insensitive hash
                char c = name.charAt(i);
                // assuming us-ascii (per last paragraph on http://tools.ietf.org/html/rfc7230#section-3.2.4)
                if ((c >= 'a' && c <= 'z'))
                    c -= 0x20;
                h = 31 * h + c;
            }
            this.hash = h;
        }
        return h;
    }

    @Override
    public int hashCode() {
        int vhc = Objects.hashCode(value);
        if (header == null)
            return vhc ^ nameHashCode();
        return vhc ^ header.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof HttpField))
            return false;
        HttpField field = (HttpField) o;
        if (header != field.getHeader())
            return false;
        if (!name.equalsIgnoreCase(field.getName()))
            return false;
        if (value == null && field.getValue() != null)
            return false;
        return Objects.equals(value, field.getValue());
    }

    public static class IntValueHttpField extends HttpField {
        private final int intValue;

        public IntValueHttpField(HttpHeader header, String name, String value, int intValue) {
            super(header, name, value);
            this.intValue = intValue;
        }

        public IntValueHttpField(HttpHeader header, String name, String value) {
            this(header, name, value, Integer.parseInt(value));
        }

        public IntValueHttpField(HttpHeader header, String name, int intValue) {
            this(header, name, Integer.toString(intValue), intValue);
        }

        public IntValueHttpField(HttpHeader header, int value) {
            this(header, header.getValue(), value);
        }

        @Override
        public int getIntValue() {
            return intValue;
        }

        @Override
        public long getLongValue() {
            return intValue;
        }
    }

    public static class LongValueHttpField extends HttpField {
        private final long longValue;

        public LongValueHttpField(HttpHeader header, String name, String value, long longValue) {
            super(header, name, value);
            this.longValue = longValue;
        }

        public LongValueHttpField(HttpHeader header, String name, String value) {
            this(header, name, value, Long.parseLong(value));
        }

        public LongValueHttpField(HttpHeader header, String name, long value) {
            this(header, name, Long.toString(value), value);
        }

        public LongValueHttpField(HttpHeader header, long value) {
            this(header, header.getValue(), value);
        }

        @Override
        public int getIntValue() {
            return (int) longValue;
        }

        @Override
        public long getLongValue() {
            return longValue;
        }
    }
}


text:
import { EntityId } from '@reduxjs/toolkit'
import { Component, Fragment, h, Host, Prop, State, Watch } from '@stencil/core'
import { option as O } from 'fp-ts'
import { pipe } from 'fp-ts/function'
import { File } from 'stencila'
import { state } from '../../../store'
import { selectDoc } from '../../../store/documentPane/documentPaneSelectors'
import { updateProjectSettings } from '../../../store/project/projectSelectors'
import { SessionsStoreKeys, sessionStore } from '../../../store/sessionStore'

const themes = {
  elife: 'eLife',
  giga: 'GigaScience',
  latex: 'LaTeX',
  stencila: 'Stencila',
  tufte: 'Tufte',
  wilmore: 'Wilmore',
}

@Component({
  tag: 'app-document-preview',
  styleUrl: 'app-document-preview.css',
  shadow: true,
})
export class AppDocumentPreview {
  /**
   * ID of the document to be previewed
   */
  @Prop() documentId: EntityId

  private updateDoc = (id: EntityId) => {
    const doc = selectDoc(state)(id)
    if (doc) {
      this.doc = doc
    }
  }

  @Watch('documentId')
  documentIdWatchHandler(newValue: string, prevValue: string) {
    if (newValue !== prevValue) {
      this.updateDoc(newValue)
    }
  }

  @State() doc: File

  @State() serverUrl: URL | undefined

  @State() theme = 'stencila'

  private onThemeChange = (e: Event) => {
    this.theme = (e.target as HTMLSelectElement).value
    updateProjectSettings({ theme: this.theme })
  }

  private getServerUrl = (): URL | undefined =>
    pipe(
      sessionStore.get(SessionsStoreKeys.SERVER_URL),
      O.map((serverUrl) => {
        window.clearInterval(this.serverUrlPollRef)
        this.serverUrl = new window.URL(serverUrl)
        return this.serverUrl
      }),
      O.getOrElseW(() => undefined)
    )

  private serverUrlPollRef: number
  private pollForServerUrl = () => {
    this.serverUrlPollRef = window.setInterval(() => this.getServerUrl(), 200)
  }

  componentWillLoad() {
    this.updateDoc(this.documentId)
    this.getServerUrl()
    if (this.serverUrl === undefined) {
      this.pollForServerUrl()
    }
  }

  render() {
    return (
      <Host>
        <div class="app-document-preview">
          {this.serverUrl === undefined ? (
            'Loading'
          ) : (
            <Fragment>
              <iframe
                title="document-preview"
                src={`${this.serverUrl.origin}${this.doc.path}${this.serverUrl.search}&theme=${this.theme}`}
              />

              <menu>
                <label aria-label="Project Theme">
                  <stencila-icon icon="palette"></stencila-icon>
                  <select onChange={this.onThemeChange}>
                    {Object.entries(themes).map(([value, name]) => (
                      <option value={value} selected={value === this.theme}>
                        {name}
                      </option>
                    ))}
                  </select>
                </label>
              </menu>
            </Fragment>
          )}
        </div>
      </Host>
    )
  }
}


text:
import ast
import sys
from unittest import mock

from tests.unit import test
from tests.unit import test_mock

class VariantsTestCase(test.TestCase):
    def setUp(self):
        self.variants = test_mock.Variants(["test", "foo", "bar"])
        super(VariantsTestCase, self).setUp()

    def test_print(self):
        self.assertEqual(
            "{'mock_test', 'mock_foo', 'mock_bar'}",
            repr(self.variants)
        )

    def test_print_long(self):
        variants = test_mock.Variants(["test", "foo", "bar", "buz"])
        self.assertEqual(
            "{'mock_test', 'mock_foo', 'mock_bar', ...}",
            repr(variants)
        )

    def test_equal(self):
        self.assertEqual(["test", "foo", "bar"], self.variants)
        self.assertEqual(self.variants, self.variants)

        mock_variants = mock.Mock(variants=["test", "foo", "bar"])
        self.assertEqual(mock_variants, self.variants)

        self.assertNotEqual(["abc"], self.variants)

    def test_contains(self):
        self.assertIn("test", self.variants)
        self.assertNotIn("abc", self.variants)

class FuncMockArgsDecoratorsCheckerTestCase(test.TestCase):
    code = """
@mock.patch("os.path.join")
@mock.patch("pkg.module1.OtherObject.method")
@mock.patch("pkg.module2.MyClassObject.method")
@mock.patch.object(pkg.SomeKindOfObject, "abc")
@mock.patch.object(pkg.MyClassObject, "abc")
def test_func(self, mock_args, mock_args2, mock_some_longer_args):
    pass
"""
    code_mock_decorators = [
        ["abc", "my_class_object_abc", "pkg_my_class_object_abc"],
        ["some_kind_of_object_abc", "pkg_some_kind_of_object_abc"],
        [
            "method",
            "my_class_object_method",
            "module2_my_class_object_method",
            "pkg_module2_my_class_object_method"
        ],
        [
            "other_object_method",
            "module1_other_object_method",
            "pkg_module1_other_object_method",
        ],
        [
            "join",
            "path_join",
            "os_path_join"
        ],
    ]
    code_mock_args = ["args", "args2", "some_longer_args"]

    def setUp(self):
        super(FuncMockArgsDecoratorsCheckerTestCase, self).setUp()
        self.visitor = test_mock.FuncMockArgsDecoratorsChecker()
        self.visitor.classname_python = ""
        self.visitor.globals_["EXPR"] = "expression"
        self.tree = self._parse_expr(self.code)

    def _parse_expr(self, code):
        firstbody = ast.parse(code).body[0]
        if isinstance(firstbody, ast.Expr):
            return firstbody.value
        return firstbody

    def test__get_name(self):
        self.assertEqual(
            "os.path.join",
            self.visitor._get_name(self._parse_expr("os.path.join"))
        )

    def test__get_value_str(self):
        self.assertEqual(
            "not.your.fault",
            self.visitor._get_value(self._parse_expr("'not.your.fault'"))
        )

    def test__get_value_mod(self):
        self.assertEqual(
            "some.crazy.mod.expression",
            self.visitor._get_value(
                self._parse_expr("'some.crazy.mod.%s' % EXPR")
            )
        )

    def test__get_value_add(self):
        self.assertEqual(
            "expression.some.crazy.add",
            self.visitor._get_value(
                self._parse_expr("EXPR + '.some.crazy.add'")
            )
        )

    def test__get_value_global(self):
        self.assertEqual(
            "expression",
            self.visitor._get_value(
                self._parse_expr("EXPR")
            )
        )

    def test__get_value_none(self):
        self.assertRaises(
            ValueError,
            self.visitor._get_value,
            ast.parse("import abc")
        )

    def test__get_value_asserts(self):
        self.assertRaises(
            ValueError,
            self.visitor._get_value,
            self._parse_expr("EXPR % 'abc'")
        )

        self.assertRaises(
            ValueError,
            self.visitor._get_value,
            self._parse_expr("'abc' + EXPR")
        )

    def test__camelcase_to_python_camel(self):
        self.assertEqual(
            "some_class_name",
            self.visitor._camelcase_to_python("SomeClassName")
        )

    def test__camelcase_to_python_python(self):
        self.assertEqual(
            "some_python_name",
            self.visitor._camelcase_to_python("some_python_name")
        )

    def test__get_mocked_class_value_variants_matches_class(self):
        self.visitor.classname_python = "foo_class"
        self.assertEqual(
            ["mocked_obj", "foo_class_mocked_obj"],
            self.visitor._get_mocked_class_value_variants(
                class_name="FooClass",
                mocked_name="MockedObj"
            )
        )

    def test__get_mocked_class_value_variants_different_class(self):
        self.visitor.classname_python = "foo_class"
        self.assertEqual(
            ["bar_class_mocked_obj"],
            self.visitor._get_mocked_class_value_variants(
                class_name="BarClass",
                mocked_name="MockedObj"
            )
        )

    def test__add_pkg_optional_prefixes(self):
        self.assertEqual(
            ["foo", "bar", "bar_class_bar", "pkg_bar_class_bar",
             "some_pkg_bar_class_bar"],
            self.visitor._add_pkg_optional_prefixes(
                "some.pkg.BarClass".split("."),
                ["foo", "bar"]
            )
        )

    def test__get_mocked_name_variants_single(self):
        self.assertEqual(
            ["foo_bar"],
            self.visitor._get_mocked_name_variants(
                "FooBar"
            )
        )

        self.assertEqual(
            ["foobar"],
            self.visitor._get_mocked_name_variants(
                "foobar"
            )
        )

    def test__get_mocked_name_variants_classname(self):
        self.visitor.classname_python = "foo_bar"
        self.assertEqual(
            ["method", "foo_bar_method", "pkg_foo_bar_method"],
            self.visitor._get_mocked_name_variants(
                "pkg.FooBar.method"
            )
        )

        self.visitor.classname_python = ""
        self.assertEqual(
            ["foo_bar_method", "pkg_foo_bar_method"],
            self.visitor._get_mocked_name_variants(
                "pkg.FooBar.method"
            )
        )

    def test__get_mocked_name_variants_pkg(self):
        self.assertEqual(
            ["method", "pkg_method", "long_pkg_method",
             "some_long_pkg_method"],
            self.visitor._get_mocked_name_variants(
                "some.long.pkg.method"
            )
        )

    def test__get_mock_decorators_variants(self):
        self.visitor.classname_python = "my_class_object"
        self.assertEqual(
            self.code_mock_decorators,
            self.visitor._get_mock_decorators_variants(self.tree)
        )

    def test__get_mock_args(self):
        self.assertEqual(
            self.code_mock_args,
            self.visitor._get_mock_args(self.tree)
        )

    def test_visit_Assign(self):
        self.visitor.globals_ = {}

        self.visitor.visit_Assign(
            self._parse_expr("ABC = '20' + '40'")
        )
        self.assertEqual(
            {"ABC": "2040"},
            self.visitor.globals_
        )

        self.visitor.visit_Assign(
            self._parse_expr("abc = 20 + 40")
        )
        self.assertEqual(
            {"ABC": "2040", "abc": 60},
            self.visitor.globals_
        )

    def test_visit_ClassDef(self):
        self.visitor.visit_ClassDef(
            self._parse_expr("class MyObject(object): pass")
        )
        self.assertEqual(
            "my_object",
            self.visitor.classname_python
        )

        self.visitor.visit_ClassDef(
            self._parse_expr("class YourObjectTestCase(object): pass")
        )
        self.assertEqual(
            "your_object",
            self.visitor.classname_python
        )

    def test_visit_FunctionDef_empty_decs(self):
        self.visitor._get_mock_decorators_variants = mock.Mock(
            return_value=[]
        )

        self.assertIsNone(self.visitor.visit_FunctionDef(self.tree))
        self.assertEqual([], self.visitor.errors)

        self.visitor._get_mock_decorators_variants.assert_called_once_with(
            self.tree
        )

    def test_visit_FunctionDef_good(self):
        self.visitor._get_mock_decorators_variants = mock.Mock(
            return_value=[
                ["foo", "foo_bar", "pkg_foo_bar"]
            ]
        )
        self.visitor._get_mock_args = mock.Mock(
            return_value=["pkg_foo_bar"]
        )

        self.assertIsNone(self.visitor.visit_FunctionDef(self.tree))
        self.assertEqual([], self.visitor.errors)

        self.visitor._get_mock_decorators_variants.assert_called_once_with(
            self.tree
        )
        self.visitor._get_mock_args.assert_called_once_with(
            self.tree
        )

    def test_visit_FunctionDef_misnamed(self):
        variants = test_mock.Variants(
            ["foo", "foo_bar", "pkg_foo_bar", "a"]
        )
        self.visitor._get_mock_decorators_variants = mock.Mock(
            return_value=[variants]
        )
        self.visitor._get_mock_args = mock.Mock(
            return_value=["bar_foo_misnamed"]
        )

        self.assertIsNone(self.visitor.visit_FunctionDef(self.tree))
        if sys.version_info < (3, 8):
            # https://github.com/python/cpython/pull/9731
            lineno = 2
        else:
            lineno = 7
        self.assertEqual(
            [
                {
                    "lineno": lineno,
                    "messages": [
                        "Argument 'mock_bar_foo_misnamed' misnamed; should be "
                        "either of %s that is derived from the mock decorator "
                        "args.\n" % variants
                    ],
                    "mismatch_pairs": [
                        ("bar_foo_misnamed", variants)
                    ]
                }
            ],
            self.visitor.errors)

        self.visitor._get_mock_decorators_variants.assert_called_once_with(
            self.tree
        )
        self.visitor._get_mock_args.assert_called_once_with(
            self.tree
        )

    def test_visit_FunctionDef_mismatch_args(self):
        variants = test_mock.Variants(
            ["foo", "foo_bar", "pkg_foo_bar", "a"]
        )
        self.visitor._get_mock_decorators_variants = mock.Mock(
            return_value=[variants]
        )
        self.visitor._get_mock_args = mock.Mock(
            return_value=["bar_foo_misnamed", "mismatched"]
        )

        self.assertIsNone(self.visitor.visit_FunctionDef(self.tree))
        if sys.version_info < (3, 8):
            # https://github.com/python/cpython/pull/9731
            lineno = 2
        else:
            lineno = 7
        self.assertEqual(
            [
                {
                    "lineno": lineno,
                    "messages": [
                        "Argument 'mock_bar_foo_misnamed' misnamed; should be "
                        "either of %s that is derived from the mock decorator "
                        "args.\n" % variants,
                        "Missing or malformed decorator for 'mock_mismatched' "
                        "argument."
                    ],
                    "args": self.visitor._get_mock_args.return_value,
                    "decs": [variants]
                }
            ],
            self.visitor.errors)

        self.visitor._get_mock_decorators_variants.assert_called_once_with(
            self.tree
        )
        self.visitor._get_mock_args.assert_called_once_with(
            self.tree
        )

    def test_visit_FunctionDef_mismatch_decs(self):
        variants = test_mock.Variants(
            ["foo", "foo_bar", "pkg_foo_bar", "a"]
        )
        self.visitor._get_mock_decorators_variants = mock.Mock(
            return_value=[variants]
        )
        self.visitor._get_mock_args = mock.Mock(
            return_value=[]
        )

        self.assertIsNone(self.visitor.visit_FunctionDef(self.tree))
        if sys.version_info < (3, 8):
            # https://github.com/python/cpython/pull/9731
            lineno = 2
        else:
            lineno = 7
        self.assertEqual(
            [
                {
                    "lineno": lineno,
                    "messages": [
                        "Missing or malformed argument for {'mock_foo', "
                        "'mock_foo_bar', 'mock_pkg_foo_bar', ...} decorator."
                    ],
                    "args": self.visitor._get_mock_args.return_value,
                    "decs": [variants]
                }
            ],
            self.visitor.errors)

        self.visitor._get_mock_decorators_variants.assert_called_once_with(
            self.tree
        )
        self.visitor._get_mock_args.assert_called_once_with(
            self.tree
        )

    def test_visit(self):
        self.visitor.classname_python = "my_class_object"
        self.visitor.visit(self.tree)

        self.assertEqual(
            self.code_mock_args,
            self.visitor.errors[0]["args"]
        )

        self.assertEqual(
            self.code_mock_decorators,
            self.visitor.errors[0]["decs"]
        )

        if sys.version_info < (3, 8):
            # https://github.com/python/cpython/pull/9731
            lineno = 2
        else:
            lineno = 7
        self.assertEqual(lineno, self.visitor.errors[0]["lineno"])

    def test_visit_ok(self):
        self.visitor.classname_python = "my_class_object"
        self.visitor.visit(
            self._parse_expr(
                """
class MyClassObjectTestCase(object):
    @mock.patch("foo.bar.MyClassObject.yep")
    @mock.patch("foo.bar.ClassName.ok")
    @mock.patch.object(pkg.FooClass, "method")
    def test_mockings(self, mock_pkg_foo_class_method, mock_class_name_ok,
                      mock_yep):
        pass
""")
        )

        self.assertEqual(
            [],
            self.visitor.errors
        )


text:
FactoryGirl.define do
  factory :user do
    sequence :username do |n|
      "user#{n}"
    end
    sequence :email do |n|
      "email#{n}@email.com"
    end
    password "pass123."
    password_confirmation "pass123."
    anonymous false
  end

  factory :anonymous_user, :class => User do
    anonymous true
  end
end


text:
typedef unsigned long DWORD;

namespace WinSvcLib {
	enum class ServiceAccessType : DWORD {
		QueryConfig			= 0x0001, // SERVICE_QUERY_CONFIG
		ChangeConfig		= 0x0002, // SERVICE_CHANGE_CONFIG
		QueryStatus			= 0x0004, // SERVICE_QUERY_STATUS
		EnumerateDependents	= 0x0008, // SERVICE_ENUMERATE_DEPENDENTS
		Start				= 0x0010, // SERVICE_START
		Stop				= 0x0020, // SERVICE_STOP
		PauseContinue		= 0x0040, // SERVICE_PAUSE_CONTINUE
		Interrogate			= 0x0080, // SERVICE_INTERROGATE
		UserDefinedControl	= 0x0100, // SERVICE_USER_DEFINED_CONTROL
		AllAccess			= 0xF01FF // SERVICE_ALL_ACCESS
	};
	enum class ServiceType : DWORD {
		KernelDriver		= 0x00000001, // SERVICE_KERNEL_DRIVER
		FileSystemDriver	= 0x00000002, // SERVICE_FILE_SYSTEM_DRIVER
		Adapter				= 0x00000004, // SERVICE_ADAPTER
		RecognizerDriver	= 0x00000008, // SERVICE_RECOGNIZER_DRIVER
		Driver				= 0x0000000B, // SERVICE_DRIVER
		Win32OwnProcess		= 0x00000010, // SERVICE_WIN32_OWN_PROCESS
		Win32ShareProcess	= 0x00000020, // SERVICE_WIN32_SHARE_PROCESS
		Win32				= 0x00000030, // SERVICE_WIN32
		InteractiveProcess	= 0x00000100, // SERVICE_INTERACTIVE_PROCESS
		TypeAll				= 0x0000013F  // SERVICE_TYPE_ALL
	};
	ServiceAccessType operator | (const ServiceAccessType A, const ServiceAccessType B);
	ServiceType operator | (const ServiceType A, const ServiceType B);
}
#endif


text:
<?php

namespace EVT\ApiBundle\Tests\DataFixtures\ORM;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use EVT\CoreDomainBundle\Model\LeadInformation;
use EVT\CoreDomainBundle\Entity\Lead;
use EVT\CoreDomainBundle\Entity\Showroom;
use EVT\CoreDomainBundle\Entity\Provider;
use EVT\CoreDomainBundle\Entity\Vertical;
use EVT\CoreDomain\Provider\ShowroomType;

class LoadLeadData implements FixtureInterface, ContainerAwareInterface
{
    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * {@inheritDoc}
     */
    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }
    public function load(ObjectManager $manager)
    {
        $userManager = $this->container->get('fos_user.user_manager');

        $user = $userManager->createUser();
        $user->setUsername('usernameManager');
        $user->setEmail('valid@emailManager.com');
        $user->setPlainPassword('passManager');
        $user->addRole('ROLE_MANAGER');
        $user->setName('nameManager');
        $user->setSurnames('surnamesManager');
        $user->setPhone('0132465987');

        $userManager->updateUser($user);

        $user2 = $userManager->createUser();
        $user2->setUsername('usernameManager2');
        $user2->setEmail('valid2@emailManager.com');
        $user2->setPlainPassword('passManager2');
        $user2->addRole('ROLE_MANAGER');
        $user2->setName('nameManager2');
        $user2->setSurnames('surnamesManager2');
        $user2->setPhone('0132465987');

        $userManager->updateUser($user2);

        $prov = new Provider();
        $prov->setName('name');
        $prov->setNotificationEmails(['valid@email.com']);
        $prov->setLocationLat(10);
        $prov->setLocationLong(10);
        $prov->setLocationAdminLevel1('test');
        $prov->setLocationAdminLevel2('test');
        $prov->setLocationCountry('Spain');
        $prov->setLang('es_ES');
        $prov->addGenericUser($user);
        $manager->persist($prov);

        $vert = new Vertical();
        $vert->setDomain('test.com');
        $vert->setLang('es_ES');
        $vert->setTimezone('Europe/Madrid');
        $manager->persist($vert);

        $showroom = new Showroom();
        $showroom->setProvider($prov);
        $showroom->setVertical($vert);
        $showroom->setType(ShowroomType::FREE);
        $showroom->setScore(0);
        $manager->persist($showroom);

        $leadInformation = new LeadInformation();
        $leadInformation->setKey("observations");
        $leadInformation->setValue("This is great");

        $lead = new Lead();
        $lead->setEventDate(new \DateTime('2014-02-20 23:50:26', new \DateTimeZone('UTC')));
        $lead->setEventLocationAdminLevel1('Madrid');
        $lead->setEventLocationAdminLevel2('Madrid');
        $lead->setEventLocationCountry('Spain');
        $lead->setEventLocationLat('24.45');
        $lead->setEventLocationLong('43.98');
        $lead->setEventType(1);
        $lead->setShowroom($showroom);
        $lead->setUserEmail('valid@email.com');
        $lead->setUserName('Pepe');
        $lead->setUserSurnames('Potamo');
        $lead->setUserPhone('919999999');
        $lead->setCreatedAt(new \DateTime('2013-10-10', new \DateTimeZone('UTC')));
        $lead->setReadAt(new \DateTime('2013-10-12', new \DateTimeZone('UTC')));
        $lead->addLeadInformation($leadInformation);

        $manager->persist($lead);

        $lead2 = new Lead();
        $lead2->setEventDate(new \DateTime('2014-01-25 13:55:56', new \DateTimeZone('UTC')));
        $lead2->setEventLocationAdminLevel1('Madrid');
        $lead2->setEventLocationAdminLevel2('Madrid');
        $lead2->setEventLocationCountry('Spain');
        $lead2->setEventLocationLat('24.45');
        $lead2->setEventLocationLong('43.98');
        $lead2->setEventType(1);
        $lead2->setShowroom($showroom);
        $lead2->setUserEmail('valid@email.com');
        $lead2->setUserName('Pepe');
        $lead2->setUserSurnames('Potamo');
        $lead2->setUserPhone('919999999');
        $lead2->setCreatedAt(new \DateTime('2013-11-11', new \DateTimeZone('UTC')));
        $lead2->setReadAt(new \DateTime('2013-10-01', new \DateTimeZone('UTC')));
        $lead2->addLeadInformation($leadInformation);

        $manager->persist($lead2);

        $manager->flush();
    }
}


text:
Td class

## Mom
DOM

## Parameters
* `OPTIONAL` params
* `OPTIONAL` params.rowspan
* `OPTIONAL` params.colspan

## Static Members
No static members.

## Public Members
No public members.


text:
package com.amazonaws.services.cloudformation.model;

import java.io.Serializable;
import javax.annotation.Generated;

/**
 *

 * The Change structure describes the changes AWS CloudFormation will perform if you execute the change
 * set.
 *

 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Change implements Serializable, Cloneable {

    /**
     *

     * The type of entity that AWS CloudFormation changes. Currently, the only entity type is Resource.
     *

     */
    private String type;
    /**
     *

     * A ResourceChange structure that describes the resource and action that AWS CloudFormation will
     * perform.
     *

     */
    private ResourceChange resourceChange;

    /**
     *

     * The type of entity that AWS CloudFormation changes. Currently, the only entity type is Resource.
     *

     *
     * @param type
     *        The type of entity that AWS CloudFormation changes. Currently, the only entity type is
     *        Resource.
     * @see ChangeType
     */

    public void setType(String type) {
        this.type = type;
    }

    /**
     *

     * The type of entity that AWS CloudFormation changes. Currently, the only entity type is Resource.
     *

     *
     * @return The type of entity that AWS CloudFormation changes. Currently, the only entity type is
     *         Resource.
     * @see ChangeType
     */

    public String getType() {
        return this.type;
    }

    /**
     *

     * The type of entity that AWS CloudFormation changes. Currently, the only entity type is Resource.
     *

     *
     * @param type
     *        The type of entity that AWS CloudFormation changes. Currently, the only entity type is
     *        Resource.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see ChangeType
     */

    public Change withType(String type) {
        setType(type);
        return this;
    }

    /**
     *

     * The type of entity that AWS CloudFormation changes. Currently, the only entity type is Resource.
     *

     *
     * @param type
     *        The type of entity that AWS CloudFormation changes. Currently, the only entity type is
     *        Resource.
     * @see ChangeType
     */

    public void setType(ChangeType type) {
        this.type = type.toString();
    }

    /**
     *

     * The type of entity that AWS CloudFormation changes. Currently, the only entity type is Resource.
     *

     *
     * @param type
     *        The type of entity that AWS CloudFormation changes. Currently, the only entity type is
     *        Resource.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see ChangeType
     */

    public Change withType(ChangeType type) {
        setType(type);
        return this;
    }

    /**
     *

     * A ResourceChange structure that describes the resource and action that AWS CloudFormation will
     * perform.
     *

     *
     * @param resourceChange
     *        A ResourceChange structure that describes the resource and action that AWS CloudFormation
     *        will perform.
     */

    public void setResourceChange(ResourceChange resourceChange) {
        this.resourceChange = resourceChange;
    }

    /**
     *

     * A ResourceChange structure that describes the resource and action that AWS CloudFormation will
     * perform.
     *

     *
     * @return A ResourceChange structure that describes the resource and action that AWS CloudFormation
     *         will perform.
     */

    public ResourceChange getResourceChange() {
        return this.resourceChange;
    }

    /**
     *

     * A ResourceChange structure that describes the resource and action that AWS CloudFormation will
     * perform.
     *

     *
     * @param resourceChange
     *        A ResourceChange structure that describes the resource and action that AWS CloudFormation
     *        will perform.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public Change withResourceChange(ResourceChange resourceChange) {
        setResourceChange(resourceChange);
        return this;
    }

    /**
     * Returns a string representation of this object; useful for testing and debugging.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getType() != null)
            sb.append("Type: ").append(getType()).append(",");
        if (getResourceChange() != null)
            sb.append("ResourceChange: ").append(getResourceChange());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof Change == false)
            return false;
        Change other = (Change) obj;
        if (other.getType() == null ^ this.getType() == null)
            return false;
        if (other.getType() != null && other.getType().equals(this.getType()) == false)
            return false;
        if (other.getResourceChange() == null ^ this.getResourceChange() == null)
            return false;
        if (other.getResourceChange() != null && other.getResourceChange().equals(this.getResourceChange()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode());
        hashCode = prime * hashCode + ((getResourceChange() == null) ? 0 : getResourceChange().hashCode());
        return hashCode;
    }

    @Override
    public Change clone() {
        try {
            return (Change) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

}


text:
<?php namespace Fisharebest\Localization\Language;

use Fisharebest\Localization\PluralRule\PluralRule1;
use Fisharebest\Localization\Territory\TerritoryGh;

class LanguageEe extends AbstractLanguage implements LanguageInterface {
	public function code() {
		return 'ee';
	}

	public function defaultTerritory() {
		return new TerritoryGh;
	}

	public function pluralRule() {
		return new PluralRule1;
	}
}


text:
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace CommonTools.Lib.fx45.UserControls.TextLabels
{
    public partial class DualText : UserControl
    {
        public string Text1
        {
            get { return (string)GetValue(Text1Property); }
            set { SetValue(Text1Property, value); }
        }
        public static readonly DependencyProperty Text1Property =
            DependencyProperty.Register("Text1", typeof(string), typeof(DualText));

        public string Text2
        {
            get { return (string)GetValue(Text2Property); }
            set { SetValue(Text2Property, value); }
        }
        public static readonly DependencyProperty Text2Property =
            DependencyProperty.Register("Text2", typeof(string), typeof(DualText));

        public GridLength? Text1Width
        {
            get { return (GridLength?)GetValue(Text1WidthProperty); }
            set { SetValue(Text1WidthProperty, value); }
        }
        public static readonly DependencyProperty Text1WidthProperty =
            DependencyProperty.Register("Text1Width", typeof(GridLength?), typeof(DualText));

        public GridLength? GapWidth
        {
            get { return (GridLength?)GetValue(GapWidthProperty); }
            set { SetValue(GapWidthProperty, value); }
        }
        public static readonly DependencyProperty GapWidthProperty =
            DependencyProperty.Register("GapWidth", typeof(GridLength?), typeof(DualText));

        public GridLength? Text2Width
        {
            get { return (GridLength?)GetValue(Text2WidthProperty); }
            set { SetValue(Text2WidthProperty, value); }
        }
        public static readonly DependencyProperty Text2WidthProperty =
            DependencyProperty.Register("Text2Width", typeof(GridLength?), typeof(DualText));

        public TextAlignment? Text1Alignment
        {
            get { return (TextAlignment?)GetValue(Text1AlignmentProperty); }
            set { SetValue(Text1AlignmentProperty, value); }
        }
        public static readonly DependencyProperty Text1AlignmentProperty =
            DependencyProperty.Register("Text1Alignment", typeof(TextAlignment?), typeof(DualText));

        public TextAlignment? Text2Alignment
        {
            get { return (TextAlignment?)GetValue(Text2AlignmentProperty); }
            set { SetValue(Text2AlignmentProperty, value); }
        }
        public static readonly DependencyProperty Text2AlignmentProperty =
            DependencyProperty.Register("Text2Alignment", typeof(TextAlignment?), typeof(DualText));

        public TextWrapping Text1Wrapping
        {
            get { return (TextWrapping)GetValue(Text1WrappingProperty); }
            set { SetValue(Text1WrappingProperty, value); }
        }
        public static readonly DependencyProperty Text1WrappingProperty =
            DependencyProperty.Register("Text1Wrapping", typeof(TextWrapping), typeof(DualText));

        public TextWrapping Text2Wrapping
        {
            get { return (TextWrapping)GetValue(Text2WrappingProperty); }
            set { SetValue(Text2WrappingProperty, value); }
        }
        public static readonly DependencyProperty Text2WrappingProperty =
            DependencyProperty.Register("Text2Wrapping", typeof(TextWrapping), typeof(DualText));

        public Brush Text1Brush
        {
            get { return (Brush)GetValue(Text1BrushProperty); }
            set { SetValue(Text1BrushProperty, value); }
        }
        public static readonly DependencyProperty Text1BrushProperty =
            DependencyProperty.Register("Text1Brush", typeof(Brush), typeof(DualText));

        public Brush Text2Brush
        {
            get { return (Brush)GetValue(Text2BrushProperty); }
            set { SetValue(Text2BrushProperty, value); }
        }
        public static readonly DependencyProperty Text2BrushProperty =
            DependencyProperty.Register("Text2Brush", typeof(Brush), typeof(DualText));

        public FontWeight? Text1Weight
        {
            get { return (FontWeight?)GetValue(Text1WeightProperty); }
            set { SetValue(Text1WeightProperty, value); }
        }
        public static readonly DependencyProperty Text1WeightProperty =
            DependencyProperty.Register("Text1Weight", typeof(FontWeight?), typeof(DualText));

        public FontWeight? Text2Weight
        {
            get { return (FontWeight?)GetValue(Text2WeightProperty); }
            set { SetValue(Text2WeightProperty, value); }
        }
        public static readonly DependencyProperty Text2WeightProperty =
            DependencyProperty.Register("Text2Weight", typeof(FontWeight?), typeof(DualText));

        public FontStyle Text1FontStyle
        {
            get { return (FontStyle)GetValue(Text1FontStyleProperty); }
            set { SetValue(Text1FontStyleProperty, value); }
        }
        public static readonly DependencyProperty Text1FontStyleProperty =
            DependencyProperty.Register("Text1FontStyle", typeof(FontStyle), typeof(DualText));

        public FontStyle Text2FontStyle
        {
            get { return (FontStyle)GetValue(Text2FontStyleProperty); }
            set { SetValue(Text2FontStyleProperty, value); }
        }
        public static readonly DependencyProperty Text2FontStyleProperty =
            DependencyProperty.Register("Text2FontStyle", typeof(FontStyle), typeof(DualText));

        public double? Text1Size
        {
            get { return (double?)GetValue(Text1SizeProperty); }
            set { SetValue(Text1SizeProperty, value); }
        }
        public static readonly DependencyProperty Text1SizeProperty =
            DependencyProperty.Register("Text1Size", typeof(double?), typeof(DualText));

        public double? Text2Size
        {
            get { return (double?)GetValue(Text2SizeProperty); }
            set { SetValue(Text2SizeProperty, value); }
        }
        public static readonly DependencyProperty Text2SizeProperty =
            DependencyProperty.Register("Text2Size", typeof(double?), typeof(DualText));

        public Visibility Text1Ellipsis
        {
            get { return (Visibility)GetValue(Text1EllipsisProperty); }
            set { SetValue(Text1EllipsisProperty, value); }
        }
        public static readonly DependencyProperty Text1EllipsisProperty =
            DependencyProperty.Register("Text1Ellipsis", typeof(Visibility), typeof(DualText));

        public Visibility Text2Ellipsis
        {
            get { return (Visibility)GetValue(Text2EllipsisProperty); }
            set { SetValue(Text2EllipsisProperty, value); }
        }
        public static readonly DependencyProperty Text2EllipsisProperty =
            DependencyProperty.Register("Text2Ellipsis", typeof(Visibility), typeof(DualText));

        public VerticalAlignment VerticalAlign
        {
            get { return (VerticalAlignment)GetValue(VerticalAlignProperty); }
            set { SetValue(VerticalAlignProperty, value); }
        }
        public static readonly DependencyProperty VerticalAlignProperty =
            DependencyProperty.Register("VerticalAlign", typeof(VerticalAlignment), typeof(DualText));
    }
}


text:
using System;
using System.Device.Location;
using System.Linq;
using TripToPrint.Core.Models;

namespace TripToPrint.Core
{
    public interface IKmlCalculator
    {
        double GetDistanceInMeters(IHasCoordinates placemark1, IHasCoordinates placemark2);
        double? GetDistanceInMeters(GeoCoordinate coordinate1, GeoCoordinate coordinate2);
        double CalculateRouteDistanceInMeters(IHasCoordinates placemark);
        bool CompleteFolderIsRoute(KmlFolder folder);
        bool PlacemarkIsShape(IHasCoordinates placemark);
    }

    internal class KmlCalculator : IKmlCalculator
    {
        public double GetDistanceInMeters(IHasCoordinates placemark1, IHasCoordinates placemark2)
        {
            if (placemark1.Coordinates?.Length != 1 || placemark2.Coordinates?.Length != 1)
            {
                throw new InvalidOperationException("Placemarks with multiple or zero coordinates are not supported");
            }

            return placemark1.Coordinates[0].GetDistanceTo(placemark2.Coordinates[0]);
        }

        public double? GetDistanceInMeters(GeoCoordinate coordinate1, GeoCoordinate coordinate2)
        {
            if (coordinate1 == null || coordinate2 == null)
            {
                return null;
            }
            return coordinate1.GetDistanceTo(coordinate2);
        }

        public double CalculateRouteDistanceInMeters(IHasCoordinates placemark)
        {
            if (placemark.Coordinates.Length < 2)
            {
                return 0d;
            }

            var sum = 0d;
            for (var i = 1; i < placemark.Coordinates.Length; i++)
            {
                sum += placemark.Coordinates[i].GetDistanceTo(placemark.Coordinates[i - 1]);
            }

            return sum;
        }

        public bool CompleteFolderIsRoute(KmlFolder folder)
        {
            var routes = folder.Placemarks.Where(x => x.Coordinates.Length > 1).ToList();
            if (routes.Count != 1)
            {
                return false;
            }

            Func<double, int> rounder = (d) => (int)Math.Round(d * 1000);

            var points = folder.Placemarks.Where(x => x.Coordinates.Length == 1)
                .Select(x => new[] { rounder(x.Coordinates[0].Latitude), rounder(x.Coordinates[0].Longitude) })
                .ToList();
            var routeCoords = routes[0].Coordinates.Select(x => new[] { rounder(x.Latitude), rounder(x.Longitude) }).ToList();

            var pointsOutsideRoute = points.Any(x => !routeCoords.Any(y => y[0] == x[0] && y[1] == x[1]));

            return pointsOutsideRoute != true;
        }

        public bool PlacemarkIsShape(IHasCoordinates placemark)
        {
            return placemark.Coordinates.Length > 1;
        }
    }
}


text:
require 'spec_helper'

describe BetfairNg::API::Operations::Betting::ListClearedOrders do
  include SharedHelper::Config
  include SharedHelper::Stubs

  describe "Operation" do
    before do
      stub :certlogin
      stub :list_cleared_orders
    end

    subject { BetfairNg::API::Operations::Betting::ListClearedOrders::Operation.new( config: config, session: session ) }

    describe "#endpoint" do
      it "has proper value" do
        expect(subject.endpoint).to eq('https://api.betfair.com/exchange/betting/json-rpc/v1')
      end
    end

    describe "#perform" do
      before do
        session.create
      end

      it 'returns valid response' do
        subject.perform

        expect(subject.http_code).to eq("200")
        expect(subject.success?).to be true
        expect(subject.http_data.result).not_to be_empty
        expect(subject.http_data.result.keys).to eq(["clearedOrders", "moreAvailable"])
        expect(subject.http_data.result["clearedOrders"]).to eq([{"eventTypeId"=>"1", "eventId"=>"27393661", "marketId"=>"1.117733825", "selectionId"=>1561969, "handicap"=>0.0, "betId"=>"47793528580", "placedDate"=>"2015-03-20T14:17:39.000Z", "persistenceType"=>"LAPSE", "orderType"=>"LIMIT", "side"=>"BACK", "priceRequested"=>2.7, "settledDate"=>"2015-03-20T14:49:51.000Z", "betCount"=>1, "priceMatched"=>2.7, "priceReduced"=>false, "sizeSettled"=>4.66, "profit"=>-4.66}])
      end
    end

    describe "#serialize" do
      it "properly sets the classes" do
        subject.perform

        expect(subject.data.class).to be_kind_of(Class)
        expect(subject.data.keys).to eq([:cleared_orders, :more_available])
      end
    end

    describe "#request_params" do
      it "returns a proper hash with default values" do

        expect(subject.request[:params]).to eq({betStatus: :SETTLED})
        expect(subject.request(bet_ids: [1,2,3])[:params]).to eq({betStatus: :SETTLED, betIds: ["1", "2", "3"]})
        expect{subject.request(bet_ids: [1,2,3], group_by: 'asdf')[:params]}.to raise_error(ArgumentError)
        expect(subject.request(bet_ids: [1,2,3], group_by: 'EVENT_TYPE')[:params]).to eq({betStatus: :SETTLED, betIds: ["1", "2", "3"], groupBy: 'EVENT_TYPE'})
        expect(subject.request(bet_ids: [1,2,3], group_by: :EVENT_TYPE)[:params]).to eq({betStatus: :SETTLED, betIds: ["1", "2", "3"], groupBy: 'EVENT_TYPE'})
      end
    end
  end
end