예제 #1
0
        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);
            }
        }
예제 #2
0
        public void Be_Creatable()
        {
            var sut = new NZazuFieldBehaviorFactory();

            sut.Should().NotBeNull();
            sut.Should().BeAssignableTo <INZazuWpfFieldBehaviorFactory>();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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);
        }
예제 #5
0
        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>();
        }
예제 #6
0
        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);
            }
        }