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(); } }
public void InitializedWithAlgorithmFromDITest() { try { InitializeSymmetricAlgorithmTest(); var target = new SymmetricAlgorithmFactory(); target.Initialize(); var symmetric1 = target.Create(); Assert.IsNotNull(symmetric1); var symmetric2 = target.Create(); Assert.IsNotNull(symmetric2); Assert.IsFalse(object.ReferenceEquals(symmetric1, symmetric2)); Assert.IsInstanceOfType(symmetric1, typeof(Aes)); Assert.IsInstanceOfType(symmetric2, typeof(Aes)); } finally { CleanupTest(); } }
public void InitializedWithBadNameFromDISymmetricTest() { try { InitializeSymmetricNameTest("foo"); var target = new SymmetricAlgorithmFactory(); target.Initialize(); } finally { CleanupTest(); } }
public void InitializedWithGoodNameTest() { try { InitializeSymmetricNameTest("DES"); var target = new SymmetricAlgorithmFactory(); target.Initialize("TripleDES"); var symmetric1 = target.Create(); Assert.IsNotNull(symmetric1); Assert.AreEqual("TripleDES", target.SymmetricAlgorithmName); var symmetric2 = target.Create(); Assert.IsNotNull(symmetric2); Assert.AreNotEqual(symmetric1, symmetric2); } finally { CleanupTest(); } }
public void InitializedWithEmptyNameFromDITest() { try { InitializeSymmetricNameTest(""); var target = new SymmetricAlgorithmFactory(); target.Initialize(); var symmetric1 = target.Create(); Assert.IsNotNull(symmetric1); Assert.AreEqual("AESManaged", target.SymmetricAlgorithmName); var symmetric2 = target.Create(); Assert.IsNotNull(symmetric2); Assert.AreNotEqual(symmetric1, symmetric2); } finally { CleanupTest(); } }