public void BCryptHashWhenGivenSomeStringExpectResult() { ICryptHashProvider hasher = Factory.CryptHashPump.NewInstance(workFactor: MockWorkFactor); string actual = hasher.Hash(clearText: "abc"); Assert.IsNotNull(actual); Assert.IsTrue(actual.Length > 0); }
public void BCryptHashWhenGivenAnotherStringExpectResult() { ICryptHashProvider hasher = Factory.CryptHashPump.NewInstance(workFactor: MockWorkFactor); string actual = hasher.Hash( clearText: "Ut est etiam invenire maluisset, ea porro debitis indoctum vim, ad eos error invidunt constituto. Eu velit quando fabellas sea. Sea fabellas dignissim at, lorem falli mundi sea eu. Ut eum gloriatur sadipscing, ius te expetenda omittantur" ); Assert.IsNotNull(actual); Assert.IsTrue(actual.Length > 0); }
public void BCryptHashVerifyWhenGivenSomeStringExpectResult() { const string clearText = "abc"; ICryptHashProvider hasher = Factory.CryptHashPump.NewInstance(workFactor: MockWorkFactor); string hashText = hasher.Hash(clearText: clearText); ICryptHashVerifyProvider verifier = Factory.CryptHashVerifyPump.NewInstance(); bool actual = verifier.Verify(clearText: clearText, hashText: hashText); Assert.IsNotNull(actual); Assert.IsTrue(actual); }
public void HashWhenGivenNullExpectArgumentNullException() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); ICryptHashProvider hash = Factory.MD5Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act Assert.Throws <ArgumentNullException>(() => hash.Hash(null)); // verify mockByteConverter.Verify(); }
public void HashWhenGivenSomeValueExpectHashValue() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); mockByteConverter.Setup(m => m.ConvertToBytes("abc")).Returns(new byte[] { 97, 98, 99 }).Verifiable(); ICryptHashProvider hash = Factory.MD5Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act string actual = hash.Hash("abc"); // assert Assert.IsNotNull(actual); Assert.AreEqual("900150983cd24fb0d6963f7d28e17f72", actual); // verify mockByteConverter.Verify(); }
public void HashWhenGivenEmptyValueExpectHashValue() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); mockByteConverter.Setup(m => m.ConvertToBytes(string.Empty)).Returns(new byte[0]).Verifiable(); ICryptHashProvider hash = Factory.MD5Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act string actual = hash.Hash(string.Empty); // assert Assert.IsNotNull(actual); Assert.AreEqual("d41d8cd98f00b204e9800998ecf8427e", actual); // verify mockByteConverter.Verify(); }
public void HashWhenGivenSomeValueExpectHashValue() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); mockByteConverter.Setup(m => m.ConvertToBytes("abc")).Returns(new byte[] { 97, 98, 99 }).Verifiable(); ICryptHashProvider hash = Factory.SHA512Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act string actual = hash.Hash("abc"); // assert Assert.IsNotNull(actual); Assert.AreEqual("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", actual); // verify mockByteConverter.Verify(); }
public void HashWhenGivenEmptyValueExpectHashValue() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); mockByteConverter.Setup(m => m.ConvertToBytes(string.Empty)).Returns(new byte[0]).Verifiable(); ICryptHashProvider hash = Factory.SHA512Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act string actual = hash.Hash(string.Empty); // assert Assert.IsNotNull(actual); Assert.AreEqual("cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e", actual); // verify mockByteConverter.Verify(); }
public void HashWhenGivenSomeValueExpectHashValue() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); mockByteConverter.Setup(m => m.ConvertToBytes("abc")).Returns(new byte[] { 97, 98, 99 }).Verifiable(); ICryptHashProvider hash = Factory.SHA256Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act string actual = hash.Hash("abc"); // assert Assert.IsNotNull(actual); Assert.AreEqual("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", actual); // verify mockByteConverter.Verify(); }
public void HashWhenGivenEmptyValueExpectHashValue() { // arrange var mockByteConverter = new Mock <IByteConverter>(MockBehavior.Strict); mockByteConverter.Setup(m => m.ConvertToBytes(string.Empty)).Returns(new byte[0]).Verifiable(); ICryptHashProvider hash = Factory.SHA256Pump.NewInstance( byteConverter: mockByteConverter.Object ); // act string actual = hash.Hash(string.Empty); // assert Assert.IsNotNull(actual); Assert.AreEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", actual); // verify mockByteConverter.Verify(); }
public void BCryptHashWhenGivenNullExpectArgumentNullException() { ICryptHashProvider hasher = Factory.CryptHashPump.NewInstance(workFactor: MockWorkFactor); Assert.Throws <ArgumentNullException>(() => hasher.Hash(clearText: null)); }