context: using System.Collections.ObjectModel;
  using System.ComponentModel;
  using Sphinx.Client.Helpers;
  using Microsoft.VisualStudio.TestTools.UnitTesting;
  using System;
  using System.Collections;
  using System.Collections.Generic;
  
  namespace Sphinx.Client.UnitTests.Test.Helpers
  {
      
      
      /// <summary>
      ///This is a test class for ArgumentAssert and is intended
      ///to contain all ArgumentAssert Unit Tests
      ///</summary>
      [TestClass]
      public class ArgumentAssertUnitTest
      {
          /// <summary>
          ///Gets or sets the test context which provides
          ///information about and functionality for the current test run.
          ///</summary>
          public TestContext TestContext { get; set; }
  
          #region Additional test attributes
          // 
          //You can use the following additional attributes as you write your tests:
          //
          //Use ClassInitialize to run code before running the first test in the class
          //[ClassInitialize()]
          //public static void MyClassInitialize(TestContext testContext)
          //{
          //}
          //
          //Use ClassCleanup to run code after all tests in a class have run
          //[ClassCleanup()]
          //public static void MyClassCleanup()
          //{
          //}
          //
          //Use TestInitialize to run code before running each test
          //[TestInitialize()]
          //public void MyTestInitialize()
          //{
          //}
          //
          //Use TestCleanup to run code after each test has run
          //[TestCleanup()]
          //public void MyTestCleanup()
          //{
          //}
          //
          #endregion
  
          #region Tests
  		/// <summary>
          ///A test for IsTrue
          ///</summary>
          [TestMethod]
          public void IsTrueTest()
          {
              string message = string.Empty;
              try
              {
                  ArgumentAssert.IsTrue(true, message);
              }
              catch(Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              try
              {
                  ArgumentAssert.IsTrue(false, message);
                  Assert.Fail("Assert method must throw ArgumentException exception");
              }
              catch(ArgumentException)
              {
                  // test passed
              }
          }
  
          /// <summary>
          ///A test for IsFalse
          ///</summary>
          [TestMethod]
          public void IsFalseTest()
          {
              string message = string.Empty;
              try
              {
                  ArgumentAssert.IsFalse(false, message);
              }
              catch
              {
                  Assert.Fail("Assert method must throw no exceptions");
              }
  
              try
              {
                  ArgumentAssert.IsFalse(true, message);
                  Assert.Fail("Assert method must throw ArgumentException exception");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
  
          /// <summary>
          ///A test for IsNotNull
          ///</summary>
          public void IsNotNullTestHelper<T>() where T : class, new()
          {
              string argumentName = string.Empty;
  
              T argumentValue = new T(); 
              try
              {
                  ArgumentAssert.IsNotNull<T>(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              argumentValue = null;
              try
              {
                  ArgumentAssert.IsNotNull<T>(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          [TestMethod]
          public void IsNotNullTest()
          {
              IsNotNullTestHelper<GenericParameterHelper>();
          }
  
          /// <summary>
          ///A test for IsNotEmpty with string argument
          ///</summary>
          [TestMethod]
          public void IsNotEmptyTestString()
          {
              string argumentName = string.Empty;
              string argumentValue = "test";
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              } 
              
              argumentValue = string.Empty;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          /// <summary>
          ///A test for IsNotEmpty with generic <T> param.
          ///</summary>
          public void IsNotEmptyTestGerericHelper<T>() where T : class, new()
          {
              ICollection<T> argumentValue = new Collection<T>(); 
              argumentValue.Add(new T());
              string argumentName = string.Empty; 
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              argumentValue = null;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          [TestMethod]
          public void IsNotEmptyTestGeneric()
          {
              IsNotEmptyTestGerericHelper<GenericParameterHelper>();
          }
  
          /// <summary>
          ///A test for IsNotEmpty with generic array param.
          ///</summary>
          public void IsNotEmptyTestGenericArrayHelper<T>() where T: class, new()
          {
              T[] argumentValue = new T[] { new T()  };
              string argumentName = string.Empty;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              argumentValue = null;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          [TestMethod]
          public void IsNotEmptyTestGenericArray()
          {
              IsNotEmptyTestGenericArrayHelper<GenericParameterHelper>();
          }
  
          /// <summary>
          ///A test for IsNotEmpty with generic dictionary param.
          ///</summary>
          public void IsNotEmptyTestGenericDictionaryHelper<TKey, TValue>() where TKey: class, new() where TValue: class, new()
          {
              IDictionary<TKey, TValue> argumentValue = new Dictionary<TKey, TValue>();
              argumentValue.Add(new TKey(), new TValue());
              string argumentName = string.Empty; 
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              argumentValue = null;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          [TestMethod]
          public void IsNotEmptyTestGenericDictionary()
          {
              IsNotEmptyTestGenericDictionaryHelper<GenericParameterHelper, GenericParameterHelper>();
          }
  
          /// <summary>
          ///A test for IsNotEmpty with ICollection generic param
          ///</summary>
          [TestMethod]
          public void IsNotEmptyTestCollectionGeneric()
          {
              ICollection argumentValue = new byte[] { 1, 2, 3 };
              string argumentName = string.Empty;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              argumentValue = null;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          /// <summary>
          ///A test for IsNotEmpty
          ///</summary>
          [TestMethod]
          public void IsNotEmptyTestIn32()
          {
              int argumentValue = 1;
              string argumentName = string.Empty;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
  
              argumentValue = 0;
              try
              {
                  ArgumentAssert.IsNotEmpty(argumentValue, argumentName);
                  Assert.Fail("Assert method must throw ArgumentException exception.");
              }
              catch (ArgumentException)
              {
                  // test passed
              }
          }
  
          /// <summary>
          ///A test for IsInRange with long arguments
          ///</summary>
          [TestMethod]
          public void IsInRangeTestInt64()
          {
              string argumentName = string.Empty;
              // close range
              long value = 0;
              try
              {
                  ArgumentAssert.IsInRange(value, 0, 0, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
              // correct range
              value = 1;
              try
              {
                  ArgumentAssert.IsInRange(value, 0, 2, argumentName);
              }
              catch (Exception ex)
              {
                  Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
              }
              // incorrect range
              value = -1;
              try
              {
                  ArgumentAssert.IsInRange(value, 0, -1, argumentName);
                  Assert.Fail("Assert method must throw ArgumentOutOfRangeException exception.");
              }
              catch (ArgumentOutOfRangeException)
              {
                  // test range
              }
              // out of range
              value = 0;
              try
              {
                  ArgumentAssert.IsInRange(value, 1, 2, argumentName);
                  Assert.Fail("Assert method must throw ArgumentOutOfRangeException exception.");
              }
              catch (ArgumentOutOfRangeException)
              {
                  // test passed
              }
          }
  
          /// <summary>
          ///A test for IsInRange with DateTime arguments
          ///</summary>
          [TestMethod]
          public void IsInRangeTestDateTime()
          {
              string argumentName = string.Empty;
              // close range
  
gt:             DateTime value = new DateTime(1960, 12, 12, 0, 0, 0);