public void ContextualCommandViewModel_Icon()
        {
            // Arrange
            var context     = new object();
            var command     = new RelayCommand(() => { });
            var testSubject = new ContextualCommandViewModel(context, command);

            using (var tracker = new PropertyChangedTracker(testSubject))
            {
                // Case 1: null
                // Act + Assert
                testSubject.Icon.Should().BeNull("Expected icon to return null when not set");

                // Case 2: static
                var staticIcon = new IconViewModel(null);
                testSubject.Icon = staticIcon;
                // Act + Assert
                testSubject.Icon.Should().Be(staticIcon, "Unexpected static icon");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.Icon), 1);

                // Case 3: dynamic
                var dynamicIcon = new IconViewModel(null);
                var funcInvoked = false;
                Func <object, IconViewModel> func = x =>
                {
                    funcInvoked = true;
                    return(dynamicIcon);
                };
                testSubject.SetDynamicIcon(func);
                // Act + Assert
                testSubject.Icon.Should().Be(dynamicIcon, "Unexpected dynamic icon");
                funcInvoked.Should().BeTrue("Dynamic icon function  was not invoked");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.Icon), 2);
            }

            // Case 4: dynamic - null exception
            Exceptions.Expect <ArgumentNullException>(() => testSubject.SetDynamicIcon(null));
        }
        public void ContextualCommandViewModel_DisplayText()
        {
            // Arrange
            var context     = new object();
            var command     = new RelayCommand(() => { });
            var testSubject = new ContextualCommandViewModel(context, command);

            using (var tracker = new PropertyChangedTracker(testSubject))
            {
                // Case 1: null
                // Act + Assert
                testSubject.DisplayText.Should().BeNull("Expected display text to return null when not set");

                // Case 2: static
                testSubject.DisplayText = "foobar9000";
                // Act + Assert
                testSubject.DisplayText.Should().Be("foobar9000", "Unexpected static display text");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.DisplayText), 1);

                // Case 3: dynamic
                var funcInvoked            = false;
                Func <object, string> func = x =>
                {
                    funcInvoked = true;
                    return("1234");
                };
                testSubject.SetDynamicDisplayText(func);
                // Act + Assert
                testSubject.DisplayText.Should().Be("1234", "Unexpected dynamic display text");
                funcInvoked.Should().BeTrue("Dynamic display text function was not invoked");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.DisplayText), 2);
            }

            // Case 4: dynamic - null exception
            Exceptions.Expect <ArgumentNullException>(() => testSubject.SetDynamicDisplayText(null));
        }
        public void ContextualCommandViewModel_DisplayText()
        {
            // Setup
            var context = new object();
            var command = new RelayCommand(() => { });
            var testSubject = new ContextualCommandViewModel(context, command);

            using (var tracker = new PropertyChangedTracker(testSubject))
            {
                // Case 1: null
                // Act + Verify
                Assert.IsNull(testSubject.DisplayText, "Expected display text to return null when not set");

                // Case 2: static
                testSubject.DisplayText = "foobar9000";
                // Act + Verify
                Assert.AreEqual("foobar9000", testSubject.DisplayText, "Unexpected static display text");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.DisplayText), 1);

                // Case 3: dynamic
                var funcInvoked = false;
                Func<object, string> func = x => 
                {
                    funcInvoked = true;
                    return "1234";
                };
                testSubject.SetDynamicDisplayText(func);
                // Act + Verify
                Assert.AreEqual("1234", testSubject.DisplayText, "Unexpected dynamic display text");
                Assert.IsTrue(funcInvoked, "Dynamic display text function was not invoked");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.DisplayText), 2);
            }

            // Case 4: dynamic - null exception
            Exceptions.Expect<ArgumentNullException>(() => testSubject.SetDynamicDisplayText(null));
        }
        public void ContextualCommandViewModel_Icon()
        {
            // Setup
            var context = new object();
            var command = new RelayCommand(() => { });
            var testSubject = new ContextualCommandViewModel(context, command);

            using (var tracker = new PropertyChangedTracker(testSubject))
            {
                // Case 1: null
                // Act + Verify
                Assert.IsNull(testSubject.Icon, "Expected icon to return null when not set");

                // Case 2: static
                var staticIcon = new IconViewModel(null);
                testSubject.Icon = staticIcon;
                // Act + Verify
                Assert.AreSame(staticIcon, testSubject.Icon, "Unexpected static icon");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.Icon), 1);

                // Case 3: dynamic
                var dynamicIcon = new IconViewModel(null);
                var funcInvoked = false;
                Func<object, IconViewModel> func = x => 
                {
                    funcInvoked = true;
                    return dynamicIcon;
                };
                testSubject.SetDynamicIcon(func);
                // Act + Verify
                Assert.AreSame(dynamicIcon, testSubject.Icon, "Unexpected dynamic icon");
                Assert.IsTrue(funcInvoked, "Dynamic icon function  was not invoked");
                tracker.AssertPropertyChangedRaised(nameof(testSubject.Icon), 2);
            }

            // Case 4: dynamic - null exception
            Exceptions.Expect<ArgumentNullException>(() => testSubject.SetDynamicIcon(null));
        }