public void GetPNDPasswords_ContainsResponse_ContainPassword() { // Arrange HaveIBeenPwndRangeResponse response = HaveIBeenPwndRangeResponseStubs.SampleResponse; string prefix = "36DEB"; // Act IEnumerable <PNDPassword> passwords = response.GetPNDPasswords(prefix); // Assert Assert.IsTrue(passwords.All(password => !string.IsNullOrEmpty(password.SHA1Password))); }
public void GetPNDPasswords_ContainsResponse_ContainCount() { // Arrange HaveIBeenPwndRangeResponse response = HaveIBeenPwndRangeResponseStubs.SampleResponse; string prefix = "36DEB"; // Act IEnumerable <PNDPassword> passwords = response.GetPNDPasswords(prefix); // Assert Assert.IsTrue(passwords.All(password => password.PNDCount != null)); }
public void GetPNDPasswords_EmptyResponse_ReturnsEmptyArray() { // Arrange HaveIBeenPwndRangeResponse response = HaveIBeenPwndRangeResponseStubs.EmptyResponse; string prefix = "36DEB"; // Act IEnumerable <PNDPassword> passwords = response.GetPNDPasswords(prefix); // Assert Assert.IsFalse(passwords.Any()); }
public void GetPNDPasswords_ContainsResponse_ReturnsPNDPasswords() { // Arrange HaveIBeenPwndRangeResponse response = HaveIBeenPwndRangeResponseStubs.SampleResponse; string prefix = "36DEB"; // Act IEnumerable <PNDPassword> passwords = response.GetPNDPasswords(prefix); // Assert Assert.IsTrue(passwords.Any()); }
public static IEnumerable <PNDPassword> GetPNDPasswords( this HaveIBeenPwndRangeResponse response, string prefix) { if (response == null || string.IsNullOrEmpty(response.Content)) { return(new PNDPassword[0]); } return(response .Content .Split("\r\n") .Select(prefexCountEntry => prefexCountEntry.Split(':')) .Select(prefixCount => new PNDPassword(prefix, prefixCount[0], int.Parse(prefixCount[1])))); }