コード例 #1
0
        public void CryptoConfig2AddMappingTest()
        {
            List <Mapping> addedMappings = new List <Mapping>();

            // Make sure that registering a class a class without any alises works
            CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm1));
            addedMappings.Add(new Mapping {
                Name = "NewAlgorithm1", ExpectedType = typeof(NewAlgorithm1)
            });
            addedMappings.Add(new Mapping {
                Name = "Security.Cryptography.Test.NewAlgorithm1", ExpectedType = typeof(NewAlgorithm1)
            });
            CheckMappings(addedMappings);

            // Re-registering the same class with some new aliases should also work
            CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm1), "NA1", "NewAlg1");
            addedMappings.Add(new Mapping {
                Name = "NA1", ExpectedType = typeof(NewAlgorithm1)
            });
            addedMappings.Add(new Mapping {
                Name = "NewAlg1", ExpectedType = typeof(NewAlgorithm1)
            });
            CheckMappings(addedMappings);

            // Adding alaises even once we've already added alaises should continue to work
            CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm1), "New-Alg-1");
            addedMappings.Add(new Mapping {
                Name = "New-Alg-1", ExpectedType = typeof(NewAlgorithm1)
            });
            CheckMappings(addedMappings);

            // Add an algorithm and some alaises at the same time, should work the same as doing the above all at once
            CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm2), "NA2", "NewAlg2", "New-Alg-2");
            addedMappings.Add(new Mapping {
                Name = "NewAlgorithm2", ExpectedType = typeof(NewAlgorithm2)
            });
            addedMappings.Add(new Mapping {
                Name = "Security.Cryptography.Test.NewAlgorithm2", ExpectedType = typeof(NewAlgorithm2)
            });
            addedMappings.Add(new Mapping {
                Name = "NA2", ExpectedType = typeof(NewAlgorithm2)
            });
            addedMappings.Add(new Mapping {
                Name = "NewAlg2", ExpectedType = typeof(NewAlgorithm2)
            });
            addedMappings.Add(new Mapping {
                Name = "New-Alg-2", ExpectedType = typeof(NewAlgorithm2)
            });
            CheckMappings(addedMappings);
        }
コード例 #2
0
 public void CryptoConfig2AddDuplicateMappingTest()
 {
     CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm5), "NA5", "NewAlg5", "New-Alg5");
     CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm6), "NA5");
 }
コード例 #3
0
 public void CryptoConfig2AddNullMappingTest()
 {
     CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm4), "NA4", "NewAlg4", null);
 }
コード例 #4
0
 public void CryptoConfig2AddEmptyMappingTest()
 {
     CryptoConfig2.AddAlgorithm(typeof(NewAlgorithm3), "NA3", "", "New-Alg-3");
 }