Esempio n. 1
0
        //发镖扣分测试 & 取镖扣分测试 & 撤镖回分测试
        public void BiaoTest3 ()
        {
            Login(XiakeNames.MZ_NAME);
            var creSet = new ConfigSettings.CreditsPolicySettings();
            creSet.GiftForZhanggui = 80;
            creSet.GifrForBiaoju = 7;
            creSet.SpendForTakeBiao = 4;

            creSet.CreditsSpendDatas.Add(new ConfigSettings.CreditsPolicySettings.CreditsSpendData()
            {
                Bangpai = BangpaiType.Taobao,
                Begin=0,
                End = 1000,
                Spend=3
            });
            creSet.CreditsSpendDatas.Add(new ConfigSettings.CreditsPolicySettings.CreditsSpendData()
            {
                Bangpai = BangpaiType.Taobao,
                Begin = 1000,
                End = 2000,
                Spend = 5
            });
            SystemService.UpdateCreditsSettings( creSet );


            var d = LoginService.XiakeJoin(XiakeNames.ZG_NAME, "ok1234", "111111", "*****@*****.**", "111111", XiakeType.Zhanggui,"");
            Login(XiakeNames.ZG_NAME);
            var d5 = DianpuService.AddDianpu(BangpaiType.Taobao, "http://1234.taobao.com", "匹克");
            var steps = "刷单@2=1;1=2;3=3"; 
            var biaoID = BiaoService.PublishBiao(d5, "abc", 1000 , 5, "hello", 5, "sku", "hahaha", true, true,false, DateTime.Now,
                false, 38, 35, 333, steps, AllowXiakeType.Both, 0, false);
            var d6 = LoginService.Login(XiakeNames.ZG_NAME, "ok1234", "sadfas");
            Assert.AreEqual(d6.Credits, 80 - 5* 5);

            var newbiao  = BiaoService.PublishBiao(d5, "abc", 800, 5, "hello", 5, "sku", "hahaha", true, true,false, DateTime.Now,
                false, 38, 35, 333, steps, AllowXiakeType.Both, 0, false);
            var d7 =  LoginService.Login(XiakeNames.ZG_NAME, "ok1234", "sadfas");
            Assert.AreEqual( 80 - 5 * 5 - 3*5 , d7.Credits);
            using (var db = DbContextFactory.CreateDbContext())
            {
                var biao = db.Biaos.FirstOrDefault(a => a.Id == newbiao);
                Assert.AreEqual(biao.SpendCredits, 5 * 3);
               
            }

            try
            {
                BiaoService.PublishBiao(d5, "abc", 100, 50, "hello", 5, "sku", "hahaha", true, true,false, DateTime.Now,
               false, 38, 35, 333, steps, AllowXiakeType.Both, 0, false);
                Assert.Fail("积分不足也可以发镖");

            } catch(AssertFailedException)
            {
                throw;
            }
            catch(FaultException)
            {  
            }
            

            //--取镖测试 
            var d8 = LoginService.XiakeJoin(XiakeNames.BJ_NAME, "ok1234", "1113111", "*****@*****.**", "1113111", XiakeType.Biaoju,"");
            Login(XiakeNames.BJ_NAME);
            var d9 = BiaoshiService.AddBiaoshiByBiaoju(BangpaiType.Taobao, "hai");
            RenwuService.MakeRenwuWithBiao(biaoID, d9);
            var d10 = LoginService.Login(XiakeNames.BJ_NAME, "ok1234", "asdfas");
            Assert.AreEqual(creSet.GifrForBiaoju - creSet.SpendForTakeBiao, d10.Credits);
            try
            {
                RenwuService.MakeRenwuWithBiao(biaoID, d9);
                Assert.Fail("没钱了也可以取镖啊。");
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (FaultException)
            {
            }
            //撤镖回分测试
            Login(XiakeNames.ZG_NAME);
            BiaoService.CancelBiao(biaoID);
            var ldata = LoginService.Login(XiakeNames.ZG_NAME, "ok1234", "sdsdf");
            Assert.AreEqual(ldata.Credits, 60);

        }
Esempio n. 2
0
        public void ValidationTest1 ()
        {

            Login(XiakeNames.MZ_NAME);
            var creSet = new ConfigSettings.CreditsPolicySettings();
            creSet.GiftForZhanggui = 80;
            creSet.GifrForBiaoju = 7;
            creSet.SpendForTakeBiao = 4;

            creSet.CreditsSpendDatas.Add(new ConfigSettings.CreditsPolicySettings.CreditsSpendData()
            {
                Bangpai = BangpaiType.Taobao,
                Begin = 0,
                End = 1000,
                Spend = 3
            });
            creSet.CreditsSpendDatas.Add(new ConfigSettings.CreditsPolicySettings.CreditsSpendData()
            {
                Bangpai = BangpaiType.Taobao,
                Begin = 1000,
                End = 2000,
                Spend = 5
            });

            SystemService.UpdateCreditsSettings(creSet);

            var d = LoginService.XiakeJoin(XiakeNames.ZG_NAME, "ok1234", "111111", "*****@*****.**", "22222222", XiakeType.Zhanggui,"");
            Login(XiakeNames.ZG_NAME);
            var d5 = DianpuService.AddDianpu(BangpaiType.Taobao, "http://1234.taobao.com", "匹克");
            var steps = "刷单@2=1;1=2;3=3";
            var bid = BiaoService.PublishBiao(d5, "abc", 32, 3, "hello", 5, "sku", "hahaha", true, true,false, DateTime.Now, true, 38, 35, 333, steps, AllowXiakeType.Both, 0, false);

            var bjId = LoginService.XiakeJoin(XiakeNames.BJ_NAME, "ok1234", "9999", "*****@*****.**", "342342", XiakeType.Biaoju,"");
            Login(XiakeNames.BJ_NAME);
            var biaoshiId =  BiaoshiService.AddBiaoshiByBiaoju(BangpaiType.Taobao, "hai");
            ValidationService.MakeValidationByBiaoju(bid,biaoshiId,"hahaha");

            var rv = LoginService.Login(XiakeNames.BJ_NAME, "ok1234", "sfsdf");
            Assert.AreEqual(rv.Credits,3);

            Login(XiakeNames.ZG_NAME);
            var d6 = ValidationService.GetValidationsByZhanggui();
            Assert.AreEqual(d6.Length, 1);
            Assert.AreEqual(d6[0].BiaoID, bid);
            Assert.AreEqual(d6[0].BiaoTitle, "hello");
            Assert.AreEqual(d6[0].Biaoshi, "hai");
            Assert.AreEqual(d6[0].Details, "hahaha");
            Assert.AreEqual(d6[0].QQ, "9999");
            Assert.AreEqual(d6[0].Tel, "342342");

            Login(XiakeNames.BJ_NAME);
            try
            {
                ValidationService.DoAllow(new long[] { d6[0].Id });
                Assert.Fail("非掌柜不可核准");
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (FaultException)
            {

            }

            try
            {
                ValidationService.Reject(  d6[0].Id );
                Assert.Fail("非掌柜不可拒绝");
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (FaultException)
            {

            }


            LoginService.XiakeJoin("zg222", "ok1234", "9992229", "*****@*****.**", "342333342", XiakeType.Zhanggui,"");
            Login("zg222");

            try
            {
                ValidationService.DoAllow(new long[] { d6[0].Id });
                Assert.Fail("别人的标不可以核准");
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (FaultException)
            {

            }

            try
            {
                ValidationService.Reject(  d6[0].Id  );
                Assert.Fail("别人的标不可以拒绝");
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (FaultException)
            {

            }

            Login(XiakeNames.ZG_NAME);
            ValidationService.Reject( d6[0].Id );
            using(var db = DbContextFactory.CreateDbContext())
            {
                var biao = db.Biaos.FirstOrDefault(a => a.Id == bid);
                Assert.AreEqual(biao.Validing , 0);
                var count = db.Validations.Count();
                Assert.AreEqual(count, 0);
            }

            var rv2 = LoginService.Login(XiakeNames.BJ_NAME, "ok1234", "sdfsd");
            Assert.AreEqual(7,rv2.Credits);


        }