Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void Test_EqualsOperator_OneNullObject()
        {
            var item1 = new TestDisposableClass();
            TestDisposableClass item2 = null;

            Assert.IsFalse(item1 == item2);
            Assert.IsTrue(item1 != item2);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 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;
 }
Esempio n. 5
0
 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.");
 }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
 public void SetNotifyingProperty_DoesNotNotifyWhenGivenTheSameValue()
 {
     var sut = new TestDisposableClass();
     sut.ShouldNotNotifyOn(m => m.SetNotifyingPropertyTester)
         .When(m => m.SetNotifyingPropertyTester = sut.SetNotifyingPropertyTester);
 }
Esempio n. 8
0
        public void SetNotifyingProperty_CanSetNewValueAndNotifyOnMultiple()
        {
            var hits = 0;
            var sut = new TestDisposableClass();
            sut.PropertyChanged += (sender, e) => { hits++; };

            sut.RaiseWithMultipleExpressions = true;

            Assert.AreEqual(3, hits);
        }
Esempio n. 9
0
 public void OnPropertyChanged_RaisesEventWithParameterName()
 {
     var sut = new TestDisposableClass();
     Assert.IsFalse(sut.RaiseWithParameterName);
     sut.ShouldNotifyOn(m => m.ResourcesChanged).When(m => m.RaiseWithParameterName = true);
 }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
 public void Test_EqualsOperator_ReferenceEquals()
 {
     var item1 = new TestDisposableClass(true, 12345);
     Assert.IsTrue(item1 == item1);
     Assert.IsFalse(item1 != item1);
 }