public void Respect_generic_settings() { const string behaviorName = "behaviorWithSettings"; BehaviorExtender.Register <BehaviorWithSettings>(behaviorName); try { var sut = new NZazuFieldBehaviorFactory(); var behaviorDefinition = new BehaviorDefinition { Name = behaviorName, Settings = new Dictionary <string, string> { { "AnInt", "42" }, { "AString", "AString" }, { "ADouble", "42.42" }, { "ABool", "True" } } }; var behavior = (BehaviorWithSettings)sut.CreateFieldBehavior(behaviorDefinition); behavior.AnInt.Should().Be(42); behavior.AString.Should().Be("AString"); behavior.ADouble.Should().Be(42.42); behavior.ABool.Should().BeTrue(); } finally { BehaviorExtender.Unregister(behaviorName); } }
public void Be_Creatable() { var sut = new NZazuFieldBehaviorFactory(); sut.Should().NotBeNull(); sut.Should().BeAssignableTo <INZazuWpfFieldBehaviorFactory>(); }
public void Return_Null_For_Unknown_Types() { var sut = new NZazuFieldBehaviorFactory(); var behavior = sut.CreateFieldBehavior(new BehaviorDefinition { Name = "i am not registered" }); behavior.Should().BeNull(); }
public void Support(string fieldType, Type controlType) { var sut = new NZazuFieldBehaviorFactory(); var field = sut.CreateFieldBehavior(new BehaviorDefinition { Name = fieldType }); field.Should().NotBeNull(); field.GetType().Should().Be(controlType); }
public void Verify_Parameter_On_CreateFieldBehavior() { var sut = new NZazuFieldBehaviorFactory(); new Action(() => sut.CreateFieldBehavior(null)) .Invoking(a => a()) .Should().Throw <ArgumentNullException>(); new Action(() => sut.CreateFieldBehavior(new BehaviorDefinition())) .Invoking(a => a()) .Should().Throw <ArgumentException>(); }
public void Handle_Interface_Implementations() { const string behaviorName = "IfaceImpl"; BehaviorExtender.Register <SimpleInterfaceImplementation>(behaviorName); try { var sut = new NZazuFieldBehaviorFactory(); var behavior = sut.CreateFieldBehavior(new BehaviorDefinition { Name = behaviorName }); behavior.Should().BeAssignableTo <SimpleInterfaceImplementation>(); // just to get code coverage behavior.AttachTo(null, null); behavior.Detach(); } finally { BehaviorExtender.Unregister(behaviorName); } }