public void Constructor_builds_correct_object() { var propertyInfo = typeof(ClassWithAttributes).GetProperty(nameof(ClassWithAttributes.NoAttribute)); var propertyInfoDescription = new PropertyInfoDescription(propertyInfo); propertyInfoDescription.Attribute.Should().BeNull(); }
public void Constructor_builds_correct_object(string name, bool bindable, BindingDirection direction) { var expected = new BindableAttribute(bindable, direction); var propertyInfo = typeof(ClassWithAttributes).GetProperty(name); var propertyInfoDescription = new PropertyInfoDescription(propertyInfo); propertyInfoDescription.Attribute.ShouldBeEquivalentTo(expected); }
public void Constructor_use_default_if_not_found(string name, bool bindable, BindingDirection direction) { var expected = new BindableAttribute(bindable, direction); var defaultAttribute = new BindableAttribute(false, BindingDirection.TwoWay); var propertyInfo = typeof(ClassWithAttributes).GetProperty(name); var propertyInfoDescription = new PropertyInfoDescription(propertyInfo, defaultAttribute); propertyInfoDescription.Attribute.ShouldBeEquivalentTo(expected); }
public void Get_Performance_Test_Stress() { var @object = new FakeClass(); var stopWatch = new Stopwatch(); stopWatch.Start(); var operations = 100000000; var propertyInfo = typeof(FakeClass).GetProperty("Available2", BindingFlags.Public | BindingFlags.Instance); var description = new PropertyInfoDescription(propertyInfo); var myTypeInstrospector = new PropertyAccessor(typeof(FakeClass), description, 0); for (var i = 0; i < operations; i++) { var res = myTypeInstrospector.Get(@object); } stopWatch.Stop(); var ts = stopWatch.ElapsedMilliseconds; _Output.WriteLine($"Perf: {operations* 1000/ts} operations per sec"); }