• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ObservableDummy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ObservableDummy的典型用法代码示例。如果您正苦于以下问题:C# ObservableDummy类的具体用法?C# ObservableDummy怎么用?C# ObservableDummy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ObservableDummy类属于命名空间,在下文中一共展示了ObservableDummy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MultiplyChecked_Int_Observable_Update

        public void MultiplyChecked_Int_Observable_Update()
        {
            checked
            {
                var updated = false;
                var dummy = new ObservableDummy<int>() { Item = 3 };

                var test = new ObservingFunc<Dummy<int>, int>(d => d.Item * 7);

                var result = test.Observe(dummy);

                result.ValueChanged += (o, e) =>
                {
                    Assert.AreEqual(21, e.OldValue);
                    updated = true;
                };

                Assert.AreEqual(21, result.Value);
                Assert.IsFalse(updated);

                dummy.Item = 6;

                Assert.IsTrue(updated);
                Assert.AreEqual(42, result.Value);
            }
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:26,代码来源:MultiplyExpressionTests.cs


示例2: ArrayCreation_Observable_NoUpdatesWhenDetached

        public void ArrayCreation_Observable_NoUpdatesWhenDetached()
        {
            var update = false;
            var dummy = new ObservableDummy<int>() { Item = 23 };

            var test = new NotifyValue<int[]>(() => new int[dummy.Item]);

            test.ValueChanged += (o, e) => update = true;

            Assert.AreEqual(23, (test.Value as int[]).Length);
            Assert.IsFalse(update);

            test.Detach();

            dummy.Item = 42;

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.AreEqual(42, test.Value.Length);
            update = false;

            dummy.Item = 2;

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:28,代码来源:NewArrayExpressionTests.cs


示例3: ListInit_Observable_NoUpdateWhenDetached

        public void ListInit_Observable_NoUpdateWhenDetached()
        {
            var update = false;
            var dummy = new ObservableDummy<string>("foo");

            var test = Observable.Expression(() => new List<string>() { dummy.Item });

            test.ValueChanged += (o, e) => update = true;

            Assert.IsTrue(test.Value.Contains("foo"));
            Assert.IsFalse(update);

            test.Detach();

            dummy.Item = "bar";

            Assert.IsFalse(update);
            Assert.AreEqual(0, test.Value.Count);

            test.Attach();

            Assert.AreEqual(1, test.Value.Count);
            Assert.IsTrue(test.Value.Contains("bar"));

            dummy.Item = "42";

            Assert.AreEqual(1, test.Value.Count);
            Assert.IsTrue(test.Value.Contains("42"));
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:29,代码来源:ListInitializationTests.cs


示例4: MemberInitialization_Observable_NoUpdatesWhenDetached

        public void MemberInitialization_Observable_NoUpdatesWhenDetached()
        {
            var update = false;
            var dummy = new ObservableDummy<int>(23);

            var test = Observable.Expression(() => new Dummy<int>() { Item = dummy.Item });

            test.ValueChanged += (o, e) => update = true;

            Assert.AreEqual(23, (test.Value as Dummy<int>).Item);
            Assert.IsFalse(update);

            test.Detach();

            dummy.Item = 42;

            Assert.IsFalse(update);
            Assert.AreNotSame(dummy, test.Value);
            Assert.AreEqual(23, test.Value.Item);

            test.Attach();

            Assert.AreEqual(42, test.Value.Item);

            dummy.Item = 1;

            Assert.AreEqual(1, test.Value.Item);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:28,代码来源:MemberInitializationTests.cs


示例5: Cast_String_Observable_NoUpdatesWhenDetached

        public void Cast_String_Observable_NoUpdatesWhenDetached()
        {
            var update = false;
            var dummy = new ObservableDummy<object>() { Item = "23" };

            var test = new NotifyValue<string>(() => (string)dummy.Item);

            test.ValueChanged += (o, e) => update = true;

            Assert.AreEqual("23", test.Value);
            Assert.IsFalse(update);

            test.Detach();

            dummy.Item = "42";

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.AreEqual("42", test.Value);
            update = false;

            dummy.Item = "1";

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:28,代码来源:UnaryExpressionTests.cs


示例6: AddChecked_Int_Observable_NoUpdateWhenDetached

        public void AddChecked_Int_Observable_NoUpdateWhenDetached()
        {
            checked
            {
                var updated = false;
                var dummy = new ObservableDummy<int>() { Item = 5 };

                var result = Observable.Expression(() => dummy.Item + 7);

                result.ValueChanged += (o, e) => updated = true;

                Assert.AreEqual(12, result.Value);
                Assert.IsFalse(updated);

                result.Detach();

                dummy.Item = 35;

                Assert.AreEqual(12, result.Value);
                Assert.IsFalse(updated);

                result.Attach();

                Assert.IsTrue(updated);
                Assert.AreEqual(42, result.Value);

                updated = false;
                dummy.Item = 5;

                Assert.IsTrue(updated);
            }
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:32,代码来源:AddExpressionTests.cs


示例7: ConditionalExpression_ObservableTest_NoUpdatesWhenDetached

        public void ConditionalExpression_ObservableTest_NoUpdatesWhenDetached()
        {
            var update = false;
            var dummy = new ObservableDummy<bool>() { Item = false };

            var test = new ObservingFunc<Dummy<bool>, string>(d => d.Item ? "42" : "23");

            var result = test.Observe(dummy);

            result.ValueChanged += (o, e) => update = true;

            Assert.AreEqual("23", result.Value);
            Assert.IsFalse(update);

            result.Detach();

            dummy.Item = true;

            Assert.IsFalse(update);

            result.Attach();

            Assert.IsTrue(update);
            Assert.AreEqual("42", result.Value);

            update = false;

            dummy.Item = false;

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:31,代码来源:ConditionalExpressionTests.cs


示例8: New_Observable_NoUpdatesWhenDetached

        public void New_Observable_NoUpdatesWhenDetached()
        {
            var update = false;
            var dummy = new ObservableDummy<int>() { Item = 23 };

            var test = new NotifyValue<Dummy<int>>(() => new Dummy<int>(dummy.Item));

            test.ValueChanged += (o, e) => update = true;

            Assert.AreEqual(23, (test.Value as Dummy<int>).Item);
            Assert.IsFalse(update);

            test.Detach();

            dummy.Item = 42;

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.AreEqual(42, test.Value.Item);
            update = false;

            dummy.Item = 1;

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:28,代码来源:NewExpressionTests.cs


示例9: OrElse_RightHandThrowsException_NoExceptionOnUpdate

        public void OrElse_RightHandThrowsException_NoExceptionOnUpdate()
        {
            var dummy = new ObservableDummy<bool>(false);
            var test = Observable.Expression(() => dummy.Item || ThrowExceptionIf(dummy.Item));
            Assert.IsTrue(test.Value);

            dummy.Item = true;

            Assert.IsTrue(test.Value);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:10,代码来源:ShortcutOperatorTests.cs


示例10: AndAlso_RightHandThrowsException_NoExceptionOnUpdate

        public void AndAlso_RightHandThrowsException_NoExceptionOnUpdate()
        {
            var dummy = new ObservableDummy<bool>(true);
            var test = Observable.Expression(() => dummy.Item && ThrowExceptionIf(!dummy.Item));
            Assert.IsTrue(test.Value);

            dummy.Item = false;

            Assert.IsFalse(test.Value);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:10,代码来源:ShortcutOperatorTests.cs


示例11: Modulo_Int_ModuloDoesNotChange_NoUpdate

        public void Modulo_Int_ModuloDoesNotChange_NoUpdate()
        {
            var update = false;
            var dummy = new ObservableDummy<int>(7);

            var test = Observable.Expression(() => dummy.Item % 2);

            test.ValueChanged += (o, e) => update = true;

            Assert.AreEqual(1, test.Value);
            Assert.IsFalse(update);

            dummy.Item = 3;

            Assert.IsFalse(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:16,代码来源:ModuloExpressionTests.cs


示例12: And_Boolean_Observable_Update

        public void And_Boolean_Observable_Update()
        {
            var updated = false;
            var dummy = new ObservableDummy<bool>() { Item = true };

            var result = Observable.Expression(() => dummy.Item & true);

            result.ValueChanged += (o, e) => updated = true;

            Assert.IsTrue(result.Value);
            Assert.IsFalse(updated);

            dummy.Item = false;

            Assert.IsFalse(result.Value);
            Assert.IsTrue(updated);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:17,代码来源:BinaryExpressionTests.cs


示例13: GreaterThanEquals_Long_Observable_Update

        public void GreaterThanEquals_Long_Observable_Update()
        {
            var updated = false;
            var dummy = new ObservableDummy<long>() { Item = 1 };

            var test = new ObservingFunc<Dummy<long>, bool>(d => d.Item >= 0);

            var result = test.Observe(dummy);

            result.ValueChanged += (o, e) => updated = true;

            Assert.IsTrue(result.Value);
            Assert.IsFalse(updated);

            dummy.Item = -1;

            Assert.IsFalse(result.Value);
            Assert.IsTrue(updated);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:19,代码来源:GreaterThanEqualsExpressionTests.cs


示例14: Equals_Class_Observable_Update

        public void Equals_Class_Observable_Update()
        {
            var updated = false;
            var dummy = new ObservableDummy<string>() { Item = "42" };

            var test = new ObservingFunc<Dummy<string>, bool>(d => d.Item == "42");

            var result = test.Observe(dummy);

            result.ValueChanged += (o, e) => updated = true;

            Assert.IsTrue(result.Value);
            Assert.IsFalse(updated);

            dummy.Item = "23";

            Assert.IsFalse(result.Value);
            Assert.IsTrue(updated);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:19,代码来源:EqualsTests.cs


示例15: LessThan_Int_Observable_Update

        public void LessThan_Int_Observable_Update()
        {
            var updated = false;
            var dummy = new ObservableDummy<int>() { Item = 1 };

            var test = new ObservingFunc<Dummy<int>, bool>(d => d.Item < 0);

            var result = test.Observe(dummy);

            result.ValueChanged += (o, e) => updated = true;

            Assert.IsFalse(result.Value);
            Assert.IsFalse(updated);

            dummy.Item = -1;

            Assert.IsTrue(result.Value);
            Assert.IsTrue(updated);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:19,代码来源:LessThanExpressionTests.cs


示例16: RecursiveFac

        public void RecursiveFac()
        {
            var dummy = new ObservableDummy<int>(4);
            var test = Observable.Expression(() => Fac(dummy.Item));
            var resultChanged = false;

            Assert.AreEqual(24, test.Value);

            test.ValueChanged += (o, e) =>
            {
                resultChanged = true;
                Assert.AreEqual(24, e.OldValue);
            };

            dummy.Item = 5;

            Assert.IsTrue(resultChanged);
            Assert.AreEqual(120, test.Value);
        }
开发者ID:NMFCode,项目名称:NMF,代码行数:19,代码来源:RecursiveTest.cs


示例17: ArrayCreation_Observable_Updates

        public void ArrayCreation_Observable_Updates()
        {
            var update = false;
            var dummy = new ObservableDummy<int>() { Item = 23 };

            var test = new NotifyValue<int[]>(() => new int[dummy.Item]);

            test.ValueChanged += (o, e) =>
            {
                update = true;
                Assert.AreEqual(23, (e.OldValue as int[]).Length);
                Assert.AreEqual(42, (e.NewValue as int[]).Length);
            };

            Assert.AreEqual(23, (test.Value as int[]).Length);
            Assert.IsFalse(update);

            dummy.Item = 42;

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:21,代码来源:NewArrayExpressionTests.cs


示例18: Add_String_Observable_Update

        public void Add_String_Observable_Update()
        {
            var updated = false;
            var dummy = new ObservableDummy<string>() { Item = "5" };

            var result = Observable.Expression(() => dummy.Item + "2");

            result.ValueChanged += (o, e) =>
            {
                Assert.AreEqual("52", e.OldValue);
                updated = true;
            };

            Assert.AreEqual("52", result.Value);
            Assert.IsFalse(updated);

            dummy.Item = "4";

            Assert.IsTrue(updated);
            Assert.AreEqual("42", result.Value);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:21,代码来源:BinaryExpressionTests.cs


示例19: New_Observable_Updates

        public void New_Observable_Updates()
        {
            var update = false;
            var dummy = new ObservableDummy<int>() { Item = 23 };

            var test = new NotifyValue<Dummy<int>>(() => new Dummy<int>(dummy.Item));

            test.ValueChanged += (o, e) =>
            {
                update = true;
                Assert.AreEqual(23, (e.OldValue as Dummy<int>).Item);
                Assert.AreEqual(42, (e.NewValue as Dummy<int>).Item);
            };

            Assert.AreEqual(23, (test.Value as Dummy<int>).Item);
            Assert.IsFalse(update);

            dummy.Item = 42;

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:21,代码来源:NewExpressionTests.cs


示例20: BitwiseOr_Long_ObservableSource_Update

        public void BitwiseOr_Long_ObservableSource_Update()
        {
            var update = false;
            var dummy = new ObservableDummy<long>(7);

            var test = Observable.Expression(() => 21 | dummy.Item);

            test.ValueChanged += (o, e) =>
            {
                update = true;
                Assert.AreEqual(23L, e.OldValue);
                Assert.AreEqual(29L, e.NewValue);
            };

            Assert.AreEqual(23L, test.Value);
            Assert.IsFalse(update);

            dummy.Item = 13;

            Assert.IsTrue(update);
            Assert.AreEqual(29L, test.Value);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:22,代码来源:BitwiseOrExpressionTests.cs



注:本文中的ObservableDummy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ObservableEventListener类代码示例发布时间:2022-05-24
下一篇:
C# ObservableDictionary类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap