public void OnPropertyChanged_RaisesEventWithMultipleParameters()
        {
            var sut = new TestDisposableClass();
            sut.ShouldNotifyOn(m => m.ResourcesChanged).When(m => m.RaiseWithMultipleParameters = true);

            sut = new TestDisposableClass();
            sut.ShouldNotifyOn(m => m.RaiseWithMultipleParameters).When(m => m.RaiseWithMultipleParameters = true);
        }
        public void Test_EqualsOperator_OneNullObject()
        {
            var item1 = new TestDisposableClass();
            TestDisposableClass item2 = null;

            Assert.IsFalse(item1 == item2);
            Assert.IsTrue(item1 != item2);
        }
        public void Test_EqualsOperator_Equals(bool expected)
        {
            var item1 = new TestDisposableClass(expected,12345);
            var item2 = new TestDisposableClass(expected,12345);

            Assert.AreEqual(expected,(item1 == item2));
            Assert.AreEqual(!expected, (item1 != item2));
        }
Exemple #4
0
 private static TestDisposableClass GetTestObject(IDisposable managed)
 {
     var pointer = new IntPtr(GetRandom.Int(25000, 65535));
     var sut = new TestDisposableClass(managed, pointer);
     Assert.IsFalse(sut.IsDisposed);
     Assert.IsNotNull(sut.ManagedResource);
     Assert.AreNotEqual(IntPtr.Zero, sut.ManagedResource);
     return sut;
 }
 public void SetNotifyingProperty_CanSetNewValueAndNotify()
 {
     var sut = new TestDisposableClass();
     IDisposable expected = null;
     sut.PropertyChanged += (sender, e) =>
     {
         var args = e as ExtendedPropertyChangedEventArgs<IDisposable>;
         Assert.IsNotNull(args);
     };
     sut.ShouldNotifyOn(m => m.ManagedResource).When(m => m.ManagedResource = expected);
     Assert.AreEqual(expected, sut.ManagedResource, "Property did not change.");
 }
        public void PropertyChanged_EventCanBeHookedAndUnhooked()
        {
            var sut = new TestDisposableClass();

            PropertyChangedEventHandler hookup = (x, y) => Test_Parameters(x, y, sut.SetNotifyingPropertyTester);

            Assert.DoesNotThrow(() => sut.PropertyChanged += hookup);
            Assert.IsTrue(sut.IsSubscribedToNotification(hookup));

            Assert.DoesNotThrow(() => sut.PropertyChanged -= hookup);
            Assert.IsFalse(sut.IsSubscribedToNotification(hookup));
        }
 public void SetNotifyingProperty_DoesNotNotifyWhenGivenTheSameValue()
 {
     var sut = new TestDisposableClass();
     sut.ShouldNotNotifyOn(m => m.SetNotifyingPropertyTester)
         .When(m => m.SetNotifyingPropertyTester = sut.SetNotifyingPropertyTester);
 }
        public void SetNotifyingProperty_CanSetNewValueAndNotifyOnMultiple()
        {
            var hits = 0;
            var sut = new TestDisposableClass();
            sut.PropertyChanged += (sender, e) => { hits++; };

            sut.RaiseWithMultipleExpressions = true;

            Assert.AreEqual(3, hits);
        }
 public void OnPropertyChanged_RaisesEventWithParameterName()
 {
     var sut = new TestDisposableClass();
     Assert.IsFalse(sut.RaiseWithParameterName);
     sut.ShouldNotifyOn(m => m.ResourcesChanged).When(m => m.RaiseWithParameterName = true);
 }
 public void SetNotifyingProperty_NotifiesWhenGivenANewValue()
 {
     var sut = new TestDisposableClass();
     sut.PropertyChanged += (x, y) => Test_Parameters(x, y, sut.SetNotifyingPropertyTester);
     sut.ShouldNotifyOn(m => m.SetNotifyingPropertyTester).When(m => m.SetNotifyingPropertyTester = true);
 }
 public void Test_EqualsOperator_ReferenceEquals()
 {
     var item1 = new TestDisposableClass(true, 12345);
     Assert.IsTrue(item1 == item1);
     Assert.IsFalse(item1 != item1);
 }