Пример #1
0
        public void ExecuteImportLoopbackTest(
            AttributeType sourceDataType,
            AttributeType targetDataType,
            List <Transform> transforms,
            object expectedValue,
            object targetValue,
            object sourceValue
            )
        {
            string mvattributeName = "mvattribute";

            TestMVEntry mventry = new TestMVEntry();

            mventry.Add(this.CreateAttribute(mvattributeName, targetDataType, false, targetValue));

            TestCSEntry csentry = new TestCSEntry();

            string attributeName = "csattribute1";

            csentry.Add(this.CreateAttribute(attributeName, sourceDataType, false, sourceValue));

            List <string> transformNames = new List <string>();

            foreach (Transform transform in transforms)
            {
                transformNames.Add(transform.ID);
            }

            string flowRuleName = string.Format(
                "{0}>>{1}>>{2}",
                attributeName,
                transformNames.ToSeparatedString(">>"),
                mvattributeName);

            this.rulesExtension.MapAttributesForImport(flowRuleName, csentry, mventry);

            Attrib returnedAttribute = mventry["mvattribute"];

            switch (targetDataType)
            {
            case AttributeType.Binary:
                CollectionAssert.AreEqual(returnedAttribute.BinaryValue, (byte[])expectedValue, new ByteArrayComparer());
                break;

            case AttributeType.Boolean:
                Assert.AreEqual(returnedAttribute.BooleanValue, (bool)expectedValue);
                break;

            case AttributeType.Integer:
                Assert.AreEqual(returnedAttribute.IntegerValue, (long)expectedValue);
                break;

            case AttributeType.String:
                Assert.AreEqual(returnedAttribute.StringValue, (string)expectedValue);
                break;

            case AttributeType.Reference:
            case AttributeType.Undefined:
            default:
                throw new UnknownOrUnsupportedDataTypeException();
            }
        }
Пример #2
0
        public void PerformanceTestImports()
        {
            GetDNComponentTransform tx = new GetDNComponentTransform();

            tx.ID             = "GetDN1";
            tx.ComponentIndex = 1;
            tx.RdnFormat      = RdnFormat.ValueOnly;

            this.re.config.Transforms.Add(tx);


            AttributeType targetDataType = AttributeType.String;
            AttributeType sourceDataType = AttributeType.String;

            List <Transform> transforms = new List <Transform>()
            {
                tx
            };
            List <object> sourceAttribute = new List <object>()
            {
                "CN=Test User, OU=Test"
            };
            List <List <object> > sourceAttributes = new List <List <object> >()
            {
                sourceAttribute
            };

            string mvattributeName = "mvattribute";

            TestMVEntry mventry = new TestMVEntry();

            mventry.Add(this.CreateAttribute(mvattributeName, targetDataType, false, null));

            TestCSEntry csentry = new TestCSEntry();

            int           count          = 0;
            List <string> attributeNames = new List <string>();

            foreach (List <object> attribute in sourceAttributes)
            {
                count++;
                string attributeName = "csattribute" + count;
                attributeNames.Add(attributeName);

                if (attribute.Count > 1)
                {
                    csentry.Add(this.CreateAttribute(attributeName, sourceDataType, attribute));
                }
                else if (attribute.Count == 1)
                {
                    csentry.Add(this.CreateAttribute(attributeName, sourceDataType, false, attribute.First()));
                }
                else
                {
                    throw new NullReferenceException("A value must be provided");
                }
            }

            List <string> transformNames = transforms.Select(transform => transform.ID).ToList();

            string flowRuleName =
                $"{attributeNames.ToSeparatedString("+")}>>{transformNames.ToSeparatedString(">>")}>>{mvattributeName}";


            UnitTestControl.PerformanceTest(() =>
            {
                this.rulesExtension.MapAttributesForImport(flowRuleName, csentry, mventry);
                Assert.AreEqual("Test User", mventry["mvattribute"].StringValue);
            }, 120000);
        }
Пример #3
0
        public void ExecuteImportTest(
            AttributeType sourceDataType,
            AttributeType targetDataType,
            List <Transform> transforms,
            List <object> expectedValues,
            params List <object>[] sourceAttributes
            )
        {
            string mvattributeName = "mvattribute";

            TestMVEntry mventry = new TestMVEntry();

            mventry.Add(this.CreateAttribute(mvattributeName, targetDataType, false, null));

            TestCSEntry csentry = new TestCSEntry();

            int           count          = 0;
            List <string> attributeNames = new List <string>();

            foreach (List <object> attribute in sourceAttributes)
            {
                count++;
                string attributeName = "csattribute" + count;
                attributeNames.Add(attributeName);

                if (attribute.Count > 1)
                {
                    csentry.Add(this.CreateAttribute(attributeName, sourceDataType, attribute));
                }
                else if (attribute.Count == 1)
                {
                    csentry.Add(this.CreateAttribute(attributeName, sourceDataType, false, attribute.First()));
                }
                else
                {
                    throw new NullReferenceException("A value must be provided");
                }
            }

            List <string> transformNames = new List <string>();

            foreach (Transform transform in transforms)
            {
                transformNames.Add(transform.ID);
            }

            string flowRuleName = string.Format(
                "{0}>>{1}>>{2}",
                attributeNames.ToSeparatedString("+"),
                transformNames.ToSeparatedString(">>"),
                mvattributeName);

            this.rulesExtension.MapAttributesForImport(flowRuleName, csentry, mventry);

            Attrib returnedAttribute = mventry["mvattribute"];

            switch (targetDataType)
            {
            case AttributeType.Binary:
                CollectionAssert.AreEqual(returnedAttribute.Values.ToByteArrays(), expectedValues, new ByteArrayComparer());
                break;

            case AttributeType.Boolean:
                Assert.AreEqual(returnedAttribute.BooleanValue, (bool)expectedValues.First());
                break;

            case AttributeType.Integer:
                CollectionAssert.AreEqual(returnedAttribute.Values.ToIntegerArray(), expectedValues);
                break;

            case AttributeType.String:
                CollectionAssert.AreEqual(returnedAttribute.Values.ToStringArray(), expectedValues);
                break;

            case AttributeType.Reference:
            case AttributeType.Undefined:
            default:
                throw new UnknownOrUnsupportedDataTypeException();
            }
        }