public void CryptWhenGivenLotionClearTextValueExpectResult()
        {
            var mockBase64Converter = new Mock <IBase64Converter>(MockBehavior.Strict);

            mockBase64Converter.Setup(m => m.ToBase64String(It.IsAny <IReadOnlyCollection <byte> >())).Returns((IReadOnlyCollection <byte> input) =>
            {
                return(Convert.ToBase64String(input.ToArray()));
            }).Verifiable();

            var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict);

            mockByteConverter.Setup(m => m.ConvertToBytes(It.IsAny <string>())).Returns((string input) =>
            {
                return(UTF8Encoding.UTF8.GetBytes(input));
            }).Verifiable();

            ICryptProvider crypt = Factory.AES256PlusHMACPump.NewInstance(
                base64Converter: mockBase64Converter.Object,
                byteConverter: mockByteConverter.Object,
                cryptKeyValue: MockCryptKeyValue,
                hmacSaltValue: MockHmacSaltValue
                ) as ICryptProvider;

            string actual = crypt.Crypt(clearText: MockLotionClearTextValue);

            Assert.IsNotNull(actual);

            mockByteConverter.Verify();
            mockBase64Converter.Verify();
        }
        public void CryptWhenGivenNullExpectArgumentNullException()
        {
            //  arrange
            ICryptProvider crypt = Factory.EchoPump.NewInstance() as ICryptProvider;

            //  act
            Assert.Throws <ArgumentNullException>(() => crypt.Crypt(null));
        }
        public void CryptWhenGivenNullClearTextExpectArgumentNullException()
        {
            ICryptProvider crypt = Factory.AES256PlusHMACPump.NewInstance(
                base64Converter: new Mock <IBase64Converter>(MockBehavior.Strict).Object,
                byteConverter: new Mock <IByteConverter>(MockBehavior.Strict).Object,
                cryptKeyValue: MockCryptKeyValue,
                hmacSaltValue: MockHmacSaltValue
                ) as ICryptProvider;

            Assert.Throws <ArgumentNullException>(() => crypt.Crypt(clearText: null));
        }
        public void CryptWhenGivenSomeValueExpectSomeValue()
        {
            //  arrange
            ICryptProvider crypt = Factory.EchoPump.NewInstance() as ICryptProvider;

            //  act
            string actual = crypt.Crypt("echo");

            //  assert
            Assert.IsNotNull(actual);
            Assert.AreEqual("echo", actual);
        }
        public void CryptWhenGivenEmptyClearTextExpectArgumentException()
        {
            var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict);

            mockByteConverter.Setup(m => m.ConvertToBytes(It.IsAny <string>())).Returns((string input) =>
            {
                return(UTF8Encoding.UTF8.GetBytes(input));
            }).Verifiable();

            ICryptProvider crypt = Factory.AES256PlusHMACPump.NewInstance(
                base64Converter: new Mock <IBase64Converter>(MockBehavior.Strict).Object,
                byteConverter: mockByteConverter.Object,
                cryptKeyValue: MockCryptKeyValue,
                hmacSaltValue: MockHmacSaltValue
                ) as ICryptProvider;

            Assert.Throws <ArgumentException>(() => crypt.Crypt(clearText: string.Empty));
        }