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); }
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); }
public WhenCallingConvertFromDbValue_WithDbNull() { var typeConverter = new DbEncryptedStringTypeConverter(new Mock<ISymmetricAlgorithmProvider>().Object); this.result = (DbEncryptedString)typeConverter.ConvertFromDbValue(DBNull.Value, typeof(DbEncryptedString)); }
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)); }
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); }