<commit_before>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BulkApi;
using System.Threading.Tasks;
using System.IO;

namespace BulkApiUnitTest
{
    [TestClass]
    public class UnitTest1
    {
        private string _UserName = "<EMAIL>";
        private string _Password = "";
        private string _SecurityToken = "";
        private string _SOQL = "select FirstName, LastName, Phone from Contact where LastName = 'Plotkin'";



        [TestMethod]
        public void TestUpsertContacts()
        {
            var csv = File.ReadAllText("contactsupsert.csv");
            var api = new BulkApiContext();
            api.Login(_UserName, _Password, _SecurityToken).Wait();
            var job = api.CreateJob(new JobCreationRequest { contentType = BulkContentType.CSV, Object = "Contact", operation = OperationType.query }).Result;
            var batch = api.AddBatch(csv, job.id).Result;
            while (batch.state == BatchState.Queued)
            {
                Task.Delay(5000).Wait();
                batch = api.GetBatchStatus(batch).Result;
            }
            var results = api.GetBatchResult(batch.id, batch.jobId).Result;

            File.AppendAllText("results.csv", results);
        }
        [TestMethod]
        public void TestBatchRunnerUpsert()
        {
            var csv = File.ReadAllText("contactsupsert.csv");
            var b = new BatchRunner(_UserName, _Password, _SecurityToken, OperationType.upsert, "Contact", BulkContentType.CSV, csv, "CMS_Family_ID__c").Task;
            File.AppendAllText("results.csv", b.Result);
        }
        [TestMethod]
        public void TestBatchRunnerQuery()
        {
            var b = new BatchRunner(_UserName, _Password, _SecurityToken, OperationType.query, "Contact", BulkContentType.CSV, _SOQL, "CMS_Family_ID__c").Task;
            File.AppendAllText("results.csv", b.Result);
        }
    }
}<commit_msg>Version 1.1<commit_after>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BulkApi;
using System.Threading.Tasks;
using System.IO;

namespace BulkApiUnitTest
{
    [TestClass]
    public class UnitTest1
    {
        private string _UserName = "<EMAIL>";
        private string _Password = "";
        private string _SecurityToken = "";
        private string _SOQL = "select FirstName, LastName, Phone from Contact where LastName = 'Plotkin'";


        //  Lower level Unit Test
        [TestMethod]
        public void TestUpsertContactsWithoutBatchRunner()
        {
            var csv = File.ReadAllText("contactsupsert.csv");
            var api = new BulkApiContext();
            api.Login(_UserName, _Password, _SecurityToken).Wait();
            var job = api.CreateJob(new JobCreationRequest { contentType = BulkContentType.CSV, Object = "Contact", operation = OperationType.query }).Result;
            var batch = api.AddBatch(csv, job.id).Result;
            while (batch.state == BatchState.Queued)
            {
                Task.Delay(5000).Wait();
                batch = api.GetBatchStatus(batch).Result;
            }
            var results = api.GetBatchResult(batch.id, batch.jobId).Result;

            File.AppendAllText("results.csv", results);
        }

        [TestMethod]
        public void TestBatchRunnerUpsert()
        {
            var csv = File.ReadAllText("contactsupsert.csv");
            var b = new BatchRunner(_UserName, _Password, _SecurityToken, OperationType.upsert, "Contact", BulkContentType.CSV, csv, "CMS_Family_ID__c").Task;
            File.AppendAllText("results.csv", b.Result);
        }

        [TestMethod]
        public void TestBatchRunnerQuery()
        {
            var b = new BatchRunner(_UserName, _Password, _SecurityToken, OperationType.query, "Contact", BulkContentType.CSV, _SOQL, null).Task;
            File.AppendAllText("results.csv", b.Result);
        }

        [TestMethod]
        public void TestBatchRunnersWithSharedLogin()
        {
            var api = new BulkApiContext();
            api.Login(_UserName, _Password, _SecurityToken).Wait();

            var csv = File.ReadAllText("contactsupsert.csv");
            var b1 = new BatchRunner(api, OperationType.upsert, "Contact", BulkContentType.CSV, csv, "CMS_Family_ID__c").Task;

            var b2 = new BatchRunner(api, OperationType.query, "Contact", BulkContentType.CSV, _SOQL, null).Task;

            File.AppendAllText("results.csv", b1.Result);
            File.AppendAllText("results.csv", b2.Result);
        }
    }
}
{'fraction_non_alphanumeric': 0.1086332523735924, 'fraction_numerical': 0.0035327886950761757, 'mean_word_length': 2.47926267281106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7458668', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1267, 'n_words': 273}