Esempio n. 1
0
        public void CreateEncrptorInstance_UnknownDescriptorType_ReturnsNull()
        {
            // Arrange
            var key = new Mock <IKey>();

            key.Setup(k => k.Descriptor).Returns(new Mock <IAuthenticatedEncryptorDescriptor>().Object);

            var factory = new CngCbcAuthenticatedEncryptorFactory(NullLoggerFactory.Instance);

            // Act
            var encryptor = factory.CreateEncryptorInstance(key.Object);

            // Assert
            Assert.Null(encryptor);
        }
Esempio n. 2
0
        public void CreateEncrptorInstance_ExpectedDescriptorType_ReturnsEncryptor()
        {
            // Arrange
            var descriptor = new CngCbcAuthenticatedEncryptorConfiguration().CreateNewDescriptor();
            var key        = new Mock <IKey>();

            key.Setup(k => k.Descriptor).Returns(descriptor);

            var factory = new CngCbcAuthenticatedEncryptorFactory(NullLoggerFactory.Instance);

            // Act
            var encryptor = factory.CreateEncryptorInstance(key.Object);

            // Assert
            Assert.NotNull(encryptor);
            Assert.IsType <CbcAuthenticatedEncryptor>(encryptor);
        }