コード例 #1
0
            public void AMicroLiteExceptionShouldBeThrown()
            {
                var typeConverter = new DbEncryptedStringTypeConverter(
                    new Mock<ISymmetricAlgorithmProvider>().Object);

                var exception = Assert.Throws<MicroLiteException>(
                    () => typeConverter.ConvertFromDbValue("foo", typeof(DbEncryptedString)));

                Assert.Equal(ExceptionMessages.DbEncryptedStringTypeConverter_CipherTextInvalid, exception.Message);
            }
コード例 #2
0
            public void AnArgumentNullExceptionShouldBeThrown()
            {
                var typeConverter = new DbEncryptedStringTypeConverter(
                    new Mock<ISymmetricAlgorithmProvider>().Object);

                var exception = Assert.Throws<ArgumentNullException>(
                    () => typeConverter.ConvertFromDbValue("foo", null));

                Assert.Equal("type", exception.ParamName);
            }
コード例 #3
0
            public WhenCallingConvertFromDbValue_WithDbNull()
            {
                var typeConverter = new DbEncryptedStringTypeConverter(new Mock<ISymmetricAlgorithmProvider>().Object);

                this.result = (DbEncryptedString)typeConverter.ConvertFromDbValue(DBNull.Value, typeof(DbEncryptedString));
            }
コード例 #4
0
            public WhenCallingConvertFromDbValueWithReader_WithDbNull()
            {
                var typeConverter = new DbEncryptedStringTypeConverter(new Mock<ISymmetricAlgorithmProvider>().Object);

                this.mockReader.Setup(x => x.IsDBNull(0)).Returns(true);
                this.result = (DbEncryptedString)typeConverter.ConvertFromDbValue(this.mockReader.Object, 0, typeof(DbEncryptedString));
            }
コード例 #5
0
            public void AMicroLiteExceptionShouldBeThrown()
            {
                var typeConverter = new DbEncryptedStringTypeConverter(
                    new Mock<ISymmetricAlgorithmProvider>().Object);

                var mockReader = new Mock<IDataReader>();
                mockReader.Setup(x => x.IsDBNull(0)).Returns(false);
                mockReader.Setup(x => x.GetString(0)).Returns("foo");

                var exception = Assert.Throws<MicroLiteException>(
                    () => typeConverter.ConvertFromDbValue(mockReader.Object, 0, typeof(DbEncryptedString)));

                Assert.Equal(ExceptionMessages.DbEncryptedStringTypeConverter_CipherTextInvalid, exception.Message);
            }