public void WinformsCreatesObservableForPropertyWorksForThirdPartyControls() { var input = new AThirdPartyNamespace.ThirdPartyControl(); var fixture = new WinformsCreatesObservableForProperty(); Assert.NotEqual(0, fixture.GetAffinityForObject(typeof(AThirdPartyNamespace.ThirdPartyControl), "Value")); Expression <Func <AThirdPartyNamespace.ThirdPartyControl, string?> > expression = x => x.Value; var propertyName = expression.Body.GetMemberInfo()?.Name; if (propertyName is null) { throw new InvalidOperationException("propertyName should not be null."); } var dispose = fixture.GetNotificationForProperty(input, expression.Body, propertyName).ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var output).Subscribe(); Assert.Equal(0, output.Count); input.Value = "Foo"; Assert.Equal(1, output.Count); Assert.Equal(input, output[0].Sender); Assert.Equal("Value", output[0].GetPropertyName()); dispose.Dispose(); input.Value = "Bar"; Assert.Equal(1, output.Count); }
public void WinformsCreatesObservableForPropertyWorksForThirdPartyControls() { var input = new AThirdPartyNamespace.ThirdPartyControl(); var fixture = new WinformsCreatesObservableForProperty(); Assert.NotEqual(0, fixture.GetAffinityForObject(typeof(AThirdPartyNamespace.ThirdPartyControl), "Value")); Expression <Func <AThirdPartyNamespace.ThirdPartyControl, string> > expression = x => x.Value; var output = fixture.GetNotificationForProperty(input, expression.Body).CreateCollection(scheduler: ImmediateScheduler.Instance); Assert.Equal(0, output.Count); input.Value = "Foo"; Assert.Equal(1, output.Count); Assert.Equal(input, output[0].Sender); Assert.Equal("Value", output[0].GetPropertyName()); output.Dispose(); input.Value = "Bar"; Assert.Equal(1, output.Count); }
public void WinformsCreatesObservableForPropertyWorksForThirdPartyControls() { var input = new AThirdPartyNamespace.ThirdPartyControl(); var fixture = new WinformsCreatesObservableForProperty(); Assert.NotEqual(0, fixture.GetAffinityForObject(typeof(AThirdPartyNamespace.ThirdPartyControl), "Value")); var output = fixture.GetNotificationForProperty(input, "Value").CreateCollection(); Assert.Equal(0, output.Count); input.Value = "Foo"; Assert.Equal(1, output.Count); Assert.Equal(input, output[0].Sender); Assert.Equal("Value", output[0].PropertyName); Assert.Equal("Foo", output[0].Value); output.Dispose(); input.Value = "Bar"; Assert.Equal(1, output.Count); }