public void DictionaryPropertyHandlesProxyAsExpected() { var proxy = NotifyPropertyChangeFactory.GetProxy(_target); var proxyDictionary = proxy.FooDictionary; Assert.That(proxyDictionary, Is.Not.SameAs(_target.FooDictionary)); // by indexer Assert.That(proxyDictionary[0].Name, Is.SameAs("No.0")); Assert.That(proxyDictionary[0], Is.InstanceOf <FooProxy>()); // by enuemrator Assert.That(proxyDictionary.First().Value.Name, Is.SameAs("No.0")); Assert.That(proxyDictionary.First().Value, Is.InstanceOf <FooProxy>()); // by enumerator of values collection Assert.That(proxyDictionary.Values.First().Name, Is.SameAs("No.0")); Assert.That(proxyDictionary.Values.First(), Is.InstanceOf <FooProxy>()); var toAdd = new Foo { Name = "No.-1", Age = -1 }; proxyDictionary.Add(toAdd.Age, toAdd); Assert.That(proxyDictionary[toAdd.Age].Name, Is.EqualTo(toAdd.Name)); Assert.That(proxyDictionary[toAdd.Age], Is.InstanceOf <FooProxy>()); }
[Test] public void CanCreateProxy() { var o = NewValueObject(); var mock = NotifyPropertyChangeFactory.GetTarget(o); mock.ComponentProperty = MockRepository.GenerateStub <IValueComponent>(); var x = o.ComponentProperty; }
public void NestedCollectionPropertyHandlesProxyAsExpected() { var target = _target; var proxy = NotifyPropertyChangeFactory.GetProxy(target); Assert.That(proxy.FooListDictionary["A"][0].Name, Is.EqualTo("No.5")); Assert.That(proxy.FooListDictionary["A"][0], Is.InstanceOf <FooProxy>()); }
[Test] public void ListPropertyHandlesProxyAsExpected() { var proxy = NotifyPropertyChangeFactory.GetProxy(_target); Assert.That(proxy.FooList, Is.Not.SameAs(_target.FooList)); Assert.That(proxy.FooList[0].Name, Is.SameAs("No.3")); Assert.That(proxy.FooList[0], Is.InstanceOf <FooProxy>()); Assert.That(proxy.FooList.First().Name, Is.SameAs("No.3")); Assert.That(proxy.FooList.First(), Is.InstanceOf <FooProxy>()); }
public IValueComponent DeepOutRef(IValueComponent a, out IValueComponent o, ref IValueObject r) { IValueComponent oTarget; IValueObject rTarget = NotifyPropertyChangeFactory.GetTarget(r); var result = _target.DeepOutRef(NotifyPropertyChangeFactory.GetTarget(a), out oTarget, ref rTarget); o = NotifyPropertyChangeFactory.GetProxy(oTarget); r = NotifyPropertyChangeFactory.GetProxy(rTarget); return(NotifyPropertyChangeFactory.GetProxy(result)); }
public void GetProxyReturnsDifferenceInstancesForDifferentButEqualTargets() { IFoo target1 = new Foo(); IFoo target2 = new Foo(); var proxy1 = NotifyPropertyChangeFactory.GetProxy(target1); var proxy2 = NotifyPropertyChangeFactory.GetProxy(target2); Assert.That(target2, Is.EqualTo(target1)); Assert.That(proxy2, Is.Not.EqualTo(proxy1)); }
public IValueComponent this[IValueComponent a, IValueComponent o, IValueObject r] { get { return(NotifyPropertyChangeFactory.GetProxy(_target[NotifyPropertyChangeFactory.GetTarget(a), NotifyPropertyChangeFactory.GetTarget(o), NotifyPropertyChangeFactory.GetTarget(r)])); } set { _target[NotifyPropertyChangeFactory.GetTarget(a), NotifyPropertyChangeFactory.GetTarget(o), NotifyPropertyChangeFactory.GetTarget(r)] = NotifyPropertyChangeFactory.GetTarget(value); } }
[Test] public void GetProxyReturnsSameInstanceForSameTarget() { IFoo target1 = new Foo(); var proxy1 = NotifyPropertyChangeFactory.GetProxy(target1); target1.Name = "New Name"; target1.Age = 100; var proxy2 = NotifyPropertyChangeFactory.GetProxy(target1); Assert.That(proxy2, Is.SameAs(proxy1)); }
[Test] public void CanCreateProxy() { var all = new Dictionary <MemberInfo, int>(); var type = typeof(ISon); var i = type.GetInterfaces(); foreach (var parent in i) { GetMemembers(parent, all); } GetMemembers(type, all); ISon mock = MockRepository.GenerateStub <ISon>(); var son = NotifyPropertyChangeFactory.GetProxy(mock); mock.Name = "Son"; mock.Stub(m => m.Job).Return("NoJob"); Assert.That(son.Name, Is.EqualTo(mock.Name)); Assert.That(son.Age, Is.EqualTo(10)); Assert.That(son.Job, Is.EqualTo("NoJob")); Assert.That(((IFather)son).Job, Is.EqualTo("NoJob")); Assert.That(((IMother)son).Job, Is.EqualTo("NoJob")); Factory.SaveAssembly(); }
protected override IValueObject NewValueObject() { var mock = MockRepository.GenerateStub <IValueObject>(); return(NotifyPropertyChangeFactory.NewProxy(mock)); }
[TestFixtureSetUp] public void TestFixtureSetUp() { NotifyPropertyChangeFactory.SetMarkingAttribute <BvoAttribute>(b => b.NotifyPropertyChangedBase); NotifyPropertyChangeFactory.SetBaseType <ChangeTrackerBase>("FirePropertyChanged"); }
protected sealed override TValue ReverseValue(TValue value) { return(NotifyPropertyChangeFactory.GetTarget(value)); }
public IValueComponent DeepMethod(IValueComponent component) { return (NotifyPropertyChangeFactory.GetProxy( _target.DeepMethod(NotifyPropertyChangeFactory.GetTarget(component)))); }
protected sealed override TValue TransformValue(TValue value) { return(NotifyPropertyChangeFactory.GetProxy(value)); }
protected override bool TryReverse(T target, out T source) { source = NotifyPropertyChangeFactory.GetTarget(target); return(true); }
protected override T Transform(T source) { return(NotifyPropertyChangeFactory.GetProxy(source)); }
protected override T Reverse(T target) { return(NotifyPropertyChangeFactory.GetTarget(target)); }