<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Imposters;

namespace MbDotNet.Tests.Imposters
{
    /// <summary>
    /// Summary description for ImposterTests
    /// </summary>
    [TestClass]
    public class HttpsImposterTests
    {
        #region Constructor Tests

        [TestMethod]
        public void Constructor_SetsPort()
        {
            const int port = 123;
            var imposter = new HttpsImposter(port, null);
            Assert.AreEqual(port, imposter.Port);
        }

        [TestMethod]
        public void Constructor_SetsProtocol()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.AreEqual("https", imposter.Protocol);
        }

        [TestMethod]
        public void Constructor_SetsName()
        {
            const string expectedName = "Service";
            var imposter = new HttpsImposter(123, expectedName);
            Assert.AreEqual(expectedName, imposter.Name);
        }

        [TestMethod]
        public void Constructor_InitializesStubsCollection()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.IsNotNull(imposter.Stubs);
        }

        [TestMethod]
        public void Constructor_SetsKey()
        {
            var expectedKeyValue = "testKey";
            var imposter = new HttpsImposter(123, null, expectedKeyValue, null);
            Assert.AreEqual(expectedKeyValue, imposter.Key);
        }

        [TestMethod]
        public void Constructor_SetsKeyAsNullWhenMissing()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.IsNull(imposter.Key);
        }

        [TestMethod]
        public void Constructor_SetsCert()
        {
            var expectedCertValue = "testCert";
            var imposter = new HttpsImposter(123, null, null, expectedCertValue);
            Assert.AreEqual(expectedCertValue, imposter.Cert);
        }

        #endregion

        #region Stub Tests

        [TestMethod]
        public void AddStub_AddsStubToCollection()
        {
            var imposter = new HttpsImposter(123, null);
            imposter.AddStub();
            Assert.AreEqual(1, imposter.Stubs.Count);
        }
                
        #endregion
    }
}<commit_msg>Check key is null if it's not defined [GREEN]<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Imposters;

namespace MbDotNet.Tests.Imposters
{
    /// <summary>
    /// Summary description for ImposterTests
    /// </summary>
    [TestClass]
    public class HttpsImposterTests
    {
        #region Constructor Tests

        [TestMethod]
        public void Constructor_SetsPort()
        {
            const int port = 123;
            var imposter = new HttpsImposter(port, null);
            Assert.AreEqual(port, imposter.Port);
        }

        [TestMethod]
        public void Constructor_SetsProtocol()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.AreEqual("https", imposter.Protocol);
        }

        [TestMethod]
        public void Constructor_SetsName()
        {
            const string expectedName = "Service";
            var imposter = new HttpsImposter(123, expectedName);
            Assert.AreEqual(expectedName, imposter.Name);
        }

        [TestMethod]
        public void Constructor_InitializesStubsCollection()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.IsNotNull(imposter.Stubs);
        }

        [TestMethod]
        public void Constructor_SetsKey()
        {
            var expectedKeyValue = "testKey";
            var imposter = new HttpsImposter(123, null, expectedKeyValue, null);
            Assert.AreEqual(expectedKeyValue, imposter.Key);
        }

        [TestMethod]
        public void Constructor_SetsKeyAsNullWhenMissing()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.IsNull(imposter.Key);
        }

        [TestMethod]
        public void Constructor_SetsCert()
        {
            var expectedCertValue = "testCert";
            var imposter = new HttpsImposter(123, null, null, expectedCertValue);
            Assert.AreEqual(expectedCertValue, imposter.Cert);
        }

        [TestMethod]
        public void Constructor_SetsCertAsNullWhenMissing()
        {
            var imposter = new HttpsImposter(123, null);
            Assert.IsNull(imposter.Cert);
        }

        #endregion

        #region Stub Tests

        [TestMethod]
        public void AddStub_AddsStubToCollection()
        {
            var imposter = new HttpsImposter(123, null);
            imposter.AddStub();
            Assert.AreEqual(1, imposter.Stubs.Count);
        }
                
        #endregion
    }
}
{'fraction_non_alphanumeric': 0.08521456172462884, 'fraction_numerical': 0.01077893024201749, 'mean_word_length': 1.925639500297442, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '931111', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1348, 'n_words': 284}