public void FindDeserializationMethodsWithCache_Caching() { SerializationEventRaiser eventRaiser = new SerializationEventRaiser(); List <MethodInfo> methods = (List <MethodInfo>)PrivateInvoke.InvokeNonPublicMethod( eventRaiser, "FindDeserializationMethodsWithCache", typeof(ClassWithDeserializationEvents), typeof(OnDeserializedAttribute)); Assert.That(methods, Is.Not.Null); List <MethodInfo> methods2 = (List <MethodInfo>)PrivateInvoke.InvokeNonPublicMethod( eventRaiser, "FindDeserializationMethodsWithCache", typeof(ClassWithDeserializationEvents), typeof(OnDeserializedAttribute)); Assert.That(methods2, Is.SameAs(methods)); }
public void RaiseOnDeserialization() { SerializationEventRaiser eventRaiser = new SerializationEventRaiser(); ClassWithDeserializationEvents instance = new ClassWithDeserializationEvents(); Assert.That(instance.OnBaseDeserializingCalled, Is.False); Assert.That(instance.OnBaseDeserializedCalled, Is.False); Assert.That(instance.OnDeserializingCalled, Is.False); Assert.That(instance.OnDeserializedCalled, Is.False); Assert.That(instance.OnDeserializationCalled, Is.False); eventRaiser.RaiseDeserializationEvent(instance, null); Assert.That(instance.OnBaseDeserializingCalled, Is.False); Assert.That(instance.OnBaseDeserializedCalled, Is.False); Assert.That(instance.OnDeserializingCalled, Is.False); Assert.That(instance.OnDeserializedCalled, Is.False); Assert.That(instance.OnDeserializationCalled, Is.True); }
public void InvokeAttributedMethod_OnDeserializing() { SerializationEventRaiser eventRaiser = new SerializationEventRaiser(); ClassWithDeserializationEvents instance = new ClassWithDeserializationEvents(); Assert.That(instance.OnBaseDeserializingCalled, Is.False); Assert.That(instance.OnBaseDeserializedCalled, Is.False); Assert.That(instance.OnDeserializingCalled, Is.False); Assert.That(instance.OnDeserializedCalled, Is.False); Assert.That(instance.OnDeserializationCalled, Is.False); eventRaiser.InvokeAttributedMethod(instance, typeof(OnDeserializingAttribute), new StreamingContext()); Assert.That(instance.OnBaseDeserializingCalled, Is.True); Assert.That(instance.OnBaseDeserializedCalled, Is.False); Assert.That(instance.OnDeserializingCalled, Is.True); Assert.That(instance.OnDeserializedCalled, Is.False); Assert.That(instance.OnDeserializationCalled, Is.False); }
public void InvokeAttributedMethod_UsesCache() { ClassWithDeserializationEvents instance = new ClassWithDeserializationEvents(); StreamingContext context = new StreamingContext(); MockRepository repository = new MockRepository(); SerializationEventRaiser eventRaiserMock = repository.StrictMock <SerializationEventRaiser>(); eventRaiserMock.InvokeAttributedMethod(instance, typeof(OnDeserializedAttribute), context); LastCall.CallOriginalMethod(OriginalCallOptions.CreateExpectation); Expect.Call(PrivateInvoke.InvokeNonPublicMethod(eventRaiserMock, "FindDeserializationMethodsWithCache", typeof(ClassWithDeserializationEvents), typeof(OnDeserializedAttribute))) .Return(new List <MethodInfo>()); repository.ReplayAll(); eventRaiserMock.InvokeAttributedMethod(instance, typeof(OnDeserializedAttribute), context); repository.VerifyAll(); }