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

            Assert.IsFalse(item1 == item2);
            Assert.IsTrue(item1 != item2);
        }
Exemplo 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));
        }
Exemplo 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;
 }
Exemplo 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.");
 }
Exemplo 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));
        }
Exemplo n.º 7
0
 public void SetNotifyingProperty_DoesNotNotifyWhenGivenTheSameValue()
 {
     var sut = new TestDisposableClass();
     sut.ShouldNotNotifyOn(m => m.SetNotifyingPropertyTester)
         .When(m => m.SetNotifyingPropertyTester = sut.SetNotifyingPropertyTester);
 }
Exemplo 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);
        }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo n.º 11
0
 public void Test_EqualsOperator_ReferenceEquals()
 {
     var item1 = new TestDisposableClass(true, 12345);
     Assert.IsTrue(item1 == item1);
     Assert.IsFalse(item1 != item1);
 }