コード例 #1
0
        public void SafeObject_PropertyChangedAfterVerifiedChanges_ThrowsMemoryInjectionException()
        {
            // Arrange
            SafeOrbitCore.Current.AlertChannel = InjectionAlertChannel.ThrowException;
            const string expected = "PropertyData";
            var          sut      = new SafeObject <TestClass>();

            sut.ApplyChanges(
                obj => obj.Class = new TestClass {
                Property = expected
            }
                );
            sut.Object.Class.Property = $"{expected}_changed";

            // Act
            void CallGetter() => _ = sut.Object;

            // Assert
            Assert.Throws <MemoryInjectionException>(CallGetter);
        }
コード例 #2
0
        public void SafeObject_Object_WhenPropertyChangedAfterVerifiedChanges_throwsMemoryInjectionException()
        {
            //arrange
            var expected = "PropertyData";
            var sut      = new SafeObject <TestClass>();

            sut.ApplyChanges(
                obj => obj.Class = new TestClass {
                Property = expected
            }
                );
            sut.Object.Class.Property = $"{expected}_changed";
            //act
            TestDelegate callingGetter = () =>
            {
                var temp = sut.Object;
            };

            //assert
            Assert.That(callingGetter, Throws.TypeOf <MemoryInjectionException>());
        }
コード例 #3
0
        public void SafeObject_PropertyChangedAfterVerifiedChanges_RaisesLibraryInjectedEvent()
        {
            // Arrange
            var events = new Collection <IInjectionMessage>();

            SafeOrbitCore.Current.AlertChannel     = InjectionAlertChannel.RaiseEvent;
            SafeOrbitCore.Current.LibraryInjected += (sender, args) => events.Add(args);
            const string expected = "PropertyData";
            var          sut      = new SafeObject <TestClass>();

            sut.ApplyChanges(
                obj => obj.Class = new TestClass {
                Property = expected
            }
                );
            sut.Object.Class.Property = $"{expected}_changed";

            // Act
            _ = sut.Object;

            // Assert
            Assert.AreEqual(1, events.Count);
        }