Example #1
0
 private void NewMethod()
 {
     ShippingMethod m = new ShippingMethod();
     m.ShippingProviderId = this.lstProviders.SelectedValue;
     m.Name = "New Shipping Method";
     if (MTApp.OrderServices.ShippingMethods.Create(m) == true)
     {
         Response.Redirect("Shipping_EditMethod.aspx?id=" + m.Bvin + "&doc=1");
     }
 }
        protected override void OnInit(System.EventArgs e)
        {
            base.OnInit(e);

            if (Request.QueryString["id"] != null)
            {
                this.BlockIDField.Value = Request.QueryString["id"];
            }
            m = MTApp.OrderServices.ShippingMethods.Find(this.BlockIDField.Value);
            LoadEditor();
        }
        public void CanCreateShippingMethod()
        {
            RequestContext c = new RequestContext();
            MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);
            c.CurrentStore = new Accounts.Store();
            c.CurrentStore.Id = 230;

            Shipping.ShippingMethod target = new Shipping.ShippingMethod();
            target.Adjustment = 1.23m;
            target.AdjustmentType = Shipping.ShippingMethodAdjustmentType.Percentage;
            target.Bvin = string.Empty;
            //target.CustomProperties.Add("bvsoftware", "mykey", "myvalue");
            target.Name = "Test Name";
            target.Settings.AddOrUpdate("MySetting", "MySetVal");
            target.ShippingProviderId = "123456";
            target.ZoneId = -101;

            Assert.IsTrue(app.OrderServices.ShippingMethods.Create(target));
            Assert.AreNotEqual(string.Empty, target.Bvin, "Bvin should not be empty");
        }
        public void CanRetrieveShippingMethod()
        {
            RequestContext c = new RequestContext();
            MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);
            c.CurrentStore = new Accounts.Store();
            c.CurrentStore.Id = 230;

            Shipping.ShippingMethod target = new Shipping.ShippingMethod();
            target.Adjustment = 1.23m;
            target.AdjustmentType = Shipping.ShippingMethodAdjustmentType.Percentage;
            target.Bvin = string.Empty;
            //target.CustomProperties.Add("bvsoftware", "mykey", "myvalue");
            target.Name = "Test Name";
            target.Settings.AddOrUpdate("MySetting", "MySetVal");
            target.ShippingProviderId = "123456";
            target.ZoneId = -101;

            app.OrderServices.ShippingMethods.Create(target);
            Assert.AreNotEqual(string.Empty, target.Bvin, "Bvin should not be empty");

            Shipping.ShippingMethod actual = app.OrderServices.ShippingMethods.Find(target.Bvin);
            Assert.IsNotNull(actual, "Actual should not be null");

            Assert.AreEqual(actual.Adjustment,target.Adjustment);
            Assert.AreEqual(actual.AdjustmentType,target.AdjustmentType);
            Assert.AreEqual(actual.Bvin,target.Bvin);
            //Assert.AreEqual(actual.CustomProperties[0].Key, target.CustomProperties[0].Key);
            Assert.AreEqual(actual.Name,target.Name);
            Assert.AreEqual(actual.Settings["MySetting"], target.Settings["MySetting"]);
            Assert.AreEqual(actual.ShippingProviderId,target.ShippingProviderId);
            Assert.AreEqual(actual.ZoneId,target.ZoneId);

        }