Ejemplo n.º 1
0
        public void InitialValue()
        {
            var stored      = new StoredProperty <int>(1);
            var passthrough = new PassthroughProperty <int>(stored);

            passthrough.Value.Should().Be(1);
        }
Ejemplo n.º 2
0
 private void passthroughPropertySynchronizationContext()
 {
     var backing     = new StoredProperty <double>(3.0);
     var passthrough = new PassthroughProperty <double>(backing)
     {
         EventSynchronizationContext = SynchronizationContext.Current
     };
 }
Ejemplo n.º 3
0
        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
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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;
        }