Пример #1
0
        public void UpdateFormDataFragmentUpdateFragmentThrowsNotFoundExceptionTest()
        {
            var testClass        = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

            dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "InvalidFragmentName", new KeyValuePair <string, 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 UpdateFormDataFragmentReturnsSerializedStringTest()
        {
            var testClass = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

            var result = dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "Owners", new KeyValuePair<string, string>());
            Assert.IsInstanceOfType(result, typeof(string));
        }
        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 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);
        }
Пример #6
0
        public void UpdateFormDataFragmentUpdateFilteredFragmentThrowsNotFoundExceptionTest()
        {
            var testClass        = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

            dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "Owners", filterQuery);
        }
        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);
        }
Пример #8
0
        public void UpdateFormDataFragmentReturnsSerializedStringTest()
        {
            var testClass        = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

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

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

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);
            var fragmentToRemove = testClass.Owners.FirstOrDefault(a => a.Id == 2);
            testClass.Owners.Remove(fragmentToRemove);

            var expectedFragmentserializedObject = serilializedService.SerializeFormData(testClass);
            var filterQuery = new KeyValuePair<string, string>("Id", "2");

            var result = dataFragmentService.RemoveFragment(serializedObject, "Owners", filterQuery);
            Assert.AreEqual(expectedFragmentserializedObject, result);
        }
        public void UpdateFormDataArrayFragmentReturnsUpdatedSerializedStringTest()
        {
            var testClass = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

            testClass.Owners = updatedTestClass.Owners;
            var expectedSerializedObject = serilializedService.SerializeFormData(testClass);

            var result = dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "Owners", new KeyValuePair<string, string>());
            Assert.AreEqual(expectedSerializedObject, result);
        }
 public void SerializationServiceSerializeObjectSerializesToStringTest()
 {
     var serializationService = new JsonSerializationService();
     var testObject = new SerializationTestClass("Jamie", DateTime.Now);
     var serializedObject = serializationService.SerializeFormData(testObject);
     Assert.IsInstanceOfType(serializedObject, typeof (string));
 }
Пример #12
0
        public void SerializationServiceSerializeObjectSerializesToStringTest()
        {
            var serializationService = new JsonSerializationService();
            var testObject           = new SerializationTestClass("Jamie", DateTime.Now);
            var serializedObject     = serializationService.SerializeFormData(testObject);

            Assert.IsInstanceOfType(serializedObject, typeof(string));
        }
Пример #13
0
        public void UpdateFormDataArrayFragmentReturnsUpdatedSerializedStringTest()
        {
            var testClass        = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

            testClass.Owners = updatedTestClass.Owners;
            var expectedSerializedObject = serilializedService.SerializeFormData(testClass);

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

            Assert.AreEqual(expectedSerializedObject, result);
        }
 public void SerializationServiceDeSerializeStringDeSerializesUsingTypeNameToObjectTest()
 {
     var serializationService = new JsonSerializationService();
     var testObject = new SerializationTestClass("Bob", DateTime.Now);
     var serializedObject = serializationService.SerializeFormData(testObject);
     var deserializedObject = serializationService.DeSerializeFormData(serializedObject);
     Assert.IsInstanceOfType(deserializedObject, typeof (SerializationTestClass));
 }
Пример #15
0
        public void SerializationServiceDeSerializeStringDeSerializesUsingTypeNameToObjectTest()
        {
            var serializationService = new JsonSerializationService();
            var testObject           = new SerializationTestClass("Bob", DateTime.Now);
            var serializedObject     = serializationService.SerializeFormData(testObject);
            var deserializedObject   = serializationService.DeSerializeFormData(serializedObject);

            Assert.IsInstanceOfType(deserializedObject, typeof(SerializationTestClass));
        }
        public void RemoveFormDataFilteredArrayFragmentReturnsUpdatedSerializedStringTestTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject    = serilializedService.SerializeFormData(testClass);
            var fragmentToRemove    = testClass.Owners.FirstOrDefault(a => a.Id == 2);

            testClass.Owners.Remove(fragmentToRemove);

            var expectedFragmentserializedObject = serilializedService.SerializeFormData(testClass);
            var filterQuery = new KeyValuePair <string, string>("Id", "2");

            var result = dataFragmentService.RemoveFragment(serializedObject, "Owners", filterQuery);

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

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

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

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

            var result = dataFragmentService.RemoveFragment(serializedObject, "Owners", new KeyValuePair<string, string>());
            Assert.AreNotEqual(serializedObject.Length, result.Length);
        }
Пример #19
0
        public void UpdateFormDataFragmentInvalidJsonThrowsUnsupportedOperationExceptionTest()
        {
            var testClass = GetTestClass();

            var          serilializedService      = new JsonSerializationService();
            var          dataFragmentService      = new DataFragmentJsonService(serilializedService);
            var          serializedObject         = serilializedService.SerializeFormData(testClass);
            const string serializedFragmentObject = "<xml>Not Json</xml>";

            dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "Owners", 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);
        }
        public void RemoveFormDataArrayFragmentReturnsUpdatedSerializedStringTest()
        {
            var testClass = GetTestClass();

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

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

            Assert.AreNotEqual(serializedObject.Length, result.Length);
        }
        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 UpdateFormDataFragmentInvalidJsonThrowsUnsupportedOperationExceptionTest()
        {
            var testClass = GetTestClass();

            var serilializedService = new JsonSerializationService();
            var dataFragmentService = new DataFragmentJsonService(serilializedService);
            var serializedObject = serilializedService.SerializeFormData(testClass);
            const string serializedFragmentObject = "<xml>Not Json</xml>";

            dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "Owners", new KeyValuePair<string, string>());
        }
        public void UpdateFormDataFragmentUpdateFilteredFragmentThrowsNotFoundExceptionTest()
        {
            var testClass = GetTestClass();
            var updatedTestClass = GetUpdatedTestClass();

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

            dataFragmentService.UpdateFragment(serializedObject, serializedFragmentObject, "Owners", filterQuery);
        }