public void InitialValue() { var stored = new StoredProperty <int>(1); var passthrough = new PassthroughProperty <int>(stored); passthrough.Value.Should().Be(1); }
private void passthroughPropertySynchronizationContext() { var backing = new StoredProperty <double>(3.0); var passthrough = new PassthroughProperty <double>(backing) { EventSynchronizationContext = SynchronizationContext.Current }; }
private void passthroughProperty() { var backing = new StoredProperty <double>(3.0); var passthrough = new PassthroughProperty <double>(backing); Console.WriteLine($"{passthrough.Value} liters"); // 3 liters backing.Value = 5.0; Console.WriteLine($"{passthrough.Value} liters"); // 5 liters }
public void ValueIsUpdated() { var stored = new StoredProperty <int>(1); var passthrough = new PassthroughProperty <int>(stored); stored.Value.Should().Be(1); stored.Value = 2; passthrough.Value.Should().Be(2); }
public void UsesSynchronizationContextIfConfigured() { var stored = new StoredProperty <int>(1); var passthrough = new PassthroughProperty <int>(stored); int eventsTriggeredCount = 0; var synchronizationContext = new MySyncContext(); passthrough.EventSynchronizationContext = synchronizationContext; passthrough.PropertyChanged += (sender, args) => { eventsTriggeredCount++; }; synchronizationContext.PostCount.Should().Be(0); synchronizationContext.SendCount.Should().Be(0); stored.Value = 2; eventsTriggeredCount.Should().Be(1); synchronizationContext.SendCount.Should().Be(1); synchronizationContext.PostCount.Should().Be(0); passthrough.EventSynchronizationContext.Should().BeSameAs(synchronizationContext); }
public void EventsAreTriggered() { var stored = new StoredProperty <int>(1); var passthrough = new PassthroughProperty <int>(stored); stored.Value.Should().Be(1); int eventsTriggeredCount = 0; passthrough.PropertyChanged += (sender, args) => { eventsTriggeredCount++; passthrough.Value.Should().Be(2); }; passthrough.PropertyChanged += OnPropertyChanged; stored.Value = 2; eventsTriggeredCount.Should().Be(1); onPropertyChangedCallCount.Should().Be(1); passthrough.PropertyChanged -= OnPropertyChanged; }