public void GetFormDataFragmentInvalidJsonThrowsUnsupportedOperationExceptionTest()
        {
            var          serilializedService = new JsonSerializationService();
            var          dataFragmentService = new DataFragmentJsonService(serilializedService);
            const string serializedObject    = "<xml>Not Json</xml>";

            dataFragmentService.GetFragment(serializedObject, "Addresses", new KeyValuePair <string, string>());
        }
        public void GetFormDataFragmentThrowsNotFoundExceptionTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject    = serilializedService.SerializeFormData(testClass);

            dataFragmentService.GetFragment(serializedObject, "InvalidFragmentName", new KeyValuePair <string, string>());
        }
        public void GetFormDataFragmentReturnsReturnsSerializedStringTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);

            var result = dataFragmentService.GetFragment(serializedObject, "Owners", new KeyValuePair<string, string>());
            Assert.IsInstanceOfType(result, typeof(string));
        }
        public void GetFormDataFragmentFilteredThrowsNotFoundExceptionTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject    = serilializedService.SerializeFormData(testClass);
            var filterQuery         = new KeyValuePair <string, string>("Id", "3");

            dataFragmentService.GetFragment(serializedObject, "Addresses", filterQuery);
        }
        public void GetFormDataFragmentReturnsReturnsSerializedStringTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject    = serilializedService.SerializeFormData(testClass);

            var result = dataFragmentService.GetFragment(serializedObject, "Owners", new KeyValuePair <string, string>());

            Assert.IsInstanceOfType(result, typeof(string));
        }
        public void GetFormDataFragmentReturnsCorrectFragmentTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);
            var targetFragmentserializedObject = serilializedService.SerializeFormData(testClass.Name);

            var result = dataFragmentService.GetFragment(serializedObject, "Name", new KeyValuePair<string, string>());
            Assert.AreEqual(targetFragmentserializedObject, result);
        }
        public void GetFormDataFragmentReturnsCorrectFragmentTest()
        {
            var testClass = GetTestClass();

            var serilializedService            = new JsonSerializationService();
            var dataFragmentService            = new DataFragmentJsonService(serilializedService);
            var serializedObject               = serilializedService.SerializeFormData(testClass);
            var targetFragmentserializedObject = serilializedService.SerializeFormData(testClass.Name);

            var result = dataFragmentService.GetFragment(serializedObject, "Name", new KeyValuePair <string, string>());

            Assert.AreEqual(targetFragmentserializedObject, result);
        }
        public void GetFormDataFilteredArrayFragmentReturnsCorrectFilteredFragmentTest2()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);
            var targetFragmentserializedObject = serilializedService.SerializeFormData(testClass.Owners.FirstOrDefault(o => o.Address.Id == 2).Address);
            var filterQuery = new KeyValuePair<string, string>("Id", "2");

            var result = dataFragmentService.GetFragment(serializedObject, "Address", filterQuery);
            Assert.AreEqual(targetFragmentserializedObject, result);
        }
        public void GetFormDataFilteredArrayFragmentReturnsCorrectFilteredFragmentTest2()
        {
            var testClass = GetTestClass();

            var serilializedService            = new JsonSerializationService();
            var dataFragmentService            = new DataFragmentJsonService(serilializedService);
            var serializedObject               = serilializedService.SerializeFormData(testClass);
            var targetFragmentserializedObject = serilializedService.SerializeFormData(testClass.Owners.FirstOrDefault(o => o.Address.Id == 2).Address);
            var filterQuery = new KeyValuePair <string, string>("Id", "2");

            var result = dataFragmentService.GetFragment(serializedObject, "Address", filterQuery);

            Assert.AreEqual(targetFragmentserializedObject, result);
        }
        public void GetFormDataFragmentThrowsNotFoundExceptionTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);

            dataFragmentService.GetFragment(serializedObject, "InvalidFragmentName", new KeyValuePair<string, string>());
        }
        public void GetFormDataFragmentInvalidJsonThrowsUnsupportedOperationExceptionTest()
        {
            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            const string serializedObject = "<xml>Not Json</xml>";

            dataFragmentService.GetFragment(serializedObject, "Addresses", new KeyValuePair<string, string>());
        }
        public void GetFormDataFragmentFilteredThrowsNotFoundExceptionTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);
            var filterQuery = new KeyValuePair<string, string>("Id", "3");

            dataFragmentService.GetFragment(serializedObject, "Addresses", filterQuery);
        }