<commit_before>﻿using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;

namespace VersionOne.SDK.APIClient.IntegrationTests
{
    [TestClass]
    public class IntegrationTests
    {
        private readonly string _v1InstanceUrl = ConfigurationManager.AppSettings.Get("V1Url");
        private readonly bool _useOAuthEndpoints = bool.Parse(ConfigurationManager.AppSettings.Get("UseOAuthEndpoints"));
        private readonly string _v1AccessToken = ConfigurationManager.AppSettings.Get("V1AccessToken");
        private readonly string _v1Username = ConfigurationManager.AppSettings.Get("V1UserName");
        private readonly string _v1Password = ConfigurationManager.AppSettings.Get("V1Password");

        #region Connection

        [TestMethod]
        public void ConnectionWithUsernameAndPassword()
        {
            var services = new Services(
                V1Connector
                    .WithInstanceUrl(_v1InstanceUrl)
                    .WithUserAgentHeader(".NET_SDK_Integration_Test", "1.0")
                    .WithUsernameAndPassword(_v1Username, _v1Password)
                    .Build());

            var member20Id = services.GetOid("Member:20");
            var result = services.Retrieve(new Query(member20Id));

            Assert.IsTrue(result.Assets.Count == 1);
        }

        [TestMethod]
        public void ConnectionWithAccessToken()
        {
            var services = GetServices();

            var member20Id = services.GetOid("Member:20");
            var result = services.Retrieve(new Query(member20Id));

            Assert.IsTrue(result.Assets.Count == 1);
        }

        #endregion

        #region Creates

        [TestMethod]
        public void CreateEpic()
        {
            var services = GetServices();

            var contextId = IntegrationTestsHelper.GetTestProjectOid(_useOAuthEndpoints);
            var epicType = services.Meta.GetAssetType("Epic");
            var newEpic = services.New(epicType, contextId);
            var nameAttribute = epicType.GetAttributeDefinition("Name");
            var name = string.Format("Test Epic {0} Create epic", contextId);
            newEpic.SetAttributeValue(nameAttribute, name);
            services.Save(newEpic);<commit_msg>Tweaked ConnectionWithUsernameAndPassword test to be ignored if integration tests run against a NTLM instance<commit_after>﻿using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;

namespace VersionOne.SDK.APIClient.IntegrationTests
{
    [TestClass]
    public class IntegrationTests
    {
        private readonly string _v1InstanceUrl = ConfigurationManager.AppSettings.Get("V1Url");
        private readonly bool _useOAuthEndpoints = bool.Parse(ConfigurationManager.AppSettings.Get("UseOAuthEndpoints"));
        private readonly string _v1AccessToken = ConfigurationManager.AppSettings.Get("V1AccessToken");
        private readonly string _v1Username = ConfigurationManager.AppSettings.Get("V1UserName");
        private readonly string _v1Password = ConfigurationManager.AppSettings.Get("V1Password");

        #region Connection

        [TestMethod]
        public void ConnectionWithUsernameAndPassword()
        {
            if (_useOAuthEndpoints)
            {
                Assert.Inconclusive();
            }
            else
            {
                var services = new Services(
                    V1Connector
                        .WithInstanceUrl(_v1InstanceUrl)
                        .WithUserAgentHeader(".NET_SDK_Integration_Test", "1.0")
                        .WithUsernameAndPassword(_v1Username, _<PASSWORD>)
                        .Build());

                var member20Id = services.GetOid("Member:20");
                var result = services.Retrieve(new Query(member20Id));

                Assert.IsTrue(result.Assets.Count == 1);
            }
        }

        [TestMethod]
        public void ConnectionWithAccessToken()
        {
            var services = GetServices();

            var member20Id = services.GetOid("Member:20");
            var result = services.Retrieve(new Query(member20Id));

            Assert.IsTrue(result.Assets.Count == 1);
        }

        #endregion

        #region Creates

        [TestMethod]
        public void CreateEpic()
        {
            var services = GetServices();

            var contextId = IntegrationTestsHelper.GetTestProjectOid(_useOAuthEndpoints);
            var epicType = services.Meta.GetAssetType("Epic");
            var newEpic = services.New(epicType, contextId);
            var nameAttribute = epicType.GetAttributeDefinition("Name");
            var name = string.Format("Test Epic {0} Create epic", contextId);
            newEpic.SetAttributeValue(nameAttribute, name);
            services.Save(newEpic);
{'fraction_non_alphanumeric': 0.08735540486637415, 'fraction_numerical': 0.011368169126445952, 'mean_word_length': 2.432580424366872, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6336631', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1240, 'n_words': 258}