Hi everyone,
I wanted to develop a mixin that has multiple properties with EnabledIf attributes such as:
public class TestMixin : ITestStepPostRunMixin
{
[Browsable(false)]
public bool IsEnabled { get; set; }
[EnabledIf(nameof(IsEnabled), true, HideIfDisabled = true)]
public string String1 { get; set; }
[EnabledIf(nameof(IsEnabled), false, HideIfDisabled = true)]
public string String2 { get; set; }
public TestMixin(bool isEnabled)
{
IsEnabled = isEnabled;
}
public void OnPostRun(TestStepPostRunEventArgs eventArgs)
{
}
}
[MixinBuilder(typeof(ITestStepParent))]
public class TestMixinBuilder : IMixinBuilder
{
public bool IsEnabled{ get; set; }
public void Initialize(ITypeData targetType)
{
}
public MixinMemberData ToDynamicMember(ITypeData targetType)
{
return new MixinMemberData(this, () => new TestMixin(IsEnabled))
{
TypeDescriptor = TypeData.FromType(typeof(TestMixin)),
Attributes = GetAttributes(),
Writable = true,
Readable = true,
DeclaringType = targetType,
Name = "TestMixin"
};
}
IEnumerable<Attribute> GetAttributes()
{
yield return new EmbedPropertiesAttribute();
yield return new DisplayAttribute("Repeat Mixin", Order: 20000);
}
}
Problem with this mixin is that when I modify the mixin from the menu command, EnabledIf attribute does not work, visibility of the properties are not changed.
This mixin works fine when it is directly embedded to a test step using [EmbedAttribute].
Edit:
This issue also exists for Basic Mixins plugin. When you modify a mixin, property on the Test Step Settings panel is not updated.