public void WrongRequestIp()
        {
            var handler = new TestableTranferujHandler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("id", handler.TransferujId);
            requestData.Add("tr_id", "TR-USR-11APEX");
            requestData.Add("tr_date", "2012-08-21+19%3a37%3a50");
            requestData.Add("tr_crc", profile.GlobalId.ToString() + "|BAPoints_30");
            requestData.Add("tr_amount", "5.00");
            requestData.Add("tr_paid", "5.00");
            requestData.Add("tr_desc", "BAPoints_30");
            requestData.Add("tr_status", "TRUE");
            requestData.Add("tr_error", "none");
            requestData.Add("tr_email", "*****@*****.**");
            var md5 = FormsAuthentication.HashPasswordForStoringInConfigFile(handler.TransferujId + requestData["tr_id"] + requestData["tr_amount"] + requestData["tr_crc"] + handler.TransferujKodPotwierdzajcy, "MD5");

            requestData.Add("md5sum", md5);

            handler.RequestIp = "200.149.229.119";
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                try
                {
                    handler.ProcessOrderRequest(serviceSession, requestData, null);
                    Assert.Fail();
                }
                catch (ValidationException)
                {
                }
            }
            Assert.IsFalse(handler.SendConfirmationInvoked);
            Session.Clear();
            var dbProfile = Session.Get <Profile>(profile.GlobalId);

            Assert.AreEqual(0, dbProfile.Licence.BAPoints);
            Assert.AreEqual(DateTime.MinValue, dbProfile.Licence.LastPointOperationDate);

            var baPoints = Session.QueryOver <BAPoints>().RowCount();

            Assert.AreEqual(0, baPoints);
        }
        public void DuplicatedOrder()
        {
            BAPoints point = new BAPoints();

            point.Identifier   = "TR-USR-11APEX";
            point.Profile      = profile;
            point.ImportedDate = DateTime.UtcNow;
            insertToDatabase(point);

            var handler = new TestableTranferujHandler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("id", handler.TransferujId);
            requestData.Add("tr_id", "TR-USR-11APEX");
            requestData.Add("tr_date", "2012-08-21+19%3a37%3a50");
            requestData.Add("tr_crc", profile.GlobalId.ToString() + "|BAPoints_30");
            requestData.Add("tr_amount", "5.00");
            requestData.Add("tr_paid", "5.00");
            requestData.Add("tr_desc", "BAPoints_30");
            requestData.Add("tr_status", "TRUE");
            requestData.Add("tr_error", "none");
            requestData.Add("tr_email", "*****@*****.**");
            var md5 = FormsAuthentication.HashPasswordForStoringInConfigFile(handler.TransferujId + requestData["tr_id"] + requestData["tr_amount"] + requestData["tr_crc"] + handler.TransferujKodPotwierdzajcy, "MD5");

            requestData.Add("md5sum", md5);
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                try
                {
                    handler.ProcessOrderRequest(serviceSession, requestData, null);
                    Assert.Fail();
                }
                catch (UniqueException)
                {
                }
            }
            Session.Clear();
            var baPoints = Session.QueryOver <BAPoints>().RowCount();

            Assert.AreEqual(1, baPoints);
        }
        public void MD5Incorrect()
        {
            var handler = new TestableTranferujHandler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("id", handler.TransferujId);
            requestData.Add("tr_id", "TR-USR-11APEX");
            requestData.Add("tr_date", "2012-08-21+19%3a37%3a50");
            requestData.Add("tr_crc", profile.GlobalId.ToString() + "|BAPoints_30");
            requestData.Add("tr_amount", "5.00");
            requestData.Add("tr_paid", "5.00");
            requestData.Add("tr_desc", "BAPoints_30");
            requestData.Add("tr_status", "TRUE");
            requestData.Add("tr_error", "surcharge");
            requestData.Add("tr_email", "*****@*****.**");
            requestData.Add("md5sum", "fdgfdgdfgdfgfdgf");

            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                try
                {
                    handler.ProcessOrderRequest(serviceSession, requestData, null);
                    Assert.Fail();
                }
                catch (ValidationException)
                {
                }
            }
            Assert.IsFalse(handler.SendConfirmationInvoked);
            Session.Clear();
            var dbProfile = Session.Get <Profile>(profile.GlobalId);

            Assert.AreEqual(0, dbProfile.Licence.BAPoints);
            Assert.AreEqual(DateTime.MinValue, dbProfile.Licence.LastPointOperationDate);

            var baPoints = Session.QueryOver <BAPoints>().RowCount();

            Assert.AreEqual(0, baPoints);
        }
        public void CorrectOrder_BAPoints_30()
        {
            var handler = new TestableTranferujHandler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("id", handler.TransferujId);
            requestData.Add("tr_id", "TR-USR-11APEX");
            requestData.Add("tr_date", "2012-08-21+19%3a37%3a50");
            requestData.Add("tr_crc", profile.GlobalId.ToString() + "|BAPoints_30");
            requestData.Add("tr_amount", "5.00");
            requestData.Add("tr_paid", "5.00");
            requestData.Add("tr_desc", "BAPoints_30");
            requestData.Add("tr_status", "TRUE");
            requestData.Add("tr_error", "none");
            requestData.Add("tr_email", "*****@*****.**");
            var md5 = FormsAuthentication.HashPasswordForStoringInConfigFile(handler.TransferujId + requestData["tr_id"] + requestData["tr_amount"] + requestData["tr_crc"] + handler.TransferujKodPotwierdzajcy, "MD5");

            requestData.Add("md5sum", md5);

            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                handler.ProcessOrderRequest(serviceSession, requestData, null);
            }
            Session.Clear();
            Assert.IsTrue(handler.SendConfirmationInvoked);
            var dbProfile = Session.Get <Profile>(profile.GlobalId);

            Assert.AreEqual(30, dbProfile.Licence.BAPoints);
            Assert.AreEqual(DateTime.MinValue, dbProfile.Licence.LastPointOperationDate);

            var baPoints = Session.QueryOver <BAPoints>().SingleOrDefault();

            Assert.AreEqual(30, baPoints.Points);
            Assert.AreEqual(dbProfile.GlobalId, baPoints.Profile.GlobalId);
            Assert.AreEqual(requestData["tr_id"], baPoints.Identifier);
            Assert.AreEqual(BAPointsType.Transferuj, baPoints.Type);
        }