public void RegisterDouble() { const string Name = "MyPropertyRegisterDouble"; _ = AttachedProperty.Register <AttachedPropertyTests, int>(Name); new Action(() => _ = AttachedProperty.Register <AttachedPropertyTests, int>(Name)).Should().Throw <ArgumentException>() .WithMessage("*already registered*").WithMessage($"*{typeof(AttachedPropertyTests).Name}*").WithMessage($"*{Name}*"); }
public void RegisterWithSuffix() { AttachedProperty <string> property = AttachedProperty.Register <AttachedPropertyTests, string>(() => MyStringProperty, "8"); property.DefaultValue.Should().Be("8"); property.DefaultValueUntyped.Should().Be("8"); property.Name.Should().Be("MyString"); property.OwnerType.Should().Be <AttachedPropertyTests>(); }
public void RegisterAttached() { AttachedProperty <int> property = AttachedProperty.Register <AttachedPropertyTests, int>("MyPropertyRegisterAttached", 9); property.DefaultValue.Should().Be(9); property.DefaultValueUntyped.Should().Be(9); property.Name.Should().Be("MyPropertyRegisterAttached"); property.OwnerType.Should().Be <AttachedPropertyTests>(); }
public void RegisterWithoutSuffix() { AttachedProperty <char> property = AttachedProperty.Register <AttachedPropertyTests, char>(() => MyChar, '7'); property.DefaultValue.Should().Be('7'); property.DefaultValueUntyped.Should().Be('7'); property.Name.Should().Be(nameof(MyChar)); property.OwnerType.Should().Be <AttachedPropertyTests>(); }
public void NullArguments() { var name = "MyPropertyCreateNullArguments"; var nameExpression = (IntPropertyExpression)(() => MyIntProperty); var identifier = new AttachableMemberIdentifier(typeof(AttachedPropertyTests), name); new Action(() => _ = AttachedProperty.Register <AttachedPropertyTests, int>((string)null, 1)).Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(name)); new Action(() => _ = AttachedProperty.Register <AttachedPropertyTests, int>((IntPropertyExpression)null, 1)).Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(nameExpression)); new Action(() => _ = AttachedProperty.Get(null)).Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(identifier)); }