<commit_before>﻿// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Threading;
using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Auth;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Commands.Batch.Properties;
using Microsoft.Azure.Management.Batch.Models;
using System;
using System.Collections;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using TaskDependencies = Microsoft.Azure.Batch.Protocol.Models.TaskDependencies;

namespace Microsoft.Azure.Commands.Batch
{
    /// <summary>
    /// Contains Batch account details for use when interacting with the Batch service.
    /// </summary>
    public class BatchAccountContext
    {
        private AccountKeyType keyInUse;
        private BatchClient batchOMClient;

        /// <summary>
        /// The account resource Id.
        /// </summary>
        public string Id { get; private set; }

        /// <summary>
        /// The account endpoint.
        /// </summary>
        public string AccountEndpoint { get; private set; }

        /// <summary>
        /// The primary account key.
        /// </summary>
        public string PrimaryAccountKey { get; internal set; }

        /// <summary>
        /// The secondary account key.
        /// </summary>
        public string SecondaryAccountKey { get; internal set; }

        /// <summary>
        /// The name of the Batch account.
        /// </summary>
        public string AccountName { get; protected set; }

        /// <summary>
        /// The region in which the account was created.
        /// </summary>
        public string Location { get; private set; }

        /// <summary>
        /// The name of the resource group that the account resource is under.
        /// </summary>
        public string ResourceGroupName { get; private set; }

        /// <summary>
        /// The subscription Id that the account belongs to.
        /// </summary>
        public string Subscription { get; private set; }

        /// <summary>
        /// The provisioning state of the account resource.
        /// </summary>
        public string State { get; private set; }

        /// <summary>
        /// The Batch service endpoint.
        /// </summary>
        public string TaskTenantUrl { get; protected set; }

        /// <summary>
        /// Tags associated with the account resource.
        /// </summary>
        public Hashtable[] Tags { get; private set; }

        /// <summary>
        /// A string representation of the Tags property.
        /// </summary>
        public string TagsTable
        {
            get { return Helpers.FormatTagsTable(Tags); }
        }

        /// <summary>
        /// The core quota for this Batch account.
        /// </summary>
        public int CoreQuota { get; private set; }

        /// <summary>
        /// The pool quota for this Batch account.
        /// </summary>
        public int PoolQuota { get; private set; }

        /// <summary>
        /// The active job and job schedule quota for this Batch account.
        /// </summary>
        public int ActiveJobAndJobScheduleQuota { get; private set; }

        /// <summary>
        /// The key to use when interacting with the Batch service. Be default, the primary key will be used.
        /// </summary>
        public AccountKeyType KeyInUse 
        { 
            get { return this.keyInUse; }
            set
            {
                if (value != this.keyInUse)
                {
                    this.batchOMClient.Dispose();
                    this.batchOMClient = null;
                }
                this.keyInUse = value;
            } 
        }

        internal BatchClient BatchOMClient
        {
            get
            {
                if (this.batchOMClient == null)
                {
                    if ((KeyInUse == AccountKeyType.Primary && string.IsNullOrEmpty(PrimaryAccountKey)) ||
                        (KeyInUse == AccountKeyType.Secondary && string.IsNullOrEmpty(SecondaryAccountKey)))
                    {
                        throw new InvalidOperationException(string.Format(Resources.KeyNotPresent, KeyInUse));
                    }
                    string key = KeyInUse == AccountKeyType.Primary ? PrimaryAccountKey : SecondaryAccountKey;
                    BatchServiceClient restClient = CreateBatchRestClient(TaskTenantUrl, AccountName, key);
                    this.batchOMClient = Microsoft.Azure.Batch.BatchClient.Open(restClient);
                }
                return this.batchOMClient;
            }
        }

        internal BatchAccountContext()
        {
            this.keyInUse = AccountKeyType.Primary;
        }

        internal BatchAccountContext(string accountEndpoint) : this()
        {
            this.AccountEndpoint = accountEndpoint;
        }<commit_msg>Fixed scenario tests<commit_after>﻿// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Threading;
using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Auth;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Commands.Batch.Properties;
using Microsoft.Azure.Management.Batch.Models;
using System;
using System.Collections;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using TaskDependencies = Microsoft.Azure.Batch.Protocol.Models.TaskDependencies;

namespace Microsoft.Azure.Commands.Batch
{
    /// <summary>
    /// Contains Batch account details for use when interacting with the Batch service.
    /// </summary>
    public class BatchAccountContext
    {
        private AccountKeyType keyInUse;
        private BatchClient batchOMClient;

        /// <summary>
        /// The account resource Id.
        /// </summary>
        public string Id { get; private set; }

        /// <summary>
        /// The account endpoint.
        /// </summary>
        public string AccountEndpoint { get; private set; }

        /// <summary>
        /// The primary account key.
        /// </summary>
        public string PrimaryAccountKey { get; internal set; }

        /// <summary>
        /// The secondary account key.
        /// </summary>
        public string SecondaryAccountKey { get; internal set; }

        /// <summary>
        /// The name of the Batch account.
        /// </summary>
        public string AccountName { get; protected set; }

        /// <summary>
        /// The region in which the account was created.
        /// </summary>
        public string Location { get; private set; }

        /// <summary>
        /// The name of the resource group that the account resource is under.
        /// </summary>
        public string ResourceGroupName { get; private set; }

        /// <summary>
        /// The subscription Id that the account belongs to.
        /// </summary>
        public string Subscription { get; private set; }

        /// <summary>
        /// The provisioning state of the account resource.
        /// </summary>
        public string State { get; private set; }

        /// <summary>
        /// The Batch service endpoint.
        /// </summary>
        public string TaskTenantUrl { get; protected set; }

        /// <summary>
        /// Tags associated with the account resource.
        /// </summary>
        public Hashtable[] Tags { get; private set; }

        /// <summary>
        /// A string representation of the Tags property.
        /// </summary>
        public string TagsTable
        {
            get { return Helpers.FormatTagsTable(Tags); }
        }

        /// <summary>
        /// The core quota for this Batch account.
        /// </summary>
        public int CoreQuota { get; private set; }

        /// <summary>
        /// The pool quota for this Batch account.
        /// </summary>
        public int PoolQuota { get; private set; }

        /// <summary>
        /// The active job and job schedule quota for this Batch account.
        /// </summary>
        public int ActiveJobAndJobScheduleQuota { get; private set; }

        /// <summary>
        /// The key to use when interacting with the Batch service. Be default, the primary key will be used.
        /// </summary>
        public AccountKeyType KeyInUse 
        { 
            get { return this.keyInUse; }
            set
            {
                if (value != this.keyInUse)
                {
                    this.batchOMClient.Dispose();
                    this.batchOMClient = null;
                }
                this.keyInUse = value;
            } 
        }

        internal BatchClient BatchOMClient
        {
            get
            {
                if (this.batchOMClient == null)
                {
                    if ((KeyInUse == AccountKeyType.Primary && string.IsNullOrEmpty(PrimaryAccountKey)) ||
                        (KeyInUse == AccountKeyType.Secondary && string.IsNullOrEmpty(SecondaryAccountKey)))
                    {
                        throw new InvalidOperationException(string.Format(Resources.KeyNotPresent, KeyInUse));
                    }
                    string key = KeyInUse == AccountKeyType.Primary ? PrimaryAccountKey : SecondaryAccountKey;
                    BatchServiceClient restClient = CreateBatchRestClient(TaskTenantUrl, AccountName, key);
                    this.batchOMClient = Microsoft.Azure.Batch.BatchClient.Open(restClient);
                }
                return this.batchOMClient;
            }
        }

        public BatchAccountContext()
        {
            this.keyInUse = AccountKeyType.Primary;
        }

        internal BatchAccountContext(string accountEndpoint) : this()
        {
            this.AccountEndpoint = accountEndpoint;
        }
{'fraction_non_alphanumeric': 0.1255637103192148, 'fraction_numerical': 0.0007074011848969847, 'mean_word_length': 1.62595774320873, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3405347', 'n_tokens_mistral': 2699, 'n_tokens_neox': 2601, 'n_words': 866}