<commit_before>﻿using System;
using System.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hylasoft.Dependency.Tests
{
  [TestClass]
  public class AccountTest
  {
    [TestMethod]
    public void ShouldInitializeTheSingletonCorrectly()
    {
      // Init to true
      var dep = Hdependency.Initialize(true);
      Assert.AreEqual(dep, Hdependency.Provider, "the returned hdep should be the same of the singleton");
      try
      {
        Hdependency.Initialize();
      }
      catch (Exception)
      {
        Assert.Fail("it shouldn't fail this time, since it's in test");
      }
      Assert.AreNotEqual(dep, Hdependency.Provider,
        "the two deps now shouldn't be the same, since it's been reinitialized");
      try
      {
        Hdependency.Initialize(true);
        Assert.Fail("It should fail now because it has been not initialized in test mode before");
      }
      catch (InvalidOperationException e)
      {
        //here is fine, the exception is being correctly thrown
      }
    }

    [TestMethod]
    public void ShouldGetTheRightService()
    {
      var dep = new Hdependency();
      IEnumerable service = "test"; //a string is a valid IEnumerable, so this is possible
      dep.Register<IEnumerable>(service);
      Assert.AreEqual("test", dep.Get<IEnumerable>());
    }

    [TestMethod]
    public void ShouldntRegisterTwice()
    {
      var dep = new Hdependency();
      IEnumerable service = "test"; //a string is a valid IEnumerable, so this is possible
      dep.Register<IEnumerable>(service);
      try
      {
        dep.Register<IEnumerable>(service); //already registered
        Assert.Fail();
      }
      catch (InvalidOperationException)
      {
        //here is fine, the exception is being correctly thrown<commit_msg>fix codebase to comply with code analysis<commit_after>﻿using System;
using System.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hylasoft.Dependency.Tests
{
  [TestClass]
  public class AccountTest
  {
    [TestMethod]
    public void ShouldInitializeTheSingletonCorrectly()
    {
      // Init to true
      var dep = Hdependency.Initialize(true);
      Assert.AreEqual(dep, Hdependency.Provider, "the returned hdep should be the same of the singleton");
      try
      {
        Hdependency.Initialize();
      }
      catch (Exception)
      {
        Assert.Fail("it shouldn't fail this time, since it's in test");
      }
      Assert.AreNotEqual(dep, Hdependency.Provider,
        "the two deps now shouldn't be the same, since it's been reinitialized");
      try
      {
        Hdependency.Initialize(true);
        Assert.Fail("It should fail now because it has been not initialized in test mode before");
      }
      catch (InvalidOperationException)
      {
        //here is fine, the exception is being correctly thrown
      }
    }

    [TestMethod]
    public void ShouldGetTheRightService()
    {
      var dep = new Hdependency();
      IEnumerable service = "test"; //a string is a valid IEnumerable, so this is possible
      dep.Register<IEnumerable>(service);
      Assert.AreEqual("test", dep.Get<IEnumerable>());
    }

    [TestMethod]
    public void ShouldntRegisterTwice()
    {
      var dep = new Hdependency();
      IEnumerable service = "test"; //a string is a valid IEnumerable, so this is possible
      dep.Register<IEnumerable>(service);
      try
      {
        dep.Register<IEnumerable>(service); //already registered
        Assert.Fail();
      }
      catch (InvalidOperationException)
      {
        //here is fine, the exception is being correctly thrown
{'fraction_non_alphanumeric': 0.09115870400878638, 'fraction_numerical': 0.0, 'mean_word_length': 2.621272365805169, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '7472850', 'n_tokens_mistral': 987, 'n_tokens_neox': 962, 'n_words': 306}