public void InterfaceIsImplementedAndNoDelegateIsDefined_InterfaceImplementationIsUsed() { var overridingActions = new ExplicitlyDefinedObjectActions<InterfaceRealizingEntity>(); var actions = new ObjectActionsBasedOnDelegateOrInterface<InterfaceRealizingEntity>(overridingActions,_notifierMock.Object); var bigAnswer = actions.IsValid(_bigInterfaceRealizingObject); var smallAnswer = actions.IsValid(_smallInterfaceRealizingObject); actions.Ping(_bigInterfaceRealizingObject); Assert.That(bigAnswer, Is.True); Assert.That(smallAnswer, Is.False); Assert.That(_bigInterfaceRealizingObject.PingImplementationWasCalled, Is.True); }
public void BothInterfaceImplementationAndDelegateAreDefined_DelegateIsUsed() { var overridingActions = new ExplicitlyDefinedObjectActions<InterfaceRealizingEntity> { IsValidDelegate = x => x.Value < 4, PingDelegate = _standalonePingImplementation, }; var actions = new ObjectActionsBasedOnDelegateOrInterface<InterfaceRealizingEntity>(overridingActions, _notifierMock.Object); var bigAnswer = actions.IsValid(_bigInterfaceRealizingObject); var smallAnswer = actions.IsValid(_smallInterfaceRealizingObject); actions.Ping(_bigInterfaceRealizingObject); Assert.That(bigAnswer, Is.False); Assert.That(smallAnswer, Is.True); Assert.That(_bigInterfaceRealizingObject.PingImplementationWasCalled, Is.False); Assert.That(_standalonePingWasCalled, Is.True); }
public void NeitherInterfaceImplementationNorDelegate_EmptyMethodRealizationIsUsed() { var overridingActions = new ExplicitlyDefinedObjectActions<AutonomousEntity>(); var actions = new ObjectActionsBasedOnDelegateOrInterface<AutonomousEntity>(overridingActions, _notifierMock.Object); var bigAnswer = actions.IsValid(_bigAutonomousObject); var smallAnswer = actions.IsValid(_smallAutonomousObject); actions.Ping(_bigAutonomousObject); Assert.That(bigAnswer, Is.True); Assert.That(smallAnswer, Is.True); Assert.That(_standalonePingWasCalled, Is.False); }