public void GetFormData_NullRequest()
        {
            var handler = new FormControllerRequestHandler(new DictionaryCache <long, EntityData>());

            Assert.That(() => handler.GetFormData(null),
                        Throws.TypeOf <ArgumentNullException>().And.Property("ParamName").EqualTo("request"));
        }
        public void GetFormData_InvalidEntityRequest()
        {
            var handler = new FormControllerRequestHandler(new DictionaryCache <long, EntityData>());

            var request = new FormDataRequest
            {
                EntityId = "-100",
                Query    = "name, description"
            };

            var response = handler.GetFormData(request);

            Assert.IsNull(response);
        }
        public void GetFormData_NoVisCalculation()
        {
            // Create a form with the name and description controls depending on each other
            var testState = CreateTestEntities(null, null, "name", "description");

            var handler = new FormControllerRequestHandler(new DictionaryCache <long, EntityData>());

            var request = new FormDataRequest
            {
                FormId   = testState.EditForm.Id.ToString(),
                EntityId = testState.Instance.Id.ToString(),
                Query    = "name, description"
            };

            var response = handler.GetFormData(request);

            Assert.IsNull(response.InitiallyHiddenControls);
            Assert.IsTrue(response.FormDataEntity.Entities.ContainsKey(testState.Instance.Id));
        }
        public void GetFormData_NonBoolVisCalculation()
        {
            var testState = CreateTestEntities("[Description]", null, "name", "description");

            var handler = new FormControllerRequestHandler(new DictionaryCache <long, EntityData>());

            var request = new FormDataRequest
            {
                FormId   = testState.EditForm.Id.ToString(),
                EntityId = testState.Instance.Id.ToString(),
                Query    = "name, description"
            };

            var response = handler.GetFormData(request);

            Assert.AreEqual(1, response.InitiallyHiddenControls.Count);
            Assert.IsTrue(response.InitiallyHiddenControls.Contains(testState.NameControl.Id));
            Assert.IsTrue(response.FormDataEntity.Entities.ContainsKey(testState.Instance.Id));
        }