text:
import sys
import random
import bisect
import logging

from . import event
from . import fight
from . import terrains
from . import props
from . import world

class Goals(list):
    def __init__(self, person, *args, **kw):
        super().__init__(*args, **kw)
        self.person = person

    def __contains__(self, item):
        if isinstance(item, type):
            # search for a type of goal
            for i in self:
                if isinstance(i, item):
                    return True
            return False
        else:
            return super().__contains__(item)

    def add(self, goal, *args, **kw):
        if isinstance(goal, type):
            kw['person'] = self.person
            goal = goal(*args, **kw)
        bisect.insort(self, goal)

    def add_or_replace(self, goal, *args, **kw):
        if isinstance(goal, type):
            for item in self:
                if isinstance(item, goal):
                    self.remove(item)
                    break
        else:
            for item in self:
                if item.__class__ == goal.__class__:
                    self.remove(item)
                    break
        self.add(goal, *args, **kw)

class Goal:
    """A (potentially) multi-move aim of a person."""
    def __init__(self, priority, person=None):
        self.priority = priority
        self.person = person
        self.subgoals = []
        logging.debug("Goal created for %s: %s (%d)", self.person, self.__class__, self.priority)
    def __repr__(self):
        return '%s(%r)' % (self.__class__.__name__, self.priority)
    def __lt__(self, other):
        return self.priority < other.priority
    def possible(self):
        """Is this goal possible to achieve right now?"""
        return True
    def achieve(self):
        """Make person perform the necessary actions to achieve this
        goal."""
        logging.debug('goal %s achieved', self)
        self.person.goals.remove(self)
        for subgoal in self.subgoals:
            logging.debug('subgoal %s achieved', subgoal)
            subgoal.person.goals.remove(subgoal)

class GoTo(Goal):
    """Character aims to reach a certain location."""
    def __init__(self, prop, *args, **kw):
        super().__init__(*args, **kw)
        self.prop = prop
        self.person.log(event.Motivation, 'get to %s' % self.prop.indefinite)
    def possible(self):
        logging.debug("Calculating path to %s", self.prop)
        self.path, prop = self.person.worldview.path_to(self.prop)
        if self.path is None:
            logging.debug('no path available')
            # Character doesn't know where there is water; explore.
            self.person.log(event.Knowledge, 'location', self.prop, -1, None)
            self.person.goals.add_or_replace(Explore, None, self.priority)
            return False
        elif self.path[0][1] == '':
            logging.debug('already at target')
            # already at water, so this goal is redundant
            self.person.log(event.Surroundings, prop)
            self.person.goals.remove(self)
            return False
        else:
            logging.debug('successful path calculated')
            self.person.log(event.Knowledge, 'location', prop, 1, self.path[0][1])
            return True
    def achieve(self):
        # don't call super; we don't want to remove ourself until dest reached.
        direction = self.path[0][1]
        assert getattr(self.person.tile, direction) != None, "%r %s" %(self.person.tile, direction)
        self.person._move(direction, getattr(self.person.tile, direction))

class Drink(Goal):
    """Character aims to quench their thirst."""
    def possible(self):
        for prop in self.person.tile.terrain.props:
            if isinstance(prop, props.Water):
                return True
        return False
    def achieve(self):
        super().achieve()
        self.person.thirst = 0
        self.person.log(event.Action, "drink")

class Fight(Goal):
    """Character is spoiling for a fight."""
    def __init__(self, opponent, *args, **kw):
        super().__init__(*args, **kw)
        self.opponent = opponent
    def possible(self):
        if self.opponent in self.person.tile.people:
            return True
        return False
    def achieve(self):
        super().achieve()
        self.person.log(event.Attack, self.opponent)
        self.opponent.log(event.Attacked, self.person)
        duel = fight.Fight(self.person, self.opponent)
        duel()
        if not self.person.dead:
            self.person.log(event.Fight, duel)
        else:
            self.opponent.log(event.Fight, duel)

class Explore(Goal):
    def __init__(self, direction, *args, **kw):
        super().__init__(*args, **kw)
        self.direction = direction
    def possible(self):
        return True
    def achieve(self):
        super().achieve()
        direction = self.direction
        if direction is None:
            neighbours = list(self.person.tile.neighbours.keys())
            if self.person.time > 30 * 24:
                # after a month, people strangely drawn towards each other...
                def target_fn(tile):
                    if tile.people and self.person not in tile.people:
                        return True
                    return False
                path, item = world.find(self.person.tile, target_fn)
                target_dir = path[0][1]
                if target_dir in neighbours:
                    neighbours.extend([path[0][0]] * 10)
            direction = random.choice(neighbours)
        self.person._move(direction, getattr(self.person.tile, direction))

class Escape(Explore):
    # just subclass Explore for now
    def __init__(self, *args, **kw):
        super().__init__(None, *args, **kw)

class Rest(Goal):
    def __init__(self, *args, **kw):
        super().__init__(*args, **kw)
    def possible(self):
        # only rest when alone.
        if len(self.person.tile.people) > 1:
            return False
        return True
    def achieve(self):
        # This compensates for the hourly +=1 but player will
        # not be able to stay awake just by resting (unless they
        # rest /every/ move).
        self.person.awake -= 1
        if self.person.awake < 0:
            self.person.awake = 0
        self.person.log(event.Rest)


text:
/**
 */
package bvr.impl;

import bvr.BvrPackage;
import bvr.VPackageable;

import org.eclipse.emf.ecore.EClass;

/**
 *
 * An implementation of the model object 'VPackageable'.
 *
 *

 *

 *
 * @generated
 */
public abstract class VPackageableImpl extends NamedElementImpl implements VPackageable {
	/**
	 *
	 *
	 * @generated
	 */
	protected VPackageableImpl() {
		super();
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BvrPackage.Literals.VPACKAGEABLE;
	}

} //VPackageableImpl

redpajama_set_name: RedPajamaGithub


text:
@interface UIButton (BARemoteImage)

@end


text:
package urlgen

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"path/filepath"
	"time"
)

const (
	adjectivesFilename = "adjectives.txt"
	animalsFilename    = "animals.txt"
	adverbsFilename    = "adverbs.txt"
	verbsFilename      = "verbs.txt"
)

var (
	// use our own rand.Rand so we don't disturb a calling program potentially using the rand package
	rng *rand.Rand

	adjectives []string
	animals    []string
	adverbs    []string
	verbs      []string
)

type Error struct {
	File string
	error
}

func (e Error) Error() string {
	return fmt.Sprintf("%s: %v", e.File, e.error)
}

func Gen() string {
	var (
		adj = rng.Intn(len(adjectives))
		an  = rng.Intn(len(animals))
		adv = rng.Intn(len(adverbs))
		v   = rng.Intn(len(verbs))
	)

	return adjectives[adj] + animals[an] + adverbs[adv] + verbs[v]
}

func LoadDir(dir string) error {
	if err := fill(&adjectives, filepath.Join(dir, adjectivesFilename)); err != nil {
		return Error{adjectivesFilename, err}
	}

	if err := fill(&animals, filepath.Join(dir, animalsFilename)); err != nil {
		return Error{animalsFilename, err}
	}

	if err := fill(&adverbs, filepath.Join(dir, adverbsFilename)); err != nil {
		return Error{adverbsFilename, err}
	}

	if err := fill(&verbs, filepath.Join(dir, verbsFilename)); err != nil {
		return Error{verbsFilename, err}
	}

	rng = rand.New(rand.NewSource(time.Now().UnixNano()))

	return nil
}

func fill(arr *[]string, path string) error {
	file, err := os.Open(path)
	if err != nil {
		return err
	}
	defer file.Close()

	scan := bufio.NewScanner(file)
	for scan.Scan() {
		line := scan.Text()

		if line != "" {
			*arr = append(*arr, line)
		}
	}

	return nil
}


text:
package com.sonic.common;

/**
 * This interface provides a method to return a boolean after a security
 * review of the implementing class has been performed.
 *
 *  @author David L. Whitehurst
 *
 */
public interface Security {

    /**
     * Method to enforce security awareness.
     * @return true or false that class has been secured
     */
    public boolean isSecure();
}


text:
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

using Microsoft.Modeling;

namespace Microsoft.Protocol.TestSuites.Smb
{
    /// <summary>
    /// NT transaction model program.
    /// </summary>
    //public class ModelProgram : BaseModelProgram
    public static partial class BaseModelProgram
    {
        /// <summary>
        /// Define FID used for setting quota.
        /// </summary>
        private static int fIdUsed;

        /// <summary>
        /// Define resumeKey.
        /// </summary>
        private static string resumeKey;

        /// <summary>
        /// Set copychunkSourceFid to 0.
        /// </summary>
        private static int copyChunkSourceFid;

        /// <summary>
        /// Check Snapshots.
        /// </summary>
        /// <param name="fId">The SMB file identifier.</param>
        /// <param name="snapShots">The snapshots for the corresponding file.</param>
        /// <param name="isSucceed">It indicates whether the checking is successful or not.</param>
        [Rule]
        public static void CheckSnapshots(int fId, Set<int> snapShots, out bool isSucceed)
        {
            Condition.IsTrue((smbState != SmbState.End) && (smbState != SmbState.Closed));
            isSucceed = true;
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId)
                                && smbConnection.openedFiles[fId].name == Parameter.fileNames[2]);
            Condition.IsTrue(smbConnection.sentRequest.Count == 0);
            Condition.IsTrue(snapShots == new Set<int>(1, 2));
            smbConnection.openedFiles[fId].previousVersionToken = snapShots;
        }

        #region SMB_COM_NT_TRANSACTION Extensions and Clarification

        #region NT_TRANSACT_QUERY_QUOTA

        /// <summary>
        /// NT_TRANSACT_QUERY_QUOTA Request.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fId">The SMB file identifier of the target directory.</param>
        /// <param name="returnSingle">
        /// A bool variable, if set, indicates only a single entry is to be returned instead of filling the entire
        /// buffer.
        /// </param>
        /// <param name="restartScan">
        /// A bool variable, if set, indicates that the scan of the quota information is to be restarted.
        /// </param>
        /// <param name="sIdListLength">
        /// Supply the length in bytes of the SidList, or 0 if there is no SidList.
        /// </param>
        /// <param name="startSidLength">
        /// Supply the length in bytes of the StartSid, or 0 if there is no StartSid.
        /// </param>
        /// <param name="startSidOffset">startSidOffset.</param>
        [Rule]
        /// Disable CA1801, because the parameter 'startSidLength' is used for interface implementation.
        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters")]
        public static void NtTransQueryQuotaRequest(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            int fId,
            bool returnSingle,
            bool restartScan,
            int sIdListLength,
            int startSidLength,
            int startSidOffset)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId));
            Condition.IsTrue(fId == fIdUsed);
            Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId);
            Condition.IsTrue(sIdListLength == 0 || startSidLength == 0);
            if (returnSingle)
            {
                Requirement.AssumeCaptured("Allowed to restart the scan of the quota information");
            }
            else
            {
                Requirement.AssumeCaptured("Don't allowed to restart the scan of the quota information");
            }
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);
            smbRequest = new NtTransactQueryQuotaRequest(
                messageId,
                sessionId,
                treeId,
                fId,
                isSigned,
                returnSingle,
                restartScan,
                sIdListLength,
                startSidLength);
            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// NT_TRANSACT_QUERY_QUOTA Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="quotaUsed">The amount of quota, in bytes, used by this user.</param>
        /// <param name="messageStatus">
        /// It indicates that the status  code returned from the System Under Test (SUT) is success or failure.
        /// </param>
        [Rule]
        /// Disable CA1801, because the parameter 'quotaUsed' is used for interface implementation.
        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters")]
        public static void NtTransQueryQuotaResponse(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            int quotaUsed,
            MessageStatus messageStatus)
        {
            NtTransactQueryQuotaRequest request = null;
            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.NtTransactQueryQuotaRequest>(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                isSigned,
                messageStatus,
                out request,
                MessageStatus.Success);
            Condition.IsTrue(request.command == Command.NtTransactQueryQuota);

            if (messageStatus == MessageStatus.Success)
            {
                ModelHelper.CaptureRequirement(
                    9451,
                    @"[In server Response]An SMB_COM_NT_TRANSACT (section 2.2.4.8) response for an
                    NT_TRANSACT_QUERY_QUOTA subcommand MUST be sent by a server in reply to a client
                    NT_TRANSACT_QUERY_QUOTA subcommand request when the request is successful.");
            }

            // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
            // changes correspondingly.
            Condition.IsTrue(Parameter.isSupportQuota);

            Update.UpdateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// NT_TRANSACT_QUERY_QUOTA Error Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule(Action = "ErrorResponse(messageId, messageStatus)")]
        public static void ErrorNtTransQueryQuotaResponse(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue(messageStatus == MessageStatus.NetworkSessionExpired
                                || messageStatus == MessageStatus.StatusInvalidDeviceRequest
                                || messageStatus == MessageStatus.InvalidParameter);
            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.NtTransactQueryQuota);
            NtTransactQueryQuotaRequest request = (NtTransactQueryQuotaRequest)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.NetworkSessionExpired)
            {
                smbConnection.sessionList.Remove(request.sessionId);
                smbState = SmbState.Closed;
            }
            else if (messageStatus == MessageStatus.StatusInvalidDeviceRequest)
            {
                Condition.IsTrue(smbConnection.sessionList[request.sessionId].sessionState == SessionState.Valid);

                // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
                // changes correspondingly.
                Condition.IsTrue(!Parameter.isSupportQuota);
                Condition.IsTrue(Parameter.fsType == FileSystemType.Fat);

                smbState = SmbState.End;
            }
            else if (messageStatus == MessageStatus.InvalidParameter)
            {
                if (request.sidListLength == 0 && request.startSidLength == 0)
                {
                    ModelHelper.CaptureRequirement(
                        8459,
                        @"[In Application Requests Querying Quota Information,The application MUST provide:] If the
                        application provides both an SID list and a start SID, then the client MUST fail the request
                        with STATUS_INVALID_PARAMETER.");
                }
            }
            smbConnection.sentRequest.Remove(messageId);
        }

        #endregion NT_TRANSACT_QUERY_QUOTA

        #region NT_TRANSACT_SET_QUOTA

        /// <summary>
        /// NT_TRANSACT_SET_QUOTA Request.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fId">The SMB file identifier of the target directory.</param>
        /// <param name="quotaUsed">The amount of quota, in bytes, used by this user.</param>
        [Rule]
        public static void NtTransSetQuotaRequest(
            int messageId,
            int sessionId,
            int treeId,
            int fId,
            bool isSigned,
            int quotaInfo)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId));
            Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId);
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);

            smbRequest = new NtTransactSetQuotaRequest(messageId, sessionId, treeId, fId, isSigned, quotaInfo);
            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// NT_TRANSACT_SET_QUOTA response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule]
        public static void NtTransSetQuotaResponse(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            MessageStatus messageStatus)
        {
            NtTransactSetQuotaRequest request = null;

            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.NtTransactSetQuotaRequest>(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                isSigned,
                messageStatus,
                out request,
                MessageStatus.Success);

            Condition.IsTrue(request.command == Command.NtTransactSetQuota);

            if (messageStatus == MessageStatus.Success)
            {
                ModelHelper.CaptureRequirement(
                    9463,
                    "[In sever response.]An SMB_COM_NT_TRANSACT (section 2.2.4.8) response for the " +
                    "NT_TRANSACT_SET_QUOTA subcommand MUST be sent by a server in reply to a client NT_TRANSACT_SET_QUOTA " +
                    "request when the request is successful.");
                if (request.quotaUsed < 65535 && request.quotaUsed >= 0)
                {
                    ModelHelper.CaptureRequirement(
                        5024,
                        @"[In Receiving an NT_TRANS_QUERY_QUOTA_INFO Request]Otherwise[if the entire quota information
                        fits in the response buffer], the server MUST return STATUS_SUCCESS.");
                }
            }

            // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
            // changes correspondingly.
            Condition.IsTrue(Parameter.isSupportQuota);
            fIdUsed = request.fId;

            Update.UpdateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// NT_TRANSACT_SET_QUOTA Error Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule(Action = "ErrorResponse(messageId, messageStatus)")]
        public static void ErrorNtTransSetQuotaResponse(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue((messageStatus == MessageStatus.NetworkSessionExpired)
                                || messageStatus == MessageStatus.StatusInvalidDeviceRequest
                                || messageStatus == MessageStatus.StatusBufferTooSmall);
            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.NtTransactSetQuota);
            NtTransactSetQuotaRequest request = (NtTransactSetQuotaRequest)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.NetworkSessionExpired)
            {
                Condition.IsTrue(smbConnection.sessionList[request.sessionId].sessionState == SessionState.Valid);

                smbConnection.sessionList.Remove(request.sessionId);
                smbState = SmbState.Closed;
            }
            else if (messageStatus == MessageStatus.StatusInvalidDeviceRequest)
            {
                Condition.IsTrue(smbConnection.sessionList[request.sessionId].sessionState == SessionState.Valid);

                // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
                // changes correspondingly.
                Condition.IsTrue(!Parameter.isSupportQuota);
                ModelHelper.CaptureRequirement(
                    5035,
                    "[In Receiving an NT_TRANS_SET_QUOTA Request] <130> Section 3.3.5.10.3:  If the volume is capable " +
                    "of supporting disk quotas but has the feature disabled, then a STATUS_INVALID_DEVICE_REQUEST is " +
                    "returned.");
                smbState = SmbState.End;
            }
            else if (messageStatus == MessageStatus.StatusBufferTooSmall)
            {
                if (request.quotaUsed > 65535)
                {
                    ModelHelper.CaptureRequirement(
                        5032,
                        "[In Receiving an NT_TRANS_QUERY_QUOTA_INFO Request]If the entire quota information cannot fit " +
                        "in the response buffer, then the server MUST return a status of STATUS_BUFFER_TOO_SMALL.");
                }
            }
            smbConnection.sentRequest.Remove(messageId);
        }

        #endregion NT_TRANSACT_SET_QUOTA

        #region NT_TRANSACT_SET_QUOTA (Additional)

        /// <summary>
        /// NT_TRANSACT_SET_QUOTA Client Request
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fId">The SMB file identifier of the target directory.</param>
        /// <param name="informationLevel">
        /// It indicates that valid condition and each error condition are contained in the input conditions type.
        /// </param>
        [Rule]
        public static void NtTransSetQuotaRequestAdditional(
            int messageId,
            int sessionId,
            int treeId,
            int fId,
            bool isSigned,
            NtTransSetQuotaRequestParameter requestPara)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId));
            Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId);
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);

            if (createFileAccess == 1)
            {
                // Created file is readonly.
                Condition.IsTrue(requestPara == NtTransSetQuotaRequestParameter.AccessDenied);
            }
            else
            {
                Condition.IsTrue(requestPara != NtTransSetQuotaRequestParameter.AccessDenied);
            }

            smbRequest = new NTTransactSetQuotaRequestAdditional(
                messageId,
                sessionId,
                treeId,
                fId,
                isSigned,
                requestPara);
            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// NT_TRANSACT_SET_QUOTA response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule]
        public static void NtTransSetQuotaResponseAdditional(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            MessageStatus messageStatus)
        {
            NTTransactSetQuotaRequestAdditional request = null;
            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.NTTransactSetQuotaRequestAdditional>(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                isSigned,
                messageStatus,
                out request,
                MessageStatus.Success);
            Condition.IsTrue(request.command == Command.NtTransactSetQuotaAdditional);
            Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.Valid);
            if (messageStatus == MessageStatus.Success)
            {
                ModelHelper.CaptureRequirement(
                    9463,
                    "[In server response]An SMB_COM_NT_TRANSACT (section 2.2.4.8) response for the " +
                    "NT_TRANSACT_SET_QUOTA subcommand MUST be sent by a server in reply to a client NT_TRANSACT_SET_QUOTA " +
                    "request when the request is successful.");
                ModelHelper.CaptureRequirement(
                    2468,
                    @"The server MUST apply the quota information provided in the NT_Trans_Data block of the request
                    (see section 2.2.7.4.1). ");
            }

            // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
            // changes correspondingly.
            Condition.IsTrue(Parameter.isSupportQuota);
            fIdUsed = request.fId;

            Update.UpdateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// NT_TRANSACT_SET_QUOTA Error Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule]
        public static void ErrorNtTransSetQuotaResponseAdditional(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue(messageStatus == MessageStatus.StatusInvalidHandle
                                || messageStatus == MessageStatus.AccessDenied
                                || messageStatus == MessageStatus.InvalidParameter
                                || messageStatus == MessageStatus.StatusInsuffServerResources
                                || messageStatus == MessageStatus.StatusDataError
                                || messageStatus == MessageStatus.StatusMediaWriteProtected
                                || messageStatus == MessageStatus.NetworkSessionExpired
                                || messageStatus == MessageStatus.StatusBufferTooSmall);
            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.NtTransactSetQuotaAdditional);

            NTTransactSetQuotaRequestAdditional request
                = (NTTransactSetQuotaRequestAdditional)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.StatusInvalidHandle)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.FileIdErrror);
                ModelHelper.CaptureRequirement(
                    1109468,
                    @"[In server response]When SMBSTATUS code is negotiated and The Fid is invalid, the server returns
                    STATUS_INVALID_HANDLE(0xC0000008).");
            }
            else if (messageStatus == MessageStatus.AccessDenied)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.AccessDenied && Parameter.isSetQuotaAccessDenied);
                ModelHelper.CaptureRequirement(
                    1109470,
                    @"[In server response]When SMBSTATUS code is negotiated and Access denied, the server returns
                    STATUS_ACCESS_DENIED(0xC0000022).");
            }
            else if (messageStatus == MessageStatus.InvalidParameter)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.QuotaInfoError);
                ModelHelper.CaptureRequirement(
                    119473,
                    @"[In server response]When in the Xenix server implementation and A parameter is invalid, the server
                    returns STATUS_INVALID_PARAMETER(0xC000000D).");
            }
            else if (messageStatus == MessageStatus.StatusInsuffServerResources)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.ServerOutOfResource);
                ModelHelper.CaptureRequirement(
                    1109480,
                    @"[In server response]When SMBSTATUS code is negotiated and The server is out of resources, the
                    server returnsSTATUS_INSUFF_SERVER_RESOURCES(0xC0000205).");
            }
            else if (messageStatus == MessageStatus.StatusDataError)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.InputOutputError);
                ModelHelper.CaptureRequirement(
                    1109488,
                    @"[In server response]When SMBSTATUS code is negotiated and Disk I/O error,the server returns
                    STATUS_DATA_ERROR(0xC000003E).");
            }
            else if (messageStatus == MessageStatus.StatusMediaWriteProtected)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.FsReadOnly);
                ModelHelper.CaptureRequirement(
                    1109490,
                    @"[In server response]When SMBSTATUS code is negotiated and Attempt to modify a read-only file
                    system,the server returns STATUS_MEDIA_WRITE_PROTECTED(0xC00000A2).");
            }
            else if (messageStatus == MessageStatus.StatusInvalidDeviceRequest)
            {
                Condition.IsTrue(smbConnection.sessionList[request.sessionId].sessionState == SessionState.Valid);
                ModelHelper.CaptureRequirement(
                    5035,
                    "[In Receiving an NT_TRANS_SET_QUOTA Request] <130> Section 3.3.5.10.3: AIf the volume is capable " +
                    "of supporting disk quotas but has the feature disabled, then a STATUS_INVALID_DEVICE_REQUEST is " +
                    "returned.");
                smbState = SmbState.End;
            }
            else if (messageStatus == MessageStatus.StatusBufferTooSmall)
            {
                Condition.IsTrue(request.requestPara == NtTransSetQuotaRequestParameter.QuotaInfoError);
                ModelHelper.CaptureRequirement(
                    5023,
                    @"[In Receiving an NT_TRANS_QUERY_QUOTA_INFO Request]If the entire quota information cannot fit in
                    the response buffer, then the server MUST return a status of STATUS_BUFFER_TOO_SMALL.");
            }
            smbConnection.sentRequest.Remove(messageId);
        }

        #endregion NT_TRANSACT_SET_QUOTA

        #region NT_TRANSACT_IOCTL

        #region FSCTL_SRV_ENUMERATE_SNAPSHOTS

        /// <summary>
        /// FSCTL_SRV_ENUMERATE_SNAPSHOTS Request.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fId">The SMB file identifier of the target directory.</param>
        /// <param name="maxDataCount">used to control the MaxDataCount in FSCTL_SRV_ENUMERATE_SNAPSHOTS.</param>
        [Rule]
        public static void FsctlSrvEnumSnapshotsRequest(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            int fId,
            MaxDataCount maxDataCount)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId));
            Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId);
            Condition.IsTrue(smbConnection.openedFiles[fId].previousVersionToken.Count != 0);
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);
            smbRequest = new FsctlSrvEnumSnapshotsRequest(messageId, sessionId, treeId, fId, isSigned, maxDataCount);
            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// FSCTL_SRV_ENUMERATE_SNAPSHOTS Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        /// <param name="NumberOfSnapShotsCompared">
        /// Return the comparison result of NumberOfSnapShots and NumberOfSnapShotsReturned.
        /// </param>
        [Rule]
        public static void FsctlSrvEnumSnapshotsResponse(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            MessageStatus messageStatus,
            IntegerCompare NumberOfSnapShotsCompared)
        {
            FsctlSrvEnumSnapshotsRequest request;

            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.FsctlSrvEnumSnapshotsRequest>(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                isSigned,
                messageStatus,
                out request,
                MessageStatus.Success);

            Condition.IsTrue(request.command == Command.FsctlSrvEnumerateSnapshots);

            if (messageStatus == MessageStatus.Success)
            {
                ModelHelper.CaptureRequirement(
                    9394,
                    "[In  Client Request Extensions]Server implementations that receive undefined FSCTL or IOCTL " +
                    "operation requests MUST either pass the operation code and data (if any) through to the underlying " +
                    "object store or fail the operation by returning STATUS_NOT_SUPPORTED.<69>");
                ModelHelper.CaptureRequirement(
                    9397,
                    "[In response. Extensions]An SMB_COM_NT_TRANSACT (section 2.2.4.8) response for an " +
                    "NT_TRANSACT_IOCTL ([MS-CIFS] section 2.2.7.2) subcommand MUST be sent by a server in reply to a " +
                    "successful NT_TRANSACT_IOCTL request.");
            }
            Condition.IsTrue(request.maxDataCount != MaxDataCount.VerySmall);

            if (request.maxDataCount == MaxDataCount.Mid)
            {
                Condition.IsTrue(NumberOfSnapShotsCompared == IntegerCompare.Smaller);
            }

            if (request.maxDataCount == MaxDataCount.VeryLarge)
            {

                Condition.IsTrue(NumberOfSnapShotsCompared == IntegerCompare.Equal);

                Requirement.AssumeCaptured(
                    @"If MaxDataCount is large enough, the adapter will return all snapshots in a
                    FSCTLSrvEnumSnapshotsResponse");
            }

            Update.UpdateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// FSCTL_SRV_ENUMERATE_SNAPSHOTS Error Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule(Action = "ErrorResponse(messageId, messageStatus)")]
        public static void ErrorFsctlSrvEnumSnapshotsResponse(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue((messageStatus == MessageStatus.NetworkSessionExpired)
                               || (messageStatus == MessageStatus.NotSupported)
                               || (messageStatus == MessageStatus.InvalidParameter));

            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.FsctlSrvEnumerateSnapshots);

            FsctlSrvEnumSnapshotsRequest request = (FsctlSrvEnumSnapshotsRequest)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.NetworkSessionExpired)
            {
                smbConnection.sessionList.Remove(request.sessionId);
                smbState = SmbState.Closed;
            }
            else if (messageStatus == MessageStatus.NotSupported)
            {
                // Input paramater is valid.
                if (request.maxDataCount != MaxDataCount.VerySmall
                        && Parameter.isSupportNtSmb
                        && smbConnection.sessionList[request.sessionId].sessionState == SessionState.Valid)
                {
                    ModelHelper.CaptureRequirement(
                        4984,
                        @"[In Receiving an FSCTL_SRV_ENUMERATE_SNAPSHOTS Function Code]If the server does not
                        support this operation [Receiving an FSCTL_SRV_ENUMERATE_SNAPSHOTS Function Code], then it
                        SHOULD fail the request with STATUS_NOT_SUPPORTED.");

                    if (Parameter.sutPlatform != Platform.NonWindows)
                    {
                        ModelHelper.CaptureRequirement(
                            4985,
                            @"[In Receiving an FSCTL_SRV_ENUMERATE_SNAPSHOTS Function Code]If  the server does not
                            support this operation [Receiving an FSCTL_SRV_ENUMERATE_SNAPSHOTS Function Code], then
                            it does fail the FSCTL request with STATUS_NOT_SUPPORTED in windows.");
                    }
                }

                smbState = SmbState.End;
            }
            else if (messageStatus == MessageStatus.InvalidParameter)
            {
                Condition.IsTrue(Parameter.isSupportPreviousVersion);

                if (request.maxDataCount == MaxDataCount.VerySmall)
                {
                    ModelHelper.CaptureRequirement(
                        2439,
                        @"[In Receiving an FSCTL_SRV_ENUMERATE_SNAPSHOTS Function Code]If the MaxDataCount of the
                        request is smaller than the size of an FSCTL_ENUMERATE_SNAPSHOTS response, then the server MUST
                        fail the request with STATUS_INVALID_PARAMETER. ");
                    ModelHelper.CaptureRequirement(
                        9576,
                        "<72> Section 2.2.7.2.1: Windows-based Servers return a STATUS_INVALID_PARAMETER error if the " +
                        "value of MaxDataCount is less than 0x10 bytes.");
                }
                smbState = SmbState.End;
            }
            smbConnection.sentRequest.Remove(messageId);
        }

        #endregion FSCTL_SRV_ENUMERATE_SNAPSHOTS

        #region FSCTL_SRV_REQUEST_RESUME_KEY

        /// <summary>
        /// FSCTL_SRV_REQUEST_RESUME_KEY Request.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fId">The SMB file identifier of the target directory.</param>
        [Rule]
        public static void FsctlSrvRequestResumeKeyRequest(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            int fId)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId));
            Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId);
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);
            smbRequest = new FsctlSrvResumeKeyRequest(messageId, sessionId, treeId, fId, isSigned);
            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// FSCTL_SRV_REQUEST_RESUME_KEY Response
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="copychunkResumeKey">The resume key generated by the SMB the SUT.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule]
        public static void FsctlSrvRequestResumeKeyResponse(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            [Domain("ValidKeys")]string copychunkResumeKey,
            MessageStatus messageStatus)
        {
            FsctlSrvResumeKeyRequest request = null;
            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.FsctlSrvResumeKeyRequest>(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                isSigned,
                messageStatus,
                out request,
                MessageStatus.Success);
            Condition.IsTrue(request.command == Command.FsctlSrvRequestResumeKey);

            // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
            // changes correspondingly.
            Condition.IsTrue(Parameter.isSupportResumeKey);

            if (messageStatus == MessageStatus.Success)
            {
                ModelHelper.CaptureRequirement(
                    9397,
                    "[In response. Extensions]An SMB_COM_NT_TRANSACT (section 2.2.4.8) response for an " +
                    "NT_TRANSACT_IOCTL ([MS-CIFS] section 2.2.7.2) subcommand MUST be sent by a server in reply to a " +
                    "successful NT_TRANSACT_IOCTL request.");
            }

            resumeKey = copychunkResumeKey;
            ModelHelper.CaptureRequirement(
                30022,
                "[In Receiving an FSCTL_SRV_REQUEST_RESUME_KEY Function Code] If this operation [Receiving an " +
                "FSCTL_SRV_REQUEST_RESUME_KEY Function Code] is successful, then the server MUST construct an " +
                "FSCTL_SRV_CHOPYCHUNK response as specified in section 2.2.7.2.2, with the following additional " +
                "requirements: The CopychunkResumeKey field MUST be the SUT-generated value.");

            copyChunkSourceFid = request.fId;

            Update.UpdateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// FSCTL_SRV_REQUEST_RESUME_KEY Error Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule(Action = "ErrorResponse(messageId, messageStatus)")]
        public static void ErrorFsctlrvRequestResumeKeyResponse(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue((messageStatus == MessageStatus.NetworkSessionExpired)
                                || (messageStatus == MessageStatus.NotSupported));
            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.FsctlSrvRequestResumeKey);
            FsctlSrvResumeKeyRequest request = (FsctlSrvResumeKeyRequest)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.NetworkSessionExpired)
            {
                smbConnection.sessionList.Remove(request.sessionId);
                smbState = SmbState.Closed;
            }
            else if (messageStatus == MessageStatus.NotSupported)
            {
                // As input paramter is valid, that the SUT still reuturn error code indicates that the SUT does not
                // support this operation.
                if (!Parameter.isSupportResumeKey)
                {
                    ModelHelper.CaptureRequirement(
                        30023,
                        @"[In Receiving an FSCTL_SRV_REQUEST_RESUME_KEY Function Code] If this operation [Receiving an
                        FSCTL_SRV_REQUEST_RESUME_KEY Function Code] is successful, then the server MUST construct an
                        FSCTL_SRV_CHOPYCHUNK response as specified in section 2.2.7.2.2, with the following additional
                        requirements: If the server does not support this operation [Receiving an
                        FSCTL_SRV_REQUEST_RESUME_KEY Function Code], then it MUST fail the request with
                        STATUS_NOT_SUPPORTED.");
                }
                smbState = SmbState.End;
            }
            smbConnection.sentRequest.Remove(messageId);
        }

        #endregion FSCTL_SRV_REQUEST_RESUME_KEY

        #region FSCTL_SRV_COPYCHUNK

        /// <summary>
        /// FSCTL_SRV_COPYCHUNK Request.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fId">The target file identifier.</param>
        /// <param name="copyChunkResumeKey">The the SUT resume key for a source file.</param>
        /// <param name="sourceOffset">The offset in the source file to copy from.</param>
        /// <param name="targetOffset">The offset in the target file to copy to.</param>
        /// <param name="length">The number of bytes to copy from the source file to the target file.</param>
        [Rule]
        /// Disable CA1801, because the parameter 'sourceOffset' and 'targetOffset' is used for interface
        /// implementation.
        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters")]
        public static void FsctlSrvCopyChunkRequest(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            int fId,
            [Domain("ValidKeys")]string copyChunkResumeKey,
            int sourceOffset,
            int targetOffset,
            int length)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fId));
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(copyChunkSourceFid));
            Condition.IsTrue(fId != copyChunkSourceFid);
            Condition.IsTrue(length == 0);

            Condition.IsTrue(smbConnection.openedFiles[fId].treeId == treeId);
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);

            smbRequest = new FsctlSrvCopyChunkRequest(
                messageId,
                sessionId,
                treeId,
                fId,
                isSigned,
                length,
                copyChunkResumeKey);
            if (((FsctlSrvCopyChunkRequest)smbRequest).length > Parameter.totalBytesWritten)
            {
                Condition.IsTrue((smbConnection.openedFiles[copyChunkSourceFid].accessRights & 0x01) == 1);
                Condition.IsTrue(
                    (smbConnection.openedFiles[((FsctlSrvCopyChunkRequest)smbRequest).fId].accessRights & 0x02) == 2);
            }
            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// FSCTL_SRV_COPYCHUNK Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="sessionId">Session ID used to identify the session.</param>
        /// <param name="treeId">Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule]
        public static void FsctlSrvCopyChunkResponse(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            MessageStatus messageStatus)
        {
            FsctlSrvCopyChunkRequest request = null;

            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.FsctlSrvCopyChunkRequest>(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                isSigned,
                messageStatus,
                out request,
                MessageStatus.Success);
            Condition.IsTrue(request.command == Command.FsctlSrvCupychunk);

            if (messageStatus == MessageStatus.Success)
            {
                ModelHelper.CaptureRequirement(
                    9397,
                    "[In response. Extensions]An SMB_COM_NT_TRANSACT (section 2.2.4.8) response for an " +
                    "NT_TRANSACT_IOCTL ([MS-CIFS] section 2.2.7.2) subcommand MUST be sent by a server in reply to a " +
                    "successful NT_TRANSACT_IOCTL request.");
            }

            // When Parameter initials, the SUT checks the parameter, if the SUT doesn't support quota, the Parmeter
            // changes correspondingly.
            Condition.IsTrue(Parameter.isSupportCopyChunk);

            // The Key is valid.
            Condition.IsTrue(resumeKey == request.copychunkResumeKey);
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(request.fId));
            ModelHelper.CaptureRequirement(
                2446,
                "Likewise, the target file MUST be specified by the Fid in the SMB_COM_NT_TRANSACTION request.");

            // The source file is oppend.
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(copyChunkSourceFid));

            // FILE_SHARE_READ (0x00000001) is set, which means the source file opened for read-data access.
            Condition.IsTrue((smbConnection.openedFiles[copyChunkSourceFid].accessRights & 0x01) == 1);

            // FILE_SHARE_WRITE (0x00000002) is set, which means the target file opened for write-data access.
            Condition.IsTrue((smbConnection.openedFiles[request.fId].accessRights & 0x02) == 2);

            Update.UpdateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// FSCTL_SRV_COPYCHUNK Error Response.
        /// </summary>
        /// <param name="messageId">Message ID used to identify the message.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule(Action = "ErrorResponse(messageId, messageStatus)")]
        public static void ErrorFsctlSrvCopyChunkResponse(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue((messageStatus == MessageStatus.NetworkSessionExpired)
                                || (messageStatus == MessageStatus.NotSupported)
                                || (messageStatus == MessageStatus.AccessDenied)
                                || (messageStatus == MessageStatus.ObjectNameNotFound));

            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.FsctlSrvCupychunk);
            FsctlSrvCopyChunkRequest request = (FsctlSrvCopyChunkRequest)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.NetworkSessionExpired)
            {
                smbConnection.sessionList.Remove(request.sessionId);
                smbState = SmbState.Closed;
            }
            else if (messageStatus == MessageStatus.NotSupported)
            {
                if (!Parameter.isSupportCopyChunk)
                {
                    ModelHelper.CaptureRequirement(
                        30019,
                        @"[In Receiving an FSCTL_SRV_COPYCHUNK Request] If the server does not support this operation,
                        then it MUST fail the request with STATUS_NOT_SUPPORTED.");
                }
                smbState = SmbState.End;
            }
            else if (messageStatus == MessageStatus.AccessDenied)
            {
                Condition.IsTrue(Parameter.isSupportCopyChunk);
                Condition.IsTrue(request.length <= Parameter.totalBytesWritten);
                Condition.IsTrue(resumeKey == request.copychunkResumeKey);
                if ((resumeKey == request.copychunkResumeKey)
                        && ((smbConnection.openedFiles[copyChunkSourceFid].accessRights & 0x01) != 1))
                {
                    ModelHelper.CaptureRequirement(
                        4997,
                        @"[In Receiving an FSCTL_SRV_COPYCHUNK Request]If the file represented by the resume key is not
                        opened for read-data access, then the server MUST fail the operation with
                        STATUS_ACCESS_DENIED.");
                }

                if ((resumeKey == request.copychunkResumeKey)
                        && ((smbConnection.openedFiles[request.fId].accessRights & 0x02) != 2))
                {
                    ModelHelper.CaptureRequirement(
                        2447,
                        @"If the target file is not opened for write-data access,  then the server MUST fail the
                        operation with STATUS_ACCESS_DENIED.");
                }

                smbState = SmbState.End;
            }
            else if (messageStatus == MessageStatus.ObjectNameNotFound)
            {
                Condition.IsTrue(smbConnection.sessionList[request.sessionId].sessionState == SessionState.Valid);
                Condition.IsTrue(Parameter.isSupportCopyChunk);
                Condition.IsTrue(request.length <= Parameter.totalBytesWritten);
                if (resumeKey != request.copychunkResumeKey)
                {
                    ModelHelper.CaptureRequirement(
                        2445,
                        @"[In Receiving an FSCTL_SRV_COPYCHUNK Request]If the copychunk resume key is not valid, or does
                        not represent an open file, then the server MUST fail the operation with
                        STATUS_OBJECT_NAME_NOT_FOUND. ");
                }
            }
            smbConnection.sentRequest.Remove(messageId);
        }

        #endregion FSCTL_SRV_COPYCHUNK

        #endregion

        #region NT_TRANSACT_CREATE

        /// <summary>
        /// NT_TRANSACT_CREATE request.
        /// </summary>
        /// <param name="messageId">This is used to associate a response with a request.</param>
        /// <param name="sessionId">The current session ID for this connection.</param>
        /// <param name="treeId">The tree ID for the corrent share connection.</param>
        /// <param name="desiredAccess">In the model, there are 3 kinds of access right: read, write, readwrite.</param>
        /// <param name="createDisposition">The action to take if a file does or does not exist.</param>
        /// <param name="impersonationLevel">
        /// This field specifies the information given to the SUT about the client and how the SUT MUST represent,
        /// or impersonate the client.
        /// </param>
        /// <param name="fileName">This is used to represent the name of the resource.</param>
        /// <param name="shareType">The share type in the current tree connection.</param>
        /// <param name="isSigned">It indicates whether the message is signed or not for this request.</param>
        /// <param name="isOpenByFileId">
        /// It indicates whether the FILE_OPEN_BY_FILE_ID is set in CreateOptions field of Create Request.
        /// </param>
        /// <param name="isDirectoryFile">
        /// It indicates whether the FILE_DIRECTORY_FILE and FILE_NON_DIRECTORY_FILE are set.
        /// If true,FILE_DIRECTORY_FILE is set; else FILE_NON_DIRECTORY_FILE is set.
        /// </param>
        /// <param name="isMaximumAllowedSet">
        /// It indicates that the client set the maximum allowed in the request.
        /// </param>
        [Rule]
        public static void NtTransactCreateRequest(
            int messageId,
            int sessionId,
            int treeId,
            [Domain("ImpersonationLevel")] int impersonationLevel,
            [Domain("FileDomain")] string fileName,
            ShareType shareType,
            bool isSigned)
        {
            smbRequest = new NtTransactCreateRequest(
                messageId,
                sessionId,
                treeId,
                impersonationLevel,
                fileName,
                shareType,
                isSigned);
            Checker.CheckNtTransactCreateRequest(
                smbConnection,
                messageId,
                sessionId,
                treeId,
                shareType,
                isSigned,
                fileName,
                smbState);
            Requirement.AssumeCaptured("Send NT_TRANSACT_CREATE request");
            Update.UpdateNTTransactCreateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// NT_TRANSACT_CREATE response.
        /// </summary>
        /// <param name="messageId">This is used to associate a response with a request.</param>
        /// <param name="sessionId">The current session ID for this connection.</param>
        /// <param name="treeId">The tree ID for the corrent share connection.</param>
        /// <param name="isSigned">It indicates whether the message is signed or not for this response.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule]
        public static void NtTransactCreateResponse(
            int messageId,
            int sessionId,
            int treeId,
            bool isSigned,
            MessageStatus messageStatus)
        {
            Checker.CheckNtTransactCreateResponse(smbConnection, messageId, sessionId, treeId, isSigned, messageStatus);
            Update.UpdateNTTransactCreateResponse(smbConnection, messageId);
        }

        /// <summary>
        /// NT_TRANSACT_CREATE Error Response.
        /// </summary>
        /// <param name="messageId">This is used to associate a response with a request.</param>
        /// <param name="messageStatus">
        /// It indicates that the status code returned from the SUT is success or failure.
        /// </param>
        [Rule(Action = "ErrorResponse(messageId, messageStatus)")]
        public static void ErrorNtTransactCreate(int messageId, MessageStatus messageStatus)
        {
            Condition.IsTrue(smbConnection.sentRequest.ContainsKey(messageId));
            Condition.IsTrue(messageStatus == MessageStatus.NetworkSessionExpired
                                || messageStatus == MessageStatus.BadImpersonationLevel);
            Condition.IsTrue(smbConnection.sentRequest[messageId].command == Command.NtTransactCreate);
            NtTransactCreateRequest request = (NtTransactCreateRequest)smbConnection.sentRequest[messageId];

            if (messageStatus == MessageStatus.NetworkSessionExpired)
            {
                smbConnection.sessionList.Remove(request.sessionId);
                smbState = SmbState.Closed;
            }

            if (messageStatus == MessageStatus.BadImpersonationLevel)
            {
                Condition.IsTrue(request.impersonationLevel > 3 || request.impersonationLevel < 0);
                ModelHelper.CaptureRequirement(
                    9560,
                    @"<65> Section 2.2.7.1: Windows-based servers fail the request with STATUS_BAD_IMPERSONATION_LEVEL
                    if the impersonation level is not one of SECURITY_ANONYMOUS, SECURITY_IDENTIFICATION,
                    SECURITY_IMPERSONATION, or SECURITY_DELEGATION.");
            }

            smbConnection.sentRequest.Remove(messageId);
        }
        #endregion

        #region Data Domain

        /// <summary>
        /// This is the domain of abstract valid keys.
        /// </summary>
        public static IEnumerable<string> ValidKeys()
        {
            yield return "Key1";
            yield return "Key2";
        }

        #endregion

        #endregion

        #region FSCC model

        /// <summary>
        /// FSCC_FSCTL_Name Request
        /// </summary>
        /// <param name="messageId"> Message ID used to identify the message.</param>
        /// <param name="sessionId"> Session ID used to identify the session.</param>
        /// <param name="treeId"> Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// <param name="fid"> The target file identifier. </param>
        /// <param name="copychunkResumeKey">The server resume key for a source file.</param>
        /// <param name="sourceOffset"> The offset in the source file to copy from. </param>
        /// <param name="targetOffset"> The offset in the target file to copy to. </param>
        /// <param name="length"> The number of bytes to copy from the source file to the target file.</param>
        [Rule]
        public static void FSCCFSCTLNameRequest(int messageId,
                                                int sessionId,
                                                int treeId,
                                                bool isSigned,
                                                int fid,
                                                FSCCFSCTLName fsctlName)
        {
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(fid));
            Condition.IsTrue(smbConnection.openedFiles[fid].treeId == treeId);
            Checker.CheckRequest(smbConnection, messageId, sessionId, treeId, isSigned, smbState);

            smbRequest = new FSCTLNameRequest(messageId, sessionId, treeId, fid, isSigned, fsctlName);

            Update.UpdateRequest(smbConnection, smbRequest);
        }

        /// <summary>
        /// FSCC_FSCTL_Name Response
        /// </summary>
        /// <param name="messageId"> Message ID used to identify the message.</param>
        /// <param name="sessionId"> Session ID used to identify the session.</param>
        /// <param name="treeId"> Tree ID used to identify the tree connection.</param>
        /// <param name="isSigned">Indicate whether the SUT has message signing enabled or required.</param>
        /// /// <param name="messageStatus"> Indicates the status code returned from server, success or fail.</param>
        [Rule]
        public static void FSCCFSCTLNameResponse(int messageId,
                                                 int sessionId,
                                                 int treeId,
                                                 bool isSigned,
                                                 MessageStatus messageStatus)
        {
            FSCTLNameRequest request;

            Checker.CheckResponse<Microsoft.Protocol.TestSuites.Smb.FSCTLNameRequest>(smbConnection, messageId, sessionId, treeId, isSigned, messageStatus, out request,
                MessageStatus.Success);

            Condition.IsTrue(request.command == Command.FSCC_FSCTL_NAME);
            Condition.IsTrue(smbConnection.openedFiles.ContainsKey(request.fid));

            if (request.fsctlName == FSCCFSCTLName.FSCTL_CREATE_OR_GET_OBJECT_ID)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_CREATE_OR_GET_OBJECT_ID");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_DELETE_OBJECT_ID)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_DELETE_OBJECT_ID");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_FILESYSTEM_GET_STATISTICS)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_FILESYSTEM_GET_STATISTICS");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_GET_COMPRESSION)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_GET_COMPRESSION");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_GET_NTFS_VOLUME_DATA)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_GET_NTFS_VOLUME_DATA");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_IS_PATHNAME_VALID)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_IS_PATHNAME_VALID");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_READ_FILE_USN_DATA)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_READ_FILE_USN_DATA");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_SET_COMPRESSION)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_SET_COMPRESSION");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_SET_SPARSE)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_SET_SPARSE");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_SET_ZERO_DATA)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_SET_ZERO_DATA");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_SET_ZERO_ON_DEALLOCATION)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_SET_ZERO_ON_DEALLOCATION");
            }
            else if (request.fsctlName == FSCCFSCTLName.FSCTL_WRITE_USN_CLOSE_RECORD)
            {
                Requirement.AssumeCaptured("FSCTL Name is FSCTL_WRITE_USN_CLOSE_RECORD");
            }

            Update.UpdateResponse(smbConnection, messageId);
        }

        #endregion
    }
}


text:
.. _jobpack:

The Job Pack
============

The :term:`job pack` contains all the information needed for creating
and running a Disco :term:`job`.

The first time any :term:`task` of a job executes on a Disco node,
the job pack for the job is retrieved from the master,
and :ref:`jobhome` is unzipped into a job-specific directory.

.. seealso:: The Python :class:`disco.job.JobPack` class.

File format::

        +---------------- 4
        | magic / version |
        |---------------- 8 -------------- 12 ------------- 16 ------------- 20
        | jobdict offset  | jobenvs offset | jobhome offset | jobdata offset |
        |------------------------------------------------------------------ 128
        |                           ... reserved ...                         |
        |--------------------------------------------------------------------|
        |                               jobdict                              |
        |--------------------------------------------------------------------|
        |                               jobenvs                              |
        |--------------------------------------------------------------------|
        |                               jobhome                              |
        |--------------------------------------------------------------------|
        |                               jobdata                              |
        +--------------------------------------------------------------------+

.. _jobpack_version:

The current supported jobpack version is ``0x0002``.  Limited support
is provided for jobpacks of version ``0x0001``.

.. _jobdict:

The Job Dict
------------

The :term:`job dict` is a :term:`JSON` dictionary.

    .. attribute:: jobdict.pipeline

       A list of tuples (tuples are lists in JSON), with each tuple
       specifying a stage in the pipeline in the following form::

           stage_name, grouping

       Stage names in a pipeline have to be unique.  ``grouping``
       should be one of :term:`split`, :term:`group_label`,
       :term:`group_all`, :term:`group_node` and
       :term:`group_node_label`.

       .. seealso:: :ref:`pipeline`

    .. attribute:: jobdict.input

       A list of inputs, with each input specified in a tuple of the
       following form::

           label, size_hint, url_location_1, url_location_2, ...

       The ``label`` and ``size_hint`` are specified as integers,
       while each ``url_location`` is a string.  The ``size_hint`` is
       a hint indicating the size of this input, and is only used to
       optimize scheduling.

    .. attribute:: jobdict.worker

       The path to the :term:`worker` binary, relative to the
       :term:`job home`.  The master will execute this binary after it
       unpacks it from :ref:`jobhome`.

    .. attribute:: jobdict.prefix

       String giving the prefix the master should use for assigning a
       unique job name.

       .. note:: Only characters in ``[a-zA-Z0-9_]`` are allowed in the prefix.

    .. attribute:: jobdict.owner

       String name of the owner of the :term:`job`.

    .. attribute:: jobdict.save_results

       Boolean that when set to true tells Disco to save the job
       results to DDFS.  The output of the job is then the DDFS tag
       name containing the job results.

       .. versionadded:: 0.5

.. note::

    The following applies to jobdict attributes in jobpack version
    ``0x0001``.  Support for this version might be removed in a future
    release.

    .. attribute:: jobdict.input

       A list of urls or a list of lists of urls.  Each url is a
       string.

       .. note::
              An inner list of urls gives replica urls for the same
              data.  This lets you specify redundant versions of an
              input file.  If a list of redundant inputs is specified,
              the scheduler chooses the input that is located on the
              node with the lowest load at the time of scheduling.
              Redundant inputs are tried one by one until the task
              succeeds.  Redundant inputs require that :attr:`map?` is
              specified.

       .. note::
              In the pipeline model, the ``label`` associated with
              each of these inputs are all 0, and all inputs are
              assumed to have a ``size_hint`` of 0.

       .. deprecated:: 0.5

    .. attribute:: jobdict.map?

       Boolean telling whether or not this job should have a
       :term:`map` phase.

       .. deprecated:: 0.5

    .. attribute:: jobdict.reduce?

       Boolean telling whether or not this job should have a
       :term:`reduce` phase.

       .. deprecated:: 0.5

    .. attribute:: jobdict.nr_reduces

       Non-negative integer that used to tell the master how many
       reduces to run.  Now, if the value is not 1, then the number of
       reduces actually run by the pipeline depends on the labels
       output by the tasks in the map stage.

       .. deprecated:: 0.5

    .. attribute:: jobdict.scheduler

      * *max_cores* - use at most this many cores (applies
        to both map and reduce).  Default is ``2**31``.

      * *force_local* - always run task on the node where
        input data is located; never use HTTP to access
        data remotely.

      * *force_remote* - never run task on the node where
        input data is located; always use HTTP to access
        data remotely.

       .. versionadded:: 0.5.2

.. _jobenvs:

Job Environment Variables
-------------------------

A :term:`JSON` dictionary of environment variables (with string keys
and string values).  The master will set these in the environment
before running the :attr:`jobdict.worker`.

.. _jobhome:

The Job Home
------------

The :term:`job home` directory serialized into :term:`ZIP` format.
The master will unzip this before running the :attr:`jobdict.worker`.
The :term:`worker` is run with this directory as its working
directory.

In addition to the :term:`worker` executable, the :term:`job home` can
be populated with files that are needed at runtime by the worker.
These could either be shared libraries, helper scripts, or parameter
data.

.. note:: The .disco subdirectory of the *job home* is reserved by Disco.

The job home is shared by all tasks of the same job on the same node.
That is, if the job requires two map task and two reduce task
executions on a particular node, then the job home will be unpacked
only once on that node, but the worker executable will be executed
four times in the job home directory, and it is also possible for some
of these executions to be concurrent.  Thus, the worker should take
care to use unique filenames as needed.

.. _jobdata:

Additional Job Data
-------------------

Arbitrary data included in the :term:`job pack`, used by the :term:`worker`.
A running worker can access the job pack at the path specified by ``jobfile``
in the response to the :ref:`TASK` message.

.. _submitting_jobpack:

Creating and submitting a Job Pack
----------------------------------

The jobpack can be constructed and submitted using the ``disco job``
command.


text:
[CmdletBinding()]
param()

. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
. $PSScriptRoot\MockVariable.ps1
. $PSScriptRoot\MockModule.ps1

$remotePowershellRunnerPath = "$PSScriptRoot\..\PowerShellOnTargetMachines.ps1"

Register-Mock Get-ParsedSessionVariables { }

Register-Mock Invoke-PsOnRemote { }
Register-Mock Invoke-Command {
    $deploymentResponse = @{}
    $deploymentResponse.Status = "Passed"
    return $deploymentResponse
 }

Register-Mock Register-Environment { return GetEnvironmentWithStandardProvider $environmentWithSkipCANotSet  } -ParametersEvaluator {$EnvironmentName -eq $environmentWithSkipCANotSet}
Register-Mock Get-EnvironmentResources { return $validResources } -ParametersEvaluator {$EnvironmentName -eq $environmentWithSkipCANotSet}
Register-Mock Get-EnvironmentProperty { return $environmentWinRMHttpPort } -ParametersEvaluator {$Environment.Name -eq $environmentWithSkipCANotSet -and $Key -eq $resourceWinRMHttpPortKeyName}

& "$remotePowershellRunnerPath" -environmentName $environmentWithSkipCANotSet  -machineNames $validMachineName1 -scriptPath $validScriptPath -runPowershellInParallel $false -protocol "HTTP"

Assert-WasCalled Get-EnvironmentProperty -Times 0 -ParametersEvaluator {$Environment.Name -eq $environmentWithSkipCANotSet -and $Key -eq $resourceWinRMHttpsPortKeyName}

# Function called twice
Assert-WasCalled Get-EnvironmentProperty -Times 2 -ParametersEvaluator {$Environment.Name -eq $environmentWithSkipCANotSet -and $Key -eq $resourceWinRMHttpPortKeyName}


text:
using System.Security.Permissions;

namespace System.ComponentModel.Design.Serialization
{
    /// <summary>
    ///     This attribute can be placed on a class to indicate what serialization
    ///     object should be used to serialize the class at design time if it is
    ///     being used as a root object.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
    [Obsolete("This attribute has been deprecated. Use DesignerSerializerAttribute instead.  For example, to specify a root designer for CodeDom, use DesignerSerializerAttribute(...,typeof(TypeCodeDomSerializer)).  http://go.microsoft.com/fwlink/?linkid=14202")]
    public sealed class RootDesignerSerializerAttribute : Attribute
    {
        private string _typeId;

        /// <summary>
        ///     Creates a new designer serialization attribute.
        /// </summary>
        public RootDesignerSerializerAttribute(Type serializerType, Type baseSerializerType, bool reloadable)
        {
            SerializerTypeName = serializerType.AssemblyQualifiedName;
            SerializerBaseTypeName = baseSerializerType.AssemblyQualifiedName;
            Reloadable = reloadable;
        }

        /// <summary>
        ///     Creates a new designer serialization attribute.
        /// </summary>
        public RootDesignerSerializerAttribute(string serializerTypeName, Type baseSerializerType, bool reloadable)
        {
            SerializerTypeName = serializerTypeName;
            SerializerBaseTypeName = baseSerializerType.AssemblyQualifiedName;
            Reloadable = reloadable;
        }

        /// <summary>
        ///     Creates a new designer serialization attribute.
        /// </summary>
        public RootDesignerSerializerAttribute(string serializerTypeName, string baseSerializerTypeName, bool reloadable)
        {
            SerializerTypeName = serializerTypeName;
            SerializerBaseTypeName = baseSerializerTypeName;
            Reloadable = reloadable;
        }

        /// <summary>
        ///     Indicates that this root serializer supports reloading.  If false, the design document
        ///     will not automatically perform a reload on behalf of the user.  It will be the user's
        ///     responsibility to reload the document themselves.
        /// </summary>
        public bool Reloadable { get; }

        /// <summary>
        ///     Retrieves the fully qualified type name of the serializer.
        /// </summary>
        public string SerializerTypeName { get; }

        /// <summary>
        ///     Retrieves the fully qualified type name of the serializer base type.
        /// </summary>
        public string SerializerBaseTypeName { get; }

        /// <internalonly/>
        /// <summary>
        ///    <para>
        ///       This defines a unique ID for this attribute type. It is used
        ///       by filtering algorithms to identify two attributes that are
        ///       the same type. For most attributes, this just returns the
        ///       Type instance for the attribute. EditorAttribute overrides
        ///       this to include the type of the editor base type.
        ///    </para>
        /// </summary>
        public override object TypeId
        {
            get
            {
                if (_typeId == null)
                {
                    string baseType = SerializerBaseTypeName;
                    int comma = baseType.IndexOf(',');
                    if (comma != -1)
                    {
                        baseType = baseType.Substring(0, comma);
                    }
                    _typeId = GetType().FullName + baseType;
                }
                return _typeId;
            }
        }
    }
}


text:
package pintapp.pint.com.pint.test;

import android.test.ActivityInstrumentationTestCase2;
import android.view.Menu;

import com.robotium.solo.Solo;

import pintapp.pint.com.pint.*;
import pintapp.pint.com.pint.R;

/**
 * Created by Juan on 11/14/2016.
 */

public class OptionItemTest extends ActivityInstrumentationTestCase2<LoginActivity> {
    private Solo solo;

    public OptionItemTest() {
        super(LoginActivity.class);
    }

    public void setUp() throws Exception {
        super.setUp();
        solo = new Solo(getInstrumentation());
        getActivity();
    }

    @Override
    public void tearDown() throws Exception {
        solo.finishOpenedActivities();
        super.tearDown();
    }

    public void testRun() {
        //Wait for activity: 'pintapp.pint.com.pint.MainActivity'
        solo.waitForActivity(pintapp.pint.com.pint.LoginActivity.class, 2000);
        //Click on Empty Text View
        solo.clickOnView(solo.getView(pintapp.pint.com.pint.R.id.loginTextEmail));
        //Enter the text: 'Xueijao@gmail.com'
        solo.clearEditText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextEmail));
        solo.enterText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextEmail), "Xuejiao@gmail.com");
        //Click on Empty Text View
        solo.clickOnView(solo.getView(pintapp.pint.com.pint.R.id.loginTextPassword));
        //Enter the text: 'Xueijao12345'
        solo.clearEditText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextPassword));
        solo.enterText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextPassword), "Xuejiao12345");
        //Click on Login
        solo.clickOnView(solo.getView(pintapp.pint.com.pint.R.id.loginButtonLogin));
        //Wait for activity: 'pintapp.pint.com.pint.HomeActivity'
        assertTrue("pintapp.pint.com.pint.HomeActivity is not found!", solo.waitForActivity(pintapp.pint.com.pint.HomeActivity.class));
        solo.clickOnMenuItem("Logout");
        assertTrue("pintapp.pint.com.pintLoginActivity is not found!", solo.waitForActivity(pintapp.pint.com.pint.LoginActivity.class));
        //Wait for activity: 'pintapp.pint.com.pint.MainActivity'
        solo.waitForActivity(pintapp.pint.com.pint.LoginActivity.class, 2000);
        //Click on Empty Text View
        solo.clickOnView(solo.getView(pintapp.pint.com.pint.R.id.loginTextEmail));
        //Enter the text: 'Xueijao@gmail.com'
        solo.clearEditText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextEmail));
        solo.enterText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextEmail), "Xuejiao@gmail.com");
        //Click on Empty Text View
        solo.clickOnView(solo.getView(pintapp.pint.com.pint.R.id.loginTextPassword));
        //Enter the text: 'Xueijao12345'
        solo.clearEditText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextPassword));
        solo.enterText((android.widget.EditText) solo.getView(pintapp.pint.com.pint.R.id.loginTextPassword), "Xuejiao12345");
        //Click on Login
        solo.clickOnView(solo.getView(pintapp.pint.com.pint.R.id.loginButtonLogin));
        //Wait for activity: 'pintapp.pint.com.pint.HomeActivity'
        assertTrue("pintapp.pint.com.pint.HomeActivity is not found!", solo.waitForActivity(pintapp.pint.com.pint.HomeActivity.class));
        solo.pressMenuItem(0);
        //solo.clickOnMenuItem("action_settings");
        //solo.clickOnMenuItem("test_action");
        assertTrue("pintapp.pint.com.pintLoginActivity is not found!", solo.waitForActivity(pintapp.pint.com.pint.LoginActivity.class));

    }
}


text: an implementation of BSON


text:
namespace v8 {
namespace internal {
namespace compiler {

// Determine which instruction blocks need a frame and where frames must be
// constructed/deconstructed.
class FrameElider {
 public:
  explicit FrameElider(InstructionSequence* code);
  void Run();

 private:
  void MarkBlocks();
  void PropagateMarks();
  void MarkDeConstruction();
  bool PropagateInOrder();
  bool PropagateReversed();
  bool PropagateIntoBlock(InstructionBlock* block);
  const InstructionBlocks& instruction_blocks() const;
  InstructionBlock* InstructionBlockAt(RpoNumber rpo_number) const;
  Instruction* InstructionAt(int index) const;

  InstructionSequence* const code_;
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_BACKEND_FRAME_ELIDER_H_


text:
<!doctype html>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AngularJS • gyroscroll</title>

        <button ng-hide="gyro.started" ng-click="start()" class="button primary medium">start</button>
        <button ng-show="gyro.started" ng-click="stop()" class="button secondary medium">stop</button>

          Click start button to gyroscroll.

Credits:

Jan Antala


text:
#ifndef __ASM_ARCH_REALVIEW_H
#define __ASM_ARCH_REALVIEW_H

#include <linux/amba/bus.h>
#include <linux/io.h>

#include <asm/setup.h>
#include <asm/leds.h>

#define AMBA_DEVICE(name,busid,base,plat)			\
static struct amba_device name##_device = {			\
	.dev		= {					\
		.coherent_dma_mask = ~0,			\
		.init_name = busid,				\
		.platform_data = plat,				\
	},							\
	.res		= {					\
		.start	= REALVIEW_##base##_BASE,		\
		.end	= (REALVIEW_##base##_BASE) + SZ_4K - 1,	\
		.flags	= IORESOURCE_MEM,			\
	},							\
	.dma_mask	= ~0,					\
	.irq		= base##_IRQ,				\
}

struct machine_desc;

extern struct platform_device realview_flash_device;
extern struct platform_device realview_cf_device;
extern struct platform_device realview_i2c_device;
extern struct mmci_platform_data realview_mmc0_plat_data;
extern struct mmci_platform_data realview_mmc1_plat_data;
extern struct clcd_board clcd_plat_data;
extern void __iomem *timer0_va_base;
extern void __iomem *timer1_va_base;
extern void __iomem *timer2_va_base;
extern void __iomem *timer3_va_base;

extern void realview_leds_event(led_event_t ledevt);
extern void realview_timer_init(unsigned int timer_irq);
extern int realview_flash_register(struct resource *res, u32 num);
extern int realview_eth_register(const char *name, struct resource *res);
extern int realview_usb_register(struct resource *res);
extern void realview_init_early(void);
extern void realview_fixup(struct machine_desc *mdesc, struct tag *tags,
			   char **from, struct meminfo *meminfo);
extern void (*realview_reset)(char);

#endif


text:
enyo.kind({
	name: "enyo.sample.ComponentOverrideSample",
	components: [
		{kind:"enyo.sample.SampleKind"},
		{style:"height:50px;"},
		{kind:"enyo.sample.SubSampleKind"},
		{style:"height:50px;"},
		{kind:"enyo.sample.SampleKind"}
	]
});

enyo.kind({
	name: "enyo.sample.SampleKind",
	components: [
		{name: "title"},
		{name:"red", style:"background:red; color:white; padding:10px;", content:"Red", components: [
			{name:"orange", style:"background:orange; color:white; padding:10px;", content:"Orange", components: [
				{name:"green", style:"background:green; color:white; padding:10px; border-radius:10px;", content:"Green"}
			]}
		]},
		{name:"purple", style:"background:purple; color:white; padding:10px;", content:"Purple"},
		{name:"blue", style:"background:blue; color:white; padding:10px;", content:"Blue"}
	],
	create: function() {
		this.inherited(arguments);
		this.$.title.setContent(this.kindName);
	}
});

enyo.kind({
	name: "enyo.sample.SubSampleKind",
	kind: "enyo.sample.SampleKind",
	componentOverrides: {
		purple: {kind:"enyo.Button", content:"Purple shmurple!", style:"border-radius:30px;"},
		green: {kind:"enyo.Button", content:"Now I'm a Pink button!", style:"background-color:pink;"}
	}
});


text:
try:
    import mock
except ImportError:
    from unittest import mock  # NOQA

def test_post_count(instagram, element):
    """ Verify post count prop returns an int """
    expected_count = 5
    instagram.driver.find_elements.return_value = [element] * 5

    actual_count = instagram.home_page.post_count
    assert isinstance(actual_count, int)
    assert expected_count == actual_count