using Knoks.Framework.Security;
using Xunit;

namespace Knoks.Tests.Unit.Framework.Security
{
    public class PasswordStrengthTest
    {
        static IPasswordStrength PasswordStrength;
        static PasswordStrengthTest()
        {
            PasswordStrength = new PasswordStrength();
        }

        [Fact]
        async void CheckStrengthReturnsEmptyForBlankPassword()
        {
            Assert.Equal(PasswordScore.Blank, await PasswordStrength.CheckStrength(""));
        }

        [Fact]
        async void CheckStrengthReturnsVeryWeakForPasswordOfHello()
        {
            Assert.Equal(PasswordScore.VeryWeak, await PasswordStrength.CheckStrength("Hello"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfHello2()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("Hello2"));
        }

        [Fact]
        async void CheckStrengthReturnsMediumForPasswordOfHelloWorld()
        {
            Assert.Equal(PasswordScore.Medium, await PasswordStrength.CheckStrength("HelloWorld"));
        }

        [Fact]
        async void CheckStrengthReturnsStrongForPasswordOfHelloWorld69()
        {
            Assert.Equal(PasswordScore.Strong, await PasswordStrength.CheckStrength("HelloWorld69"));
        }

        [Fact]
        async void CheckStrengthReturnsVeryStrongForPasswordOfHelloWorld69WithExclaimationMark()
        {
            Assert.Equal(PasswordScore.VeryStrong, await PasswordStrength.CheckStrength("HelloWorld69!"));
        }

        [Fact]
        async void CheckStrengthReturnsStrongForPasswordOf1234HelloWorld69()
        {
            Assert.Equal(PasswordScore.Strong, await PasswordStrength.CheckStrength("1234HelloWorld69"));
        }

        [Fact]
        async void CheckStrengthReturnsVeryStrongForPasswordOf1234HelloWorld69WithExclaimationMark()
        {
            Assert.Equal(PasswordScore.VeryStrong, await PasswordStrength.CheckStrength("!1234HelloWorld69"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfPasswordOnTheWeakPasswordList()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("password"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfTrustNoOne1OnTheWeakPasswordList()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("trustno1"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfTRUSTNO1OnTheWeakPasswordList()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("TRUSTNO1"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfP455w9rdOnTheWeakPasswordList()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("p455w0rd"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfTrustN01TheWeakPasswordList()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("trustn01"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfW3lc0m3TheWeakPasswordList()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("w3lc0m3"));
        }

        [Fact]
        async void CheckStrengthReturnsWeakForPasswordOfPasswordOnTheWeakPasswordListIncludingNonCharacters()
        {
            Assert.Equal(PasswordScore.Weak, await PasswordStrength.CheckStrength("p@$$w0rd"));
        }
    }
}
