public void Asserts_The_Message(IInjectionMessage message)
        {
            var sut    = GetSut();
            var action = new TestDelegate(() => sut.Alert(message));

            Alert_Sut_Alerts_Message(action, message);
        }
 public MemoryInjectionException(IInjectionMessage message)
     : base(message.ToString())
 {
     InjectionType  = message.InjectionType;
     InjectedObject = message.InjectedObject;
     DetectionTime  = message.InjectionDetectionTime;
 }
Пример #3
0
 public override void Alert_Sut_Alerts_Message(TestDelegate alertingMessage, IInjectionMessage message)
 {
     Assert.That(alertingMessage,
                 Throws.TypeOf <MemoryInjectionException>()
                 .And.With.Property(nameof(MemoryInjectionException.InjectionType)).EqualTo(message.InjectionType)
                 .And.With.Property(nameof(MemoryInjectionException.DetectionTime)).EqualTo(message.InjectionDetectionTime)
                 .And.With.Property(nameof(MemoryInjectionException.InjectedObject)).EqualTo(message.InjectedObject)
                 );
 }
Пример #4
0
 public bool Equals(IInjectionMessage other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     return(this.InjectionType.Equals(other.InjectionType) &&
            (this.InjectedObject?.Equals(other.InjectedObject) ?? false) &&
            this.InjectionDetectionTime.Equals(other.InjectionDetectionTime));
 }
Пример #5
0
        public void Alert_ChannelIsDebugWrite_InvokesRaiseEventAlerter(IInjectionMessage info)
        {
            //arrange
            const InjectionAlertChannel channel = InjectionAlertChannel.DebugWrite;
            var alerterMock = new Mock <IAlerter>();
            var sut         = GetSut(debugWriteAlerter: alerterMock.Object);

            //act
            sut.Alert(info, channel);
            //assert
            alerterMock.Verify(a => a.Alert(It.Is <IInjectionMessage>((value) => info.Equals(value))));
        }
Пример #6
0
        public void Alert_ChannelIsThrowException_InvokesRaiseEventAlerter(IInjectionMessage info)
        {
            // Arrange
            const InjectionAlertChannel channel = InjectionAlertChannel.ThrowException;
            var alerterMock = new Mock <IAlerter>();
            var sut         = GetSut(throwExceptionAlerter: alerterMock.Object);

            // Act
            sut.Alert(info, channel);

            // Assert
            alerterMock.Verify(a => a.Alert(It.Is <IInjectionMessage>(value => info.Equals(value))));
        }
Пример #7
0
 public override void Alert_Sut_Alerts_Message(TestDelegate alertingMessage, IInjectionMessage message)
 {
     base.IgnoreTest();
 }
Пример #8
0
 /// <exception cref="MemoryInjectionException">
 ///     <p>
 ///         The state of the object has been changed after last validation.
 ///         <seealso cref="InjectionType.VariableInjection" />
 ///     </p>
 ///     <p>
 ///         The code of the object has been changed after last validation.
 ///         <seealso cref="InjectionType.CodeInjection" />
 ///     </p>
 ///     <p>
 ///         Both state and the code code of the object has been changed after last validation.
 ///         <seealso cref="InjectionType.CodeAndVariableInjection" />
 ///     </p>
 /// </exception>
 public void Alert(IInjectionMessage info)
 {
     throw new MemoryInjectionException(info);
 }
Пример #9
0
 public void Alert(IInjectionMessage info)
 {
     Debug.Fail(info.ToString());
 }
Пример #10
0
 public void Alert(IInjectionMessage info)
 {
     Debug.Fail($"An object has been infected by {info.InjectionType} at {info.InjectionDetectionTime.ToLocalTime()}");
 }
Пример #11
0
        public void Alert(IInjectionMessage info, InjectionAlertChannel channel)
        {
            var alerter = _alerterFactory.Get(channel);

            alerter.Alert(info);
        }
Пример #12
0
 public abstract void Alert_Sut_Alerts_Message(TestDelegate alertingMessage, IInjectionMessage message);
Пример #13
0
 public void Alert(IInjectionMessage info)
 {
     _safeOrbitCore.AlertInjection(info.InjectedObject, info);
 }
Пример #14
0
 /// <exception cref="MemoryInjectionException">
 ///     <p>
 ///         The state of the object has been changed after last validation.
 ///         <seealso cref="InjectionType.VariableInjection" />
 ///     </p>
 ///     <p>
 ///         The code of the object has been changed after last validation.
 ///         <seealso cref="InjectionType.CodeInjection" />
 ///     </p>
 ///     <p>
 ///         Both state and the code code of the object has been changed after last validation.
 ///         <seealso cref="InjectionType.CodeAndVariableInjection" />
 ///     </p>
 /// </exception>
 public void Alert(IInjectionMessage info)
 {
     throw new MemoryInjectionException(info.InjectionType, info.InjectedObject, info.InjectionDetectionTime);
 }
 public override void Alert_Sut_Alerts_Message(TestDelegate alertingMessage, IInjectionMessage message)
 {
     _safeOrbitCoreMock.Invocations.Clear();
     alertingMessage.Invoke();
     _safeOrbitCoreMock.Verify(core => core.AlertInjection(message.InjectedObject, message));
 }
Пример #16
0
        /// <summary>
        ///     Internal method to alert an injection. It's virtual for testability.
        /// </summary>
        /// <param name="object">The injected object.</param>
        /// <param name="info">The information.</param>
        internal virtual void AlertInjection(object @object, IInjectionMessage info)
        {
            var localCopy = LibraryInjected;

            localCopy?.Invoke(@object, info);
        }