ReactiveParameterObservers_ReplayParameterObserver_OwnerExpression_ComplexProperty_Value_Integer_AutoActivate_True4() { var value = (int?)null; var count = 0; var notifyPropertyChangedTestObject = new ParameterTestObject(); using var observer1 = ReplayObserverFactory.Observes( notifyPropertyChangedTestObject, o => o.ComplexProperty.Value.IntProperty.Value); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.IntParameter.Value = 1"); notifyPropertyChangedTestObject.IntParameter.Value = 1; TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value = new ComplexParameterType()"); notifyPropertyChangedTestObject.ComplexProperty.Value = new ComplexParameterType(); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 1"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 1; TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 2"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 2; Assert.AreEqual(null, value); Assert.AreEqual(0, count); TestContext.Out.WriteLine($"observer1.Subscribe"); using var d = observer1.Subscribe( v => { count++; value = v; TestContext.Out.WriteLine($"Count: {count}, Value " + (v.HasValue ? v.ToString() : "null")); }); Assert.AreEqual(2, value); Assert.AreEqual(3, count); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 3"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 3; Assert.AreEqual(3, value); Assert.AreEqual(4, count); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value = null"); notifyPropertyChangedTestObject.ComplexProperty.Value = null; Assert.AreEqual(null, value); }
ReactiveParameterObservers_ReplayParameterObserver_Timspan2_OwnerExpression_ComplexProperty_Value_Integer_AutoActivate_True4() { var value = (int?)null; var count = 0; var notifyPropertyChangedTestObject = new ParameterTestObject(); using var observer1 = ReplayObserverFactory.Observes( notifyPropertyChangedTestObject, o => o.ComplexProperty.Value.IntProperty.Value, TimeSpan.FromMilliseconds(150)); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.IntParameter.Value = 1"); notifyPropertyChangedTestObject.IntParameter.Value = 1; Thread.Sleep(50); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value = new ComplexParameterType()"); notifyPropertyChangedTestObject.ComplexProperty.Value = new ComplexParameterType(); Thread.Sleep(50); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 1"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 1; Thread.Sleep(50); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 2"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 2; Thread.Sleep(50); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 3"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 3; Thread.Sleep(50); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 4"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 4; Assert.AreEqual(null, value); Assert.AreEqual(0, count); TestContext.Out.WriteLine($"observer1.Subscribe"); using var d1 = observer1.Subscribe( v => { count++; value = v; TestContext.Out.WriteLine($"Count: {count}, Value " + (v.HasValue ? v.ToString() : "null")); }); Assert.AreEqual(4, value); Assert.AreEqual(3, count); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 5"); notifyPropertyChangedTestObject.ComplexProperty.Value.IntProperty.Value = 5; Assert.AreEqual(5, value); Assert.AreEqual(4, count); TestContext.Out.WriteLine($"notifyPropertyChangedTestObject.ComplexProperty.Value = null"); notifyPropertyChangedTestObject.ComplexProperty.Value = null; Assert.AreEqual(5, count); Assert.AreEqual(null, value); TestContext.Out.WriteLine($"observer1.Unubscribe"); observer1.Unsubscribe(); TestContext.Out.WriteLine($"observer1.Subscribe"); using var d2 = observer1.Subscribe(v => { count++; value = v; TestContext.Out.WriteLine($"Count: {count}, Value " + (v.HasValue ? v.ToString() : "null")); }); Thread.Sleep(100); Assert.AreEqual(10, count); Assert.AreEqual(null, value); }