private static void TestSingleValueRoundTrip <T1, T2>(string fieldName, T1 expectedGoogleValue, T2 expectedFimValue, T1 valueForUpdateTest)
        {
            string testAttributeName            = $"{UserCustomSchemaTests.TestSchemaName}_{fieldName}";
            AdapterCustomSchemaField schemaItem = GetFieldAdapter(testAttributeName);

            User u = DeserializeTestUser();

            CSEntryChange x = CSEntryChange.Create();

            x.ObjectModificationType = ObjectModificationType.Add;

            // Convert the user object into a series of attribute changes

            IList <AttributeChange> result = schemaItem.CreateAttributeChanges(x.DN, ObjectModificationType.Add, u).ToList();

            AttributeChange change = result.FirstOrDefault(t => t.Name == testAttributeName);

            Assert.IsNotNull(change);
            Assert.AreEqual(expectedFimValue, change.GetValueAdd <T2>());

            // Reverse the process and convert the attribute changes onto a new user

            x.AttributeChanges.Add(change);

            User ux = new User();

            schemaItem.UpdateField(x, ux);
            Assert.AreEqual(expectedGoogleValue, (T1)ux.CustomSchemas[TestSchemaName][fieldName]);

            // Modify the value

            change = AttributeChange.CreateAttributeUpdate(testAttributeName, valueForUpdateTest);
            x      = CSEntryChange.Create();
            x.ObjectModificationType = ObjectModificationType.Update;
            x.AttributeChanges.Add(change);

            schemaItem.UpdateField(x, ux);
            Assert.AreEqual(valueForUpdateTest, (T1)ux.CustomSchemas[TestSchemaName][fieldName]);

            // Delete the value

            change = AttributeChange.CreateAttributeDelete(testAttributeName);
            x      = CSEntryChange.Create();
            x.ObjectModificationType = ObjectModificationType.Update;
            x.AttributeChanges.Add(change);

            schemaItem.UpdateField(x, ux);
            Assert.AreEqual(Constants.NullValuePlaceholder, (string)ux.CustomSchemas[TestSchemaName][fieldName]);
        }
        private static void TestMultivalueRoundTrip <T1, T2>(string fieldName, IList <T1> expectedGoogleValue, IList <T2> expectedFimValues, T1 valueToAdd)
        {
            string testAttributeName            = $"{UserCustomSchemaTests.TestSchemaName}_{fieldName}";
            AdapterCustomSchemaField schemaItem = GetFieldAdapter(testAttributeName);

            User u = DeserializeTestUser();

            CSEntryChange x = CSEntryChange.Create();

            x.ObjectModificationType = ObjectModificationType.Add;

            // Convert the user object into a series of attribute changes

            IList <AttributeChange> result = schemaItem.CreateAttributeChanges(x.DN, ObjectModificationType.Add, u).ToList();

            AttributeChange change = result.FirstOrDefault(t => t.Name == testAttributeName);

            Assert.IsNotNull(change);
            CollectionAssert.AreEquivalent(expectedFimValues.ToArray(), change.GetValueAdds <T2>().ToArray());

            // Reverse the process and convert the attribute changes onto a new user
            x.AttributeChanges.Add(change);

            User ux = new User();

            schemaItem.UpdateField(x, ux);

            List <T1> returnedValues = UserCustomSchemaTests.GetReturnedValues <T1>(fieldName, ux);

            CollectionAssert.AreEquivalent(expectedGoogleValue.ToArray(), returnedValues);

            // Add a value
            ValueChange add1 = ValueChange.CreateValueAdd(valueToAdd);

            change = AttributeChange.CreateAttributeUpdate(testAttributeName, new List <ValueChange>()
            {
                add1
            });
            x = CSEntryChange.Create();
            x.ObjectModificationType = ObjectModificationType.Update;
            x.AttributeChanges.Add(change);
            schemaItem.UpdateField(x, ux);

            returnedValues = UserCustomSchemaTests.GetReturnedValues <T1>(fieldName, ux);

            IList <object> e = expectedGoogleValue.Cast <object>().ToList();

            e.Add(valueToAdd);

            CollectionAssert.AreEquivalent(e.ToArray(), returnedValues);

            // Remove a value

            ValueChange delete1 = ValueChange.CreateValueDelete(valueToAdd);

            change = AttributeChange.CreateAttributeUpdate(testAttributeName, new List <ValueChange>()
            {
                delete1
            });
            x = CSEntryChange.Create();
            x.ObjectModificationType = ObjectModificationType.Update;
            x.AttributeChanges.Add(change);
            schemaItem.UpdateField(x, ux);

            returnedValues = UserCustomSchemaTests.GetReturnedValues <T1>(fieldName, ux);

            CollectionAssert.AreEquivalent(expectedGoogleValue.ToArray(), returnedValues);

            // Delete the attribute

            change = AttributeChange.CreateAttributeDelete(testAttributeName);
            x      = CSEntryChange.Create();
            x.ObjectModificationType = ObjectModificationType.Update;
            x.AttributeChanges.Add(change);

            schemaItem.UpdateField(x, ux);
            Assert.AreEqual(Constants.NullValuePlaceholder, (string)ux.CustomSchemas[TestSchemaName][fieldName]);
        }