コード例 #1
0
        public void IsNotified_OnSizeChanged()
        {
            var sizeStrategy = new MySizeStrategy();
            var service      = new BreakpointListener(sizeStrategy);

            Assert.AreEqual(-1, service.CurrentWidth);

            sizeStrategy.RaiseSizeChanged(100);

            Assert.AreEqual(100, service.CurrentWidth);
        }
コード例 #2
0
        public void ActiveChange()
        {
            var sizeStrategy = new MySizeStrategy();
            var service      = new BreakpointListener(sizeStrategy);

            var breakpoints = new List <double> {
                0, 100, 200, 300
            };

            Assert.AreEqual(-1, service.CurrentBreakpoint);

            sizeStrategy.RaiseSizeChanged(10);

            Assert.AreEqual(-1, service.CurrentBreakpoint);
            Assert.AreEqual(10, service.CurrentWidth);

            service.AddBreakpoint(0);
            service.AddBreakpoint(100);
            service.AddBreakpoint(200);
            service.AddBreakpoint(300);

            sizeStrategy.RaiseSizeChanged(10);

            Assert.AreEqual(0, service.CurrentBreakpoint);
            Assert.AreEqual(10, service.CurrentWidth);

            sizeStrategy.RaiseSizeChanged(150);

            Assert.AreEqual(100, service.CurrentBreakpoint);
            Assert.AreEqual(150, service.CurrentWidth);

            sizeStrategy.RaiseSizeChanged(250);

            Assert.AreEqual(200, service.CurrentBreakpoint);
            Assert.AreEqual(250, service.CurrentWidth);

            sizeStrategy.RaiseSizeChanged(350);

            Assert.AreEqual(300, service.CurrentBreakpoint);
            Assert.AreEqual(350, service.CurrentWidth);
        }
コード例 #3
0
        public void TestIsNotified()
        {
            var sizeStrategy = new MySizeStrategy();
            var control      = new BreakpointBinder(sizeStrategy);

            control.AddBreakpointWithBindings(0, AdaptiveContainer.Create().Set("TitleFontSize", "20").Set("TitleColor", "red").Get())
            .AddBreakpointWithBindings(500, AdaptiveContainer.Create().Set("TitleFontSize", "50").Set("TitleColor", "blue").Get())
            .AddBreakpointWithBindings(1000, AdaptiveContainer.Create().Set("TitleFontSize", "100").Set("TitleColor", "green").Get());

            Assert.IsNull(control.Active);

            sizeStrategy.RaiseSizeChanged(600);

            Assert.AreEqual("50", control.Active["TitleFontSize"]);
            Assert.AreEqual("blue", control.Active["TitleColor"]);
        }
コード例 #4
0
        public async Task RaiseBreakpointChanged_DeferredOnAdd()
        {
            var sizeStrategy = new MySizeStrategy();
            var service      = new BreakpointListener(sizeStrategy);

            int count = 0;

            service.BreakpointChanged += (s, e) =>
            {
                count++;
            };

            sizeStrategy.RaiseSizeChanged(10);

            await Task.Delay(3000);

            service.AddBreakpoint(0);

            Assert.AreEqual(1, count);
        }
コード例 #5
0
        public async Task RaiseBreakpointBinderChanged_DeferredOnSubscribe()
        {
            var sizeStrategy = new MySizeStrategy();
            var control      = new BreakpointBinder(sizeStrategy);

            int count = 0;

            control.AddBreakpointWithBindings(0, AdaptiveContainer.Create().Set("TitleFontSize", "20").Set("TitleColor", "red").Get());

            sizeStrategy.RaiseSizeChanged(10);

            await Task.Delay(3000);

            control.ActiveChanged += (s, e) =>
            {
                count++;
            };


            Assert.AreEqual(1, count);
        }
コード例 #6
0
        public void RaiseBreakpointChanged()
        {
            var sizeStrategy = new MySizeStrategy();
            var service      = new BreakpointListener(sizeStrategy);

            int count = 0;

            service.BreakpointChanged += (s, e) =>
            {
                count++;
            };

            service.AddBreakpoint(0);
            service.AddBreakpoint(100);
            service.AddBreakpoint(200);
            service.AddBreakpoint(300);

            sizeStrategy.RaiseSizeChanged(10);
            sizeStrategy.RaiseSizeChanged(20);   // ignored
            sizeStrategy.RaiseSizeChanged(150);
            sizeStrategy.RaiseSizeChanged(160);  // ignored
            sizeStrategy.RaiseSizeChanged(170);  // ignored
            sizeStrategy.RaiseSizeChanged(180);  // ignored
            sizeStrategy.RaiseSizeChanged(250);
            sizeStrategy.RaiseSizeChanged(260);  // ignored
            sizeStrategy.RaiseSizeChanged(350);
            sizeStrategy.RaiseSizeChanged(1000); // ignored
            sizeStrategy.RaiseSizeChanged(1600); // ignored

            Assert.AreEqual(4, count);
        }