using Knoks.Framework.Cryptography;
using System;
using Xunit;

namespace Knoks.Tests.Unit.Framework.Cryptography
{
    public class PasswordResultTest
    {
        const string _password1 = "V1|0NiGdCEEdT/BzfXlbC4P9W8OOO+z632XsYoLPVlzT9w=|ms6V+xCA6ctNhGpFyWJvUQ==";
        const string _password2 = "V1|gylm3E0WUhXaSmBkPbKDG6585kcf8iH+Hd5o+Su7Nog=|d3CZd4ab6Hxaatu09YSDBg==";

        [Theory(DisplayName = "IsIdentical: ValidParams  => Equal")]
        [InlineData(_password1, _password1, true)]
        [InlineData(_password1, _password2, false)]
        void IsIdentical_ValidParams(string flatString1, string flatString2, bool result)
        {
            var res1 = new PasswordResult(flatString1);
            var res2 = new PasswordResult(flatString2);

            Assert.Equal(result, res1.IsIdentical(res2));
        }

        [Theory(DisplayName = "ToFlatString: ValidFlatString  => Equal")]
        [InlineData(_password1)]
        [InlineData(_password2)]
        void ToFlatString_ValidFlatString_Equal(string flatString)
        {
            var res = new PasswordResult(flatString);
            Assert.Equal(flatString, res.ToFlatString());
        }

        [Theory(DisplayName = "Constructor: ValidParams  => Equal")]
        [InlineData(null)]
        [InlineData("abra-kadabra")]
        [InlineData("1|2|3")]
        void Constructor_InvalidFlatString_InvalidOperationExceptionThrown(string flatString)
        {
            Assert.Throws<InvalidOperationException>(() => new PasswordResult(flatString));
        }
    }
}
