Exemplo n.º 1
0
        public void SetPropertyAndPerformAsyncUpdate_should_not_invoke_the_update_func_if_loading()
        {
            var vm = new TestEditorViewModel(s_bonusBar);

            typeof(EditorViewModel)
            .InvokeMember(
                "IsLoading",
                BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetProperty,
                Type.DefaultBinder,
                vm,
                new object[] { true });

            int  value = 0;
            bool invokedUpdateAction = false;

            vm.SetPropertyAndPerformAsyncUpdate(
                ref value,
                10,
                () =>
            {
                invokedUpdateAction = true;
                return(Task.CompletedTask);
            },
                TimeSpan.FromMinutes(1).Milliseconds,
                // ReSharper disable once ExplicitCallerInfoArgument
                "TestProperty")
            .Should()
            .BeTrue();

            invokedUpdateAction.Should().BeFalse();
        }
Exemplo n.º 2
0
        public void SetPropertyAndPerformAsyncUpdate_should_not_do_anything_if_the_property_has_not_chnaged()
        {
            string fakeProperty = "Nothing";

            var vm = new TestEditorViewModel(s_bonusBar);

            vm.SetPropertyAndPerformAsyncUpdate(
                ref fakeProperty,
                "Nothing",
                () => Task.CompletedTask,
                TimeSpan.FromMinutes(1).Milliseconds,
                // ReSharper disable once ExplicitCallerInfoArgument
                "TestProperty")
            .Should()
            .BeFalse();

            fakeProperty.Should().Be("Nothing");
        }