Exemplo n.º 1
0
        public void InitializedTest5()
        {
            try
            {
                ServiceLocatorWrapper.Reset();
                _unityServiceLocator = new UnityServiceLocator(
                    new UnityContainer()
                    /*.RegisterInstance<string>(Algorithms.Hash.ResolveName, "SHA1")*/
                    /*.RegisterType<HashAlgorithm, SHA512Cng>()*/);
                ServiceLocator.SetLocatorProvider(() => _unityServiceLocator);

                var target = new HashAlgorithmFactory();

                target.Initialize("SHA384");

                var hasher = target.Create();

                Assert.IsNotNull(hasher);
                Assert.IsInstanceOfType(hasher, typeof(SHA384));
            }
            finally
            {
                CleanupTest();
            }
        }
Exemplo n.º 2
0
        public void InitializedTest5()
        {
            try
            {
                ServiceLocatorWrapper.Reset();
                _unityServiceLocator = new UnityServiceLocator(
                    new UnityContainer()
                    /*.RegisterInstance<string>(Algorithms.Symmetric.ResolveName, "DES")*/
                    /*.RegisterType<Symmetric, TripleDESCryptoServiceProvider>()*/);
                ServiceLocator.SetLocatorProvider(() => _unityServiceLocator);

                var target = new SymmetricAlgorithmFactory();

                target.Initialize("RC2");

                var symmetric = target.Create();

                Assert.IsNotNull(symmetric);
                Assert.IsInstanceOfType(symmetric, typeof(RC2));
            }
            finally
            {
                CleanupTest();
            }
        }
Exemplo n.º 3
0
 public static void InitializeHashAlgorithmTest()
 {
     ServiceLocatorWrapper.Reset();
     _unityServiceLocator = new UnityServiceLocator(
         new UnityContainer()
         .RegisterType <HashAlgorithm, MD5Cng>());
     ServiceLocator.SetLocatorProvider(() => _unityServiceLocator);
 }
Exemplo n.º 4
0
 public static void InitializeHashNameTest(string name)
 {
     ServiceLocatorWrapper.Reset();
     _unityServiceLocator = new UnityServiceLocator(
         new UnityContainer()
         .RegisterInstance <string>(Algorithms.Hash.ResolveName, name));
     ServiceLocator.SetLocatorProvider(() => _unityServiceLocator);
 }
Exemplo n.º 5
0
 public static void InitializeSymmetricAlgorithmTest()
 {
     ServiceLocatorWrapper.Reset();
     _unityServiceLocator = new UnityServiceLocator(
         new UnityContainer()
         .RegisterType <SymmetricAlgorithm, Rijndael>());
     ServiceLocator.SetLocatorProvider(() => _unityServiceLocator);
 }
Exemplo n.º 6
0
 public static void CleanupTest()
 {
     ServiceLocator.SetLocatorProvider(null);
     if (_unityServiceLocator != null)
     {
         _unityServiceLocator.Dispose();
     }
     ServiceLocatorWrapper.Reset();
 }