public UnitTestStepObjectModificationViewModel(UnitTestStepObjectModification model) : base(model) { this.typedModel = model; AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(model.ObjectClassName); this.AttributeChanges = new AttributeChangesViewModel(model.CSEntryChange.AttributeChanges, model.CSEntryChange.ObjectModificationType, objectClass, () => this.GetAllowedReferenceObjects()); if (this.typedModel.ObjectCreationStep != null) { this.typedModel.ObjectCreationStep.PropertyChanged += ObjectCreationStep_PropertyChanged; } }
public void AddUnitTestObjectModification() { NewObjectModificationWindow window = new NewObjectModificationWindow(); NewObjectModificationViewModel vm = new NewObjectModificationViewModel(window, this.parentUnitTest); window.DataContext = vm; vm.StepName = "Modify"; vm.ModificationType = ObjectModificationType.Update; bool?result = window.ShowDialog(); if (result.HasValue && result.Value) { UnitTestStepObjectModification step = new UnitTestStepObjectModification(); step.ParentTest = this.parentUnitTest; step.ObjectCreationStep = vm.CreationObject; step.Name = vm.StepName; step.ModificationType = vm.ModificationType; this.Add(step, true); } }
public void TestSerialization() { UnitTestStepObjectModification toSerlialize = new UnitTestStepObjectModification(); AcmaCSEntryChange csentry = new AcmaCSEntryChange(); csentry.ObjectModificationType = ObjectModificationType.Update; csentry.ObjectType = "person"; csentry.DN = "testDN"; csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("sn", "myValue")); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mailAlternateAddresses", new List <object>() { "myValue1", "myValue2" })); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeDelete("accountName")); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("activeExpiryDate", 900L)); csentry.AttributeChanges.Add(AttributeChange.CreateAttributeUpdate("displayName", new List <ValueChange>() { ValueChange.CreateValueAdd("addValue"), ValueChange.CreateValueDelete("deleteValue") })); csentry.AnchorAttributes.Add(AnchorAttribute.Create("myAnchor1", "99")); csentry.AnchorAttributes.Add(AnchorAttribute.Create("myAnchor2", "my second test anchor")); toSerlialize.CSEntryChange = csentry; UnitTestStepObjectModification deserialized = UnitTestControl.XmlSerializeRoundTrip <UnitTestStepObjectModification>(toSerlialize); CSEntryChange deserializedCSEntry = deserialized.CSEntryChange; Assert.AreEqual(csentry.ObjectModificationType, deserializedCSEntry.ObjectModificationType); Assert.AreEqual(csentry.ObjectType, deserializedCSEntry.ObjectType); Assert.AreEqual(csentry.DN, deserializedCSEntry.DN); Assert.AreEqual(csentry.AttributeChanges[0].Name, deserializedCSEntry.AttributeChanges[0].Name); Assert.AreEqual(csentry.AttributeChanges[0].ModificationType, deserializedCSEntry.AttributeChanges[0].ModificationType); Assert.AreEqual(csentry.AttributeChanges[0].ValueChanges[0].Value, deserializedCSEntry.AttributeChanges[0].ValueChanges[0].Value); Assert.AreEqual(csentry.AttributeChanges[0].ValueChanges[0].ModificationType, deserializedCSEntry.AttributeChanges[0].ValueChanges[0].ModificationType); Assert.AreEqual(csentry.AttributeChanges[1].Name, deserializedCSEntry.AttributeChanges[1].Name); Assert.AreEqual(csentry.AttributeChanges[1].ModificationType, deserializedCSEntry.AttributeChanges[1].ModificationType); Assert.AreEqual(csentry.AttributeChanges[1].ValueChanges[0].Value, deserializedCSEntry.AttributeChanges[1].ValueChanges[0].Value); Assert.AreEqual(csentry.AttributeChanges[1].ValueChanges[0].ModificationType, deserializedCSEntry.AttributeChanges[1].ValueChanges[0].ModificationType); Assert.AreEqual(csentry.AttributeChanges[1].ValueChanges[1].Value, deserializedCSEntry.AttributeChanges[1].ValueChanges[1].Value); Assert.AreEqual(csentry.AttributeChanges[1].ValueChanges[1].ModificationType, deserializedCSEntry.AttributeChanges[1].ValueChanges[1].ModificationType); Assert.AreEqual(csentry.AttributeChanges[2].Name, deserializedCSEntry.AttributeChanges[2].Name); Assert.AreEqual(csentry.AttributeChanges[2].ModificationType, deserializedCSEntry.AttributeChanges[2].ModificationType); Assert.AreEqual(csentry.AttributeChanges[3].Name, deserializedCSEntry.AttributeChanges[3].Name); Assert.AreEqual(csentry.AttributeChanges[3].ModificationType, deserializedCSEntry.AttributeChanges[3].ModificationType); Assert.AreEqual(csentry.AttributeChanges[3].ValueChanges[0].Value, deserializedCSEntry.AttributeChanges[3].ValueChanges[0].Value); Assert.AreEqual(csentry.AttributeChanges[3].ValueChanges[0].ModificationType, deserializedCSEntry.AttributeChanges[3].ValueChanges[0].ModificationType); Assert.AreEqual(csentry.AttributeChanges[4].Name, deserializedCSEntry.AttributeChanges[4].Name); Assert.AreEqual(csentry.AttributeChanges[4].ModificationType, deserializedCSEntry.AttributeChanges[4].ModificationType); Assert.AreEqual(csentry.AttributeChanges[4].ValueChanges[0].Value, deserializedCSEntry.AttributeChanges[4].ValueChanges[0].Value); Assert.AreEqual(csentry.AttributeChanges[4].ValueChanges[0].ModificationType, deserializedCSEntry.AttributeChanges[4].ValueChanges[0].ModificationType); Assert.AreEqual(csentry.AttributeChanges[4].ValueChanges[1].Value, deserializedCSEntry.AttributeChanges[4].ValueChanges[1].Value); Assert.AreEqual(csentry.AttributeChanges[4].ValueChanges[1].ModificationType, deserializedCSEntry.AttributeChanges[4].ValueChanges[1].ModificationType); Assert.AreEqual(csentry.AnchorAttributes[0].Name, deserializedCSEntry.AnchorAttributes[0].Name); Assert.AreEqual(csentry.AnchorAttributes[0].Value, deserializedCSEntry.AnchorAttributes[0].Value); Assert.AreEqual(csentry.AnchorAttributes[1].Name, deserializedCSEntry.AnchorAttributes[1].Name); Assert.AreEqual(csentry.AnchorAttributes[1].Value, deserializedCSEntry.AnchorAttributes[1].Value); }
public void TestSerialization() { UnitTest unitTest1 = new UnitTest(); unitTest1.Description = "unit test 1"; unitTest1.ExpectedConstructors.Add("ABC123"); unitTest1.ExpectedConstructors.Add("123DGS"); unitTest1.ID = "ID1234"; UnitTestStepObjectCreation ut1step1 = new UnitTestStepObjectCreation(); AcmaCSEntryChange csentry1 = new AcmaCSEntryChange(); csentry1.ObjectModificationType = ObjectModificationType.Add; csentry1.ObjectType = "person"; csentry1.DN = "testDN"; ut1step1.Name = "mystep1"; ut1step1.CSEntryChange = csentry1; unitTest1.Steps.Add(ut1step1); UnitTestStepObjectEvaluation ut1step2 = new UnitTestStepObjectEvaluation(); ut1step2.Name = "mystep2"; ut1step2.ObjectCreationStep = ut1step1; ut1step2.SuccessCriteria = new RuleGroup(); ut1step2.SuccessCriteria.Items.Add(new ObjectChangeRule() { Description = "test", TriggerEvents = TriggerEvents.Add }); unitTest1.Steps.Add(ut1step2); UnitTest unitTest2 = new UnitTest(); unitTest2.Description = "unit test 1"; unitTest2.ExpectedConstructors.Add("ABC123"); unitTest2.ExpectedConstructors.Add("123DGS"); unitTest2.ID = "ID1234"; UnitTestStepObjectModification ut2step1 = new UnitTestStepObjectModification(); AcmaCSEntryChange csentry2 = new AcmaCSEntryChange(); csentry2.ObjectModificationType = ObjectModificationType.Update; csentry2.ObjectType = "person"; csentry2.DN = "testDN"; ut2step1.Name = "mystep1"; ut2step1.CSEntryChange = csentry2; unitTest2.Steps.Add(ut2step1); UnitTestStepObjectEvaluation ut2step2 = new UnitTestStepObjectEvaluation(); ut2step2.Name = "mystep2"; ut2step2.ObjectCreationStep = ut1step1; ut2step2.SuccessCriteria = new RuleGroup(); ut2step2.SuccessCriteria.Items.Add(new ObjectChangeRule() { Description = "test", TriggerEvents = TriggerEvents.Add }); unitTest2.Steps.Add(ut2step2); UnitTestFile toSerialize = new UnitTestFile(); toSerialize.ConfigVersion = "1"; toSerialize.Description = "test description"; toSerialize.UnitTestObjects.Add(unitTest1); toSerialize.UnitTestObjects.Add(unitTest2); UniqueIDCache.ClearIdCache(); UnitTestFile deserialized = UnitTestControl.XmlSerializeRoundTrip <UnitTestFile>(toSerialize); Assert.AreEqual(toSerialize.Description, deserialized.Description); Assert.AreEqual(toSerialize.ConfigVersion, deserialized.ConfigVersion); Assert.AreEqual(toSerialize.UnitTestObjects.Count, deserialized.UnitTestObjects.Count); UnitTest deserializedUnitTest1 = deserialized.UnitTestObjects[0] as UnitTest; Assert.AreEqual(unitTest1.Description, deserializedUnitTest1.Description); Assert.AreEqual(unitTest1.ExpectedConstructors[0], deserializedUnitTest1.ExpectedConstructors[0]); Assert.AreEqual(unitTest1.ExpectedConstructors[1], deserializedUnitTest1.ExpectedConstructors[1]); Assert.AreEqual(unitTest1.ID, deserializedUnitTest1.ID); Assert.AreEqual(((UnitTestStepObjectCreation)unitTest1.Steps[0]).Name, ((UnitTestStepObjectCreation)deserializedUnitTest1.Steps[0]).Name); Assert.AreEqual(((UnitTestStepObjectCreation)unitTest1.Steps[0]).CSEntryChange.DN, ((UnitTestStepObjectCreation)deserializedUnitTest1.Steps[0]).CSEntryChange.DN); Assert.AreEqual(((UnitTestStepObjectCreation)unitTest1.Steps[0]).CSEntryChange.ObjectType, ((UnitTestStepObjectCreation)deserializedUnitTest1.Steps[0]).CSEntryChange.ObjectType); Assert.AreEqual(((UnitTestStepObjectCreation)unitTest1.Steps[0]).CSEntryChange.ObjectModificationType, ((UnitTestStepObjectCreation)deserializedUnitTest1.Steps[0]).CSEntryChange.ObjectModificationType); Assert.AreEqual(((UnitTestStepObjectEvaluation)unitTest1.Steps[1]).Name, ((UnitTestStepObjectEvaluation)deserializedUnitTest1.Steps[1]).Name); Assert.AreEqual(((UnitTestStepObjectEvaluation)unitTest1.Steps[1]).ObjectCreationStepName, ((UnitTestStepObjectEvaluation)deserializedUnitTest1.Steps[1]).ObjectCreationStepName); Assert.AreEqual(((UnitTestStepObjectEvaluation)unitTest1.Steps[1]).SuccessCriteria.Items.Count, ((UnitTestStepObjectEvaluation)deserializedUnitTest1.Steps[1]).SuccessCriteria.Items.Count); }