public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                balanceAggregate.RemoveSource(adjustBindable);
                break;

            case AdjustableProperty.Frequency:
                frequencyAggregate.RemoveSource(adjustBindable);
                break;

            case AdjustableProperty.Volume:
                volumeAggregate.RemoveSource(adjustBindable);
                break;
            }
        }
        public void TestSourceRemoved()
        {
            var aggregate = new AggregateBindable <double>((a, b) => a * b, new Bindable <double>(1));

            var bindable1 = new BindableDouble(0.5);

            aggregate.AddSource(bindable1);

            var bindable2 = new BindableDouble(0.5);

            aggregate.AddSource(bindable2);

            Assert.AreEqual(0.25, aggregate.Result.Value);

            aggregate.RemoveSource(bindable1);
            Assert.AreEqual(0.5, aggregate.Result.Value);

            aggregate.RemoveSource(bindable2);
            Assert.AreEqual(1, aggregate.Result.Value);
        }
        public void TestValueChangedFirings()
        {
            int aggregateResultFireCount = 0, bindable1FireCount = 0, bindable2FireCount = 0;

            var aggregate = new AggregateBindable <double>((a, b) => a * b, new Bindable <double>(1));

            aggregate.Result.BindValueChanged(_ => Interlocked.Increment(ref aggregateResultFireCount));

            Assert.AreEqual(0, aggregateResultFireCount);

            var bindable1 = new BindableDouble(0.5);

            bindable1.BindValueChanged(_ => Interlocked.Increment(ref bindable1FireCount));
            aggregate.AddSource(bindable1);

            Assert.AreEqual(1, aggregateResultFireCount);

            var bindable2 = new BindableDouble(0.5);

            bindable2.BindValueChanged(_ => Interlocked.Increment(ref bindable2FireCount));
            aggregate.AddSource(bindable2);

            Assert.AreEqual(2, aggregateResultFireCount);

            bindable1.Value = 0.25;

            Assert.AreEqual(3, aggregateResultFireCount);
            Assert.AreEqual(1, bindable1FireCount);
            Assert.AreEqual(0, bindable2FireCount);

            bindable2.Value = 0.25;

            Assert.AreEqual(4, aggregateResultFireCount);
            Assert.AreEqual(1, bindable1FireCount);
            Assert.AreEqual(1, bindable2FireCount);

            aggregate.RemoveSource(bindable2);

            Assert.AreEqual(5, aggregateResultFireCount);
            Assert.AreEqual(1, bindable1FireCount);
            Assert.AreEqual(1, bindable2FireCount);

            bindable2.Value = 0.5;

            Assert.AreEqual(5, aggregateResultFireCount);
            Assert.AreEqual(1, bindable1FireCount);
            Assert.AreEqual(2, bindable2FireCount);
        }