using NUnit.Framework;
using WatiN.Core;

namespace Platnosci.Tests.Web.UI
{
    [TestFixture]
    public class MerchantTests
    {
        [Test]
        [Category("UI")]
        public void Redirects_To_Ecard_When_All_Details_Are_Correct()
        {
            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(test);
            ie.Button(Find.ById("place")).Click();
            Assert.IsTrue(ie.ContainsText("Imię i nazwisko:" + test + " " + test));
            Assert.IsTrue(ie.Url.Contains("https://pay.ecard.pl/"));
            ie.ForceClose();
            ie.Close();
            ie.Dispose();
        }

        [Test]
        [Category("UI")]
        public void Returns_ZlyHash_When_Invoice_Amount_Is_Zero()
        {
            // wartosc faktury 1/SLJ/2009 jest 0 (zero)
            // wowczas eCard powinien zwrocic zlyHash - stala informujaca, ze cos jest nie tak...

            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(test);
            ie.Button(Find.ById("place")).Click();
            Assert.IsTrue(ie.ContainsText("Wystąpił nieoczekiwany błąd"));
            ie.ForceClose();
            ie.Close();
            ie.Dispose();
        }
    }
}