[Test] public void ProxyOverridesAbstractMemberAndUtilizeImplementationInBase() { Factory.Reset(true); NotifyPropertyChangeFactory.SetMarkingAttribute <MarkingAttribute>(a => a.BaseType); var mock = MockRepository.GenerateStub <IBigMess>(); var proxy = NotifyPropertyChangeFactory.GetProxy(mock); Assert.That(proxy, Is.InstanceOf <AbstractBigMess>()); Assert.That(((BigMessBase)proxy).Target, Is.SameAs(mock)); }
[Test] public void SetMarkingAttributeChangesMarkingAttribute() { Factory.Reset(true); NotifyPropertyChangeFactory.SetMarkingAttribute <SimpleMarkerAttribute>(); var foo = MockRepository.GenerateStub <IFoo>(); var koo = MockRepository.GenerateStub <IKoo>(); var bar = MockRepository.GenerateStub <IBar>(); var barProxy = NotifyPropertyChangeFactory.GetProxy(bar); barProxy.FooProperty = foo; barProxy.KooProperty = koo; Assert.That(barProxy, Is.InstanceOf <NotifyPropertyChangeBase>()); Assert.That(barProxy.FooProperty, Is.SameAs(foo)); Assert.That(barProxy.KooProperty, Is.InstanceOf <NotifyPropertyChangeBase>()); }
[Test] public void SetMarkingAttributeChangesMarkingAttributeAndAllowsDifferentBaseType() { Factory.Reset(true); NotifyPropertyChangeFactory.SetMarkingAttribute <MarkingAttribute>(a => a.BaseType); var handler = MockRepository.GenerateStub <PropertyChangedEventHandler>(); var foo = MockRepository.GenerateStub <IFoo>(); var koo = MockRepository.GenerateStub <IKoo>(); var bar = MockRepository.GenerateStub <IBar>(); var barProxy = NotifyPropertyChangeFactory.GetProxy(bar); barProxy.FooProperty = foo; barProxy.KooProperty = koo; Assert.That(barProxy, Is.InstanceOf <GoodBase>()); Assert.That(barProxy.KooProperty, Is.SameAs(koo)); var fooProxy = barProxy.FooProperty; Assert.That(fooProxy, Is.InstanceOf <GoodBaseDifferentRaiser>()); ((INotifyPropertyChanged)fooProxy).PropertyChanged += handler; fooProxy.IntPropery = 100; handler.AssertWasCalled(x => x(Arg <object> .Is.Same(fooProxy), Arg <PropertyChangedEventArgs> .Matches(e => e.PropertyName == "IntPropery Raised"))); }