public void TestSimpleImportDoubleTransformString() { GetDNComponentTransform tx1 = new GetDNComponentTransform(); tx1.ID = "GetDN2"; tx1.ComponentIndex = 1; tx1.RdnFormat = RdnFormat.ValueOnly; this.re.config.Transforms.Add(tx1); StringCaseTransform tx2 = new StringCaseTransform(); tx2.ID = "ToLower3"; tx2.StringCase = StringCaseType.Lower; this.re.config.Transforms.Add(tx2); this.ExecuteImportTest( AttributeType.String, AttributeType.String, new List <Transform>() { tx1, tx2 }, new List <object>() { "test user" }, new List <object>() { "CN=Test User, OU=Test" } ); }
public void TestSimpleImportTransformString() { GetDNComponentTransform tx = new GetDNComponentTransform(); tx.ID = "GetDN1"; tx.ComponentIndex = 1; tx.RdnFormat = RdnFormat.ValueOnly; this.re.config.Transforms.Add(tx); this.ExecuteImportTest( AttributeType.String, AttributeType.String, new List <Transform>() { tx }, new List <object>() { "Test User" }, new List <object>() { "CN=Test User, OU=Test" } ); }
public void TestSerialization() { UniqueIDCache.ClearIdCache(); TransformKeyedCollection objectToSerialize = new TransformKeyedCollection(); StringCaseTransform transform1 = new StringCaseTransform(); transform1.ID = "tx0001"; transform1.StringCase = StringCaseType.Title; GetDNComponentTransform transform2 = new GetDNComponentTransform(); transform2.ID = "tx0002"; transform2.RdnFormat = RdnFormat.ValueOnly; transform2.ComponentIndex = 1; objectToSerialize.Add(transform1); objectToSerialize.Add(transform2); UniqueIDCache.ClearIdCache(); TransformKeyedCollection deserializedObject = (TransformKeyedCollection)UnitTestControl.XmlSerializeRoundTrip <TransformKeyedCollection>(objectToSerialize); Assert.AreEqual(objectToSerialize.Count, deserializedObject.Count); Assert.AreEqual(objectToSerialize[0].ID, transform1.ID); Assert.AreEqual(objectToSerialize[1].ID, transform2.ID); }
public FlowRuleParameterTests() { UniqueIDCache.ClearIdCache(); this.config = new XmlConfigFile(); GetDNComponentTransform transform1 = new GetDNComponentTransform(); transform1.ID = "xform1"; this.config.Transforms.Add(transform1); GetDNComponentTransform transform2 = new GetDNComponentTransform(); transform2.ID = "xform2"; this.config.Transforms.Add(transform2); MVBooleanToBitmaskTransform transform3 = new MVBooleanToBitmaskTransform(); transform3.ID = "loopback"; this.config.Transforms.Add(transform3); FlowRuleAlias alias1 = new FlowRuleAlias(); alias1.Alias = "alias1"; alias1.FlowRuleDefinition = "csattribute>>xform1>>mvattribute"; this.config.FlowRuleAliases.Add(alias1); FlowRuleAlias alias2 = new FlowRuleAlias(); alias2.Alias = "alias2"; alias2.FlowRuleDefinition = "csattribute>>xform2>>mvattribute"; this.config.FlowRuleAliases.Add(alias2); }
public void GetDNComponentTransformRDN1() { GetDNComponentTransform transform = new GetDNComponentTransform(); transform.ComponentIndex = 1; transform.RdnFormat = RdnFormat.Rdn; transform.Direction = Direction.Left; this.ExecuteTestGetDN(transform, "cn=Test user, ou=Organisation", "cn=Test user"); }
public void GetDNComponentTransformValueEscaped() { GetDNComponentTransform transform = new GetDNComponentTransform(); transform.ComponentIndex = 1; transform.RdnFormat = RdnFormat.ValueOnly; transform.Direction = Direction.Left; this.ExecuteTestGetDN(transform, "cn=\"Test user\", ou=Organisation", "Test user"); }
public void GetDNComponentTransformValue2Right() { GetDNComponentTransform transform = new GetDNComponentTransform(); transform.ComponentIndex = 2; transform.RdnFormat = RdnFormat.ValueOnly; transform.Direction = Direction.Right; this.ExecuteTestGetDN(transform, "cn=Test user, ou=Organisation", "Test user"); }
public void PerformanceTest() { GetDNComponentTransform transform = new GetDNComponentTransform(); transform.ComponentIndex = 1; transform.RdnFormat = RdnFormat.ValueOnly; transform.Direction = Direction.Left; UnitTestControl.PerformanceTest(() => { Assert.AreEqual("Test user", transform.TransformValue("cn=Test user, ou=Organisation").First()); }, 200000); }
public void TestSerialization() { UniqueIDCache.ClearIdCache(); GetDNComponentTransform transformToSeralize = new GetDNComponentTransform(); transformToSeralize.ID = "test001"; transformToSeralize.RdnFormat = RdnFormat.Rdn; transformToSeralize.ComponentIndex = 5; transformToSeralize.Direction = Direction.Right; UniqueIDCache.ClearIdCache(); GetDNComponentTransform deserializedTransform = (GetDNComponentTransform)UnitTestControl.XmlSerializeRoundTrip <Transform>(transformToSeralize); Assert.AreEqual(transformToSeralize.ID, deserializedTransform.ID); Assert.AreEqual(transformToSeralize.RdnFormat, deserializedTransform.RdnFormat); Assert.AreEqual(transformToSeralize.ComponentIndex, deserializedTransform.ComponentIndex); Assert.AreEqual(transformToSeralize.Direction, deserializedTransform.Direction); }
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); }
private void ExecuteTestGetDN(GetDNComponentTransform transform, string sourceValue, string expectedValue) { string outValue = transform.TransformValue(sourceValue).FirstOrDefault() as string; Assert.AreEqual(expectedValue, outValue); }
public GetDNComponentTransformViewModel(GetDNComponentTransform model) : base(model) { this.model = model; }