Esempio n. 1
0
        private static IReadOnlyCollection <IKey> RunGetAllKeysCore(string xml, IActivator activator, ILoggerFactory loggerFactory = null)
        {
            // Arrange
            var mockXmlRepository = new Mock <IXmlRepository>();

            mockXmlRepository.Setup(o => o.GetAllElements()).Returns(XElement.Parse(xml).Elements().ToArray());
            var options = Options.Create(new KeyManagementOptions()
            {
                AuthenticatedEncryptorConfiguration = new Mock <AlgorithmConfiguration>().Object,
                XmlRepository = mockXmlRepository.Object,
                XmlEncryptor  = null
            });
            var keyManager = new XmlKeyManager(options, activator, loggerFactory ?? NullLoggerFactory.Instance);

            // Act
            return(keyManager.GetAllKeys());
        }
Esempio n. 2
0
        private static IReadOnlyCollection <IKey> RunGetAllKeysCore(string xml, IActivator activator, ILoggerFactory loggerFactory = null)
        {
            // Arrange - mocks
            var mockXmlRepository = new Mock <IXmlRepository>();

            mockXmlRepository.Setup(o => o.GetAllElements()).Returns(XElement.Parse(xml).Elements().ToArray());

            // Arrange - services
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IXmlRepository>(mockXmlRepository.Object);
            serviceCollection.AddSingleton <IActivator>(activator);
            serviceCollection.AddSingleton <IAuthenticatedEncryptorConfiguration>(new Mock <IAuthenticatedEncryptorConfiguration>().Object);
            if (loggerFactory != null)
            {
                serviceCollection.AddSingleton <ILoggerFactory>(loggerFactory);
            }
            var services   = serviceCollection.BuildServiceProvider();
            var keyManager = new XmlKeyManager(services);

            // Act
            return(keyManager.GetAllKeys());
        }
        private static IReadOnlyCollection<IKey> RunGetAllKeysCore(string xml, IActivator activator, ILoggerFactory loggerFactory = null)
        {
            // Arrange - mocks
            var mockXmlRepository = new Mock<IXmlRepository>();
            mockXmlRepository.Setup(o => o.GetAllElements()).Returns(XElement.Parse(xml).Elements().ToArray());

            // Arrange - services
            var serviceCollection = new ServiceCollection();
            serviceCollection.AddSingleton<IXmlRepository>(mockXmlRepository.Object);
            serviceCollection.AddSingleton<IActivator>(activator);
            serviceCollection.AddSingleton<IAuthenticatedEncryptorConfiguration>(new Mock<IAuthenticatedEncryptorConfiguration>().Object);
            if (loggerFactory != null)
            {
                serviceCollection.AddSingleton<ILoggerFactory>(loggerFactory);
            }
            var services = serviceCollection.BuildServiceProvider();
            var keyManager = new XmlKeyManager(services);

            // Act
            return keyManager.GetAllKeys();
        }