using NUnit.Framework;
using WatiN.Core;

namespace adMoto.Payments.Test.Web.UI
{
    [TestFixture]
    public class ValidationTests
    {
        [Test]
        [Category("UI")]
        public void Validates_When_Firstname_Is_Too_Long()
        {
            const string test = "test";
            var ie = new IE("http://localhost:3646/pl/Account/LogOn");
            ie.TextField(Find.ByName("numerFaktury")).TypeText("1/SLJ/2009");
            ie.TextField(Find.ByName("nip")).TypeText("9730727417");
            ie.Button(Find.ById("loguj")).Click();

            ie.TextField(Find.ByName("Payer.FirstName")).TypeText("12345678901234567890123456");
            ie.TextField(Find.ByName("Payer.LastName")).TypeText(test);
            ie.Button(Find.ById("place")).Click();
            Assert.IsTrue(ie.ContainsText("Zbyt długa nazwa"));
            ie.ForceClose();
            ie.Close();
            ie.Dispose();
        }

        [Test]
        [Category("UI")]
        public void Validates_When_Surname_Is_Too_Long()
        {
            const string test = "test";
            var ie = new IE("http://localhost:3646/pl/Account/LogOn");
            ie.TextField(Find.ByName("numerFaktury")).TypeText("1/SLJ/2009");
            ie.TextField(Find.ByName("nip")).TypeText("9730727417");
            ie.Button(Find.ById("loguj")).Click();

            ie.TextField(Find.ByName("Payer.FirstName")).TypeText(test);
            ie.TextField(Find.ByName("Payer.LastName")).TypeText("1234567890123456789012345678901");
            ie.Button(Find.ById("place")).Click();
            Assert.IsTrue(ie.ContainsText("Zbyt długa nazwa"));
            ie.ForceClose();
            ie.Close();
            ie.Dispose();
        }

        [Test]
        [Category("UI")]
        public void Validates_When_LastName_Is_Empty()
        {
            const string test = "test";
            var ie = new IE("http://localhost:3646/pl/Account/LogOn");
            ie.TextField(Find.ByName("numerFaktury")).TypeText("27/ASZ/2009");
            ie.TextField(Find.ByName("nip")).TypeText("854956281");
            ie.Button(Find.ById("loguj")).Click();

            ie.TextField(Find.ByName("Payer.FirstName")).TypeText(test);
            ie.TextField(Find.ByName("Payer.LastName")).TypeText("");
            ie.Button(Find.ById("place")).Click();
            Assert.IsTrue(ie.ContainsText("Proszę podać"));
            ie.ForceClose();
            ie.Close();
            ie.Dispose();
        }
    }
}