Beispiel #1
0
        public void CorrectOrder_30()
        {
            var handler = new TestablePrzelewy24Handler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("p24_id_sprzedawcy", handler.MyId);
            requestData.Add("p24_order_id", "191015");
            requestData.Add("p24_order_id_full", "18191015");
            requestData.Add("p24_kwota", "600");
            requestData.Add("p24_session_id", Guid.NewGuid() + "|" + profile.GlobalId.ToString() + "|BAPoints_30");
            requestData.Add("p24_crc", "fghgfhfrtyryr");
            requestData.Add("p24_karta", "0");


            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                handler.ProcessOrderRequest(serviceSession, requestData, null);
            }
            Session.Clear();
            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["p24_order_id"], baPoints.Identifier);
            Assert.AreEqual(BAPointsType.Przelewy24, baPoints.Type);
        }
Beispiel #2
0
        public void DuplicatedOrder()
        {
            BAPoints point = new BAPoints();

            point.Identifier   = "191015";
            point.Profile      = profile;
            point.ImportedDate = DateTime.UtcNow;
            insertToDatabase(point);

            var handler = new TestablePrzelewy24Handler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("p24_id_sprzedawcy", handler.MyId);
            requestData.Add("p24_order_id", "191015");
            requestData.Add("p24_order_id_full", "18191015");
            requestData.Add("p24_kwota", "500");
            requestData.Add("p24_session_id", Guid.NewGuid() + "|" + profile.GlobalId.ToString() + "|BAPoints_120");
            requestData.Add("p24_crc", "fghgfhfrtyryr");
            requestData.Add("p24_karta", "0");
            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);
        }
Beispiel #3
0
        public void InvalidSessionId()
        {
            var handler = new TestablePrzelewy24Handler(manager);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("p24_id_sprzedawcy", handler.MyId);
            requestData.Add("p24_order_id", "191015");
            requestData.Add("p24_order_id_full", "18191015");
            requestData.Add("p24_kwota", "9000");
            requestData.Add("p24_session_id", Guid.NewGuid() + "|" + profile.GlobalId.ToString());
            requestData.Add("p24_crc", "fghgfhfrtyryr");
            requestData.Add("p24_karta", "0");


            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                try
                {
                    handler.ProcessOrderRequest(serviceSession, requestData, null);
                    Assert.Fail();
                }
                catch (IndexOutOfRangeException)
                {
                }
            }
            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);
        }