public void TestAreNotSameDifferent()
        {
            string s1 = "test";
            string s2 = "test2";

            Verify.AreNotSame(s1, s2);
        }
Exemple #2
0
        public void TestOneWayExitBehavior()
        {
            // Put the exit in room A only, and register an exit command to travel one way.
            this.roomA.Add(this.exit);
            this.exitBehavior.AddDestination("east", this.roomB.ID);

            // Ensure the exit is rigged up to the correct location now, but does not work the other way around.
            Verify.AreSame(this.exitBehavior.GetDestination(this.roomA), this.roomB);
            Verify.AreSame(this.exitBehavior.GetDestination(this.roomA), this.roomB);
            Verify.AreNotSame(this.exitBehavior.GetDestination(this.roomB), this.roomA);

            // Create an unmovable actor, and ensure that said actor cannot move through.
            this.actor = new Thing()
            {
                Name = "Actor", Parent = this.roomA
            };
            this.exitBehavior.MoveThrough(this.actor);
            Verify.AreSame(this.actor.Parent, this.roomA);

            // Make the actor movable, and try moving the actor through again.
            this.actor.Behaviors.Add(new MovableBehavior());
            this.exitBehavior.MoveThrough(this.actor);
            Verify.AreSame(this.actor.Parent, this.roomB);

            // Ensure the actor does not end up in room A if we try to shove the actor through again.
            this.exitBehavior.MoveThrough(this.actor);
            Verify.AreSame(this.actor.Parent, this.roomB);

            // @@@ TODO: Place the actor back in room A, and try using the context command to move it?
            this.actor.Parent = this.roomA;
        }
        public void TestAreNotSameDifferent()
        {
            var s1 = "test";
            var s2 = "test2";

            Verify.AreNotSame(s1, s2);
        }
        public void UpdateMinMaxTest()
        {
            using (var setup = new TestSetupHelper("ProgressBar Tests"))
            {
                Log.Comment("Updating Minimum and Maximum value of ProgressBar");

                RangeValueSpinner progressBar = FindElement.ByName <RangeValueSpinner>("TestProgressBar");

                double oldMinimumInputText = progressBar.Minimum;
                double oldMaximumInputText = progressBar.Maximum;

                Button updateMinMaxButton = FindElement.ByName <Button>("UpdateMinMaxButton");
                Edit   minimumInput       = FindElement.ByName <Edit>("MinimumInput");
                Edit   maximumInput       = FindElement.ByName <Edit>("MaximumInput");

                minimumInput.SetValue("10");
                maximumInput.SetValue("15");
                updateMinMaxButton.InvokeAndWait();

                double newMinimumInputText = progressBar.Minimum;
                double newMaximumInputText = progressBar.Maximum;

                Verify.AreNotSame(oldMinimumInputText, newMinimumInputText, "Minimum updated");
                Verify.AreNotSame(oldMaximumInputText, newMaximumInputText, "Maximum updated");

                // Below edge cases are handled by Rangebase

                Log.Comment("Updating Minimum and Maximum when Maximum < Minimum");

                maximumInput.SetValue("5");
                updateMinMaxButton.InvokeAndWait();

                Verify.AreEqual(progressBar.Minimum, progressBar.Maximum, "Maximum updates to equal Minimum");

                Log.Comment("Updating Minimum and Maximum when Minimum > Value");

                minimumInput.SetValue("15");
                updateMinMaxButton.InvokeAndWait();

                Verify.AreEqual(progressBar.Value, progressBar.Minimum, "Value updates to equal Minimum");
                Verify.AreEqual(progressBar.Maximum, progressBar.Minimum, "Maximum also updates to equal Minimum");

                Log.Comment("Updating Minimum and Maximum to be a decimal number");

                minimumInput.SetValue("0.1");
                maximumInput.SetValue("1.1");
                updateMinMaxButton.InvokeAndWait();

                double oldValue = progressBar.Value;

                Button changeValueButton = FindElement.ByName <Button>("ChangeValueButton");
                changeValueButton.InvokeAndWait();

                double newValue = progressBar.Value;
                double diff     = Math.Abs(oldValue - newValue);

                Verify.IsGreaterThan(diff, Convert.ToDouble(0), "Value of ProgressBar increments properly within range with decimal Minimum and Maximum");
            }
        }
Exemple #5
0
        public void DoInititiveRollTest()
        {
            Die combatDie = DiceService.Instance.GetDie(6);

            int roll = combatDie.Roll();

            Verify.AreNotSame(roll, 0);
        }
        public void ValidateMappingAndAutoRecycling()
        {
            ItemsRepeater repeater     = null;
            ScrollViewer  scrollViewer = null;

            RunOnUIThread.Execute(() =>
            {
                var layout = new MockVirtualizingLayout()
                {
                    MeasureLayoutFunc = (availableSize, context) =>
                    {
                        var element0 = context.GetOrCreateElementAt(index: 0);
                        // lookup - repeater will give back the same element and note that this element will not
                        // be pinned - i.e it will be auto recycled after a measure pass where GetElementAt(0) is not called.
                        var element0lookup = context.GetOrCreateElementAt(index: 0, options: ElementRealizationOptions.None);

                        var element1 = context.GetOrCreateElementAt(index: 1, options: ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle);
                        // forcing a new element for index 1 that will be pinned (not auto recycled). This will be
                        // a completely new element. Repeater does not do the mapping/lookup when forceCreate is true.
                        var element1Clone = context.GetOrCreateElementAt(index: 1, options: ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle);

                        Verify.AreSame(element0, element0lookup);
                        Verify.AreNotSame(element1, element1Clone);

                        element0.Measure(availableSize);
                        element1.Measure(availableSize);
                        element1Clone.Measure(availableSize);
                        return(new Size(100, 100));
                    },
                };

                Content = CreateAndInitializeRepeater(
                    itemsSource: Enumerable.Range(0, 5),
                    layout: layout,
                    elementFactory: GetDataTemplate("<Button>Hello</Button>"),
                    repeater: ref repeater,
                    scrollViewer: ref scrollViewer);

                Content.UpdateLayout();

                Verify.IsNotNull(repeater.TryGetElement(0));
                Verify.IsNotNull(repeater.TryGetElement(1));

                layout.MeasureLayoutFunc = null;

                repeater.InvalidateMeasure();
                Content.UpdateLayout();

                Verify.IsNull(repeater.TryGetElement(0));    // not pinned, should be auto recycled.
                Verify.IsNotNull(repeater.TryGetElement(1)); // pinned, should stay alive
            });
        }
Exemple #7
0
        public void ValidateGetElementAtCachingForLayout()
        {
            List <int>      data       = Enumerable.Range(0, 15).ToList();
            ItemsSourceView dataSource = null;

            RunOnUIThread.Execute(() => dataSource = new ItemsSourceView(data));
            ScrollViewer scrollViewer = null;
            var          repeater     = SetupRepeater(dataSource, null /*layout*/, out scrollViewer);
            bool         layoutRan    = false;

            RunOnUIThread.Execute(() =>
            {
                var layout = new MockVirtualizingLayout();
                layout.MeasureLayoutFunc = (availableSize, context) =>
                {
                    Verify.AreEqual(15, context.ItemCount);
                    var element0 = context.GetOrCreateElementAt(0);
                    Verify.IsNotNull(element0);
                    var element1 = context.GetOrCreateElementAt(1);
                    Verify.IsNotNull(element1);
                    Verify.AreNotSame(element0, element1);

                    var element1again = context.GetOrCreateElementAt(1);
                    Verify.AreSame(element1, element1again);

                    var element10 = context.GetOrCreateElementAt(10);
                    Verify.IsNotNull(element10);
                    Verify.AreNotSame(element0, element10);
                    Verify.AreNotSame(element1, element10);

                    context.RecycleElement(element1);

                    var element0New = context.GetOrCreateElementAt(0);
                    Verify.AreSame(element0, element0New);

                    context.RecycleElement(element10);
                    context.RecycleElement(element0);

                    layoutRan = true;
                    return(new Size(10, 10));
                };

                repeater.Layout = layout;
                repeater.UpdateLayout();
                Verify.IsTrue(layoutRan);
            });

            IdleSynchronizer.Wait();
        }
        public void ValidateRecycling()
        {
            RunOnUIThread.Execute(() =>
            {
                var elementFactory = new RecyclingElementFactory()
                {
                    RecyclePool = new RecyclePool(),
                };
                elementFactory.Templates["even"] = (DataTemplate)XamlReader.Load(
                    @"<DataTemplate  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>
						<TextBlock Text='even' />
					</DataTemplate>"                    );
                elementFactory.Templates["odd"] = (DataTemplate)XamlReader.Load(
                    @"<DataTemplate  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>
						<TextBlock Text='odd' />
					</DataTemplate>"                    );

                elementFactory.SelectTemplateKey +=
                    delegate(RecyclingElementFactory sender, SelectTemplateEventArgs args)
                {
                    args.TemplateKey = ((int)args.DataContext % 2 == 0) ? "even" : "odd";
                };

                const int numItems     = 10;
                ItemsRepeater repeater = new ItemsRepeater()
                {
                    ItemsSource  = Enumerable.Range(0, numItems),
                    ItemTemplate = elementFactory,
                };

                var context         = (ElementFactoryGetArgs)RepeaterTestHooks.CreateRepeaterElementFactoryGetArgs();
                context.Parent      = repeater;
                var clearContext    = (ElementFactoryRecycleArgs)RepeaterTestHooks.CreateRepeaterElementFactoryRecycleArgs();
                clearContext.Parent = repeater;

                // Element0 is of type even, a new one should be created
                context.Data = 0;
                var element0 = elementFactory.GetElement(context);
                Verify.IsNotNull(element0);
                Verify.AreEqual("even", (element0 as TextBlock).Text);
                clearContext.Element = element0;
                elementFactory.RecycleElement(clearContext);

                // Element1 is of type odd, a new one should be created
                context.Data = 1;
                var element1 = elementFactory.GetElement(context);
                Verify.IsNotNull(element1);
                Verify.AreNotSame(element0, element1);
                Verify.AreEqual("odd", (element1 as TextBlock).Text);
                clearContext.Element = element1;
                elementFactory.RecycleElement(clearContext);

                // Element0 should be recycled for element2
                context.Data = 2;
                var element2 = elementFactory.GetElement(context);
                Verify.AreEqual("even", (element2 as TextBlock).Text);
                Verify.AreSame(element0, element2);

                // Element1 should be recycled for element3
                context.Data = 3;
                var element3 = elementFactory.GetElement(context);
                Verify.AreEqual("odd", (element3 as TextBlock).Text);
                Verify.AreSame(element1, element3);
            });
        }
        public void TestAreNotSameSame()
        {
            string s = "test";

            Assert.Throws <InvalidOperationException>(() => Verify.AreNotSame(s, s));
        }