Пример #1
0
        public void TestValidateOkValueParameter() {
            var controller = new AjaxController();
            var mocks = new ContextMocks(controller);

            INakedObject contactRepo = FrameworkHelper.GetAdaptedService("ContactRepository");


            const string actionName = "FindContactByName";
            const string parameterName = "lastName";

            string id = FrameworkHelper.GetObjectId(contactRepo);
            const string value = "Bloggs";
            const string parmId = "ContactRepository-FindContactByName-LastName-Input";
            mocks.Request.Setup(x => x.Params).Returns(new NameValueCollection {{parmId, value}});

            JsonResult result = controller.ValidateParameter(id, null, actionName, parameterName);
            Assert.IsTrue((bool) result.Data);
        }
Пример #2
0
        public void TestValidateFailRefParameter() {
            var controller = new AjaxController();
            new ContextMocks(controller);

            Store store = NakedObjectsContext.ObjectPersistor.Instances<Store>().First();
            Vendor vendor = NakedObjectsContext.ObjectPersistor.Instances<Vendor>().First();
            const string actionName = "CreateNewOrder";
            const string parameterName = "customer";

            string id = FrameworkHelper.GetObjectId(store);
            string value = FrameworkHelper.GetObjectId(vendor);

            JsonResult result = controller.ValidateParameter(id, value, actionName, parameterName);
            Assert.AreEqual("Not a suitable type; must be a Customer", result.Data);
        }
Пример #3
0
        public void TestValidateOkRefParameter() {
            var controller = new AjaxController();
            new ContextMocks(controller);

            Store store = NakedObjectsContext.ObjectPersistor.Instances<Store>().First();
            const string actionName = "CreateNewOrder";
            const string parameterName = "customer";


            string id = FrameworkHelper.GetObjectId(store);
            string value = FrameworkHelper.GetObjectId(store);

            JsonResult result = controller.ValidateParameter(id, value, actionName, parameterName);
            Assert.IsTrue((bool) result.Data);
        }