Ejemplo n.º 1
0
        public void INPCInvoke()
        {
            var generated = new GenerateProperties {
                Property = 1
            };

            DoWith.PropertyChangedEvent(
                generated,
                () => {
                DoWith.PropertyChangingEvent(
                    generated,
                    () => generated.Property = 2,
                    e => {
                    Assert.AreEqual(nameof(GenerateProperties.Property), e.PropertyName);
                    Assert.AreEqual(1, generated.Property);
                }
                    );
            },
                e => {
                Assert.AreEqual(nameof(GenerateProperties.Property), e.PropertyName);
                Assert.AreEqual(2, generated.Property);
            }
                );

            Assert.AreEqual(2, generated.Property);
        }
Ejemplo n.º 2
0
        public void NullableAnnotation()
        {
            var generated = new GenerateProperties()
            {
                NullableValue = 1
            };

            Assert.AreEqual(null, generated.NullableOldValue);
            Assert.AreEqual(1, generated.NullableNewValue);

            DoWith.PropertyChangedEvent(
                generated,
                () => {
                DoWith.PropertyChangingEvent(
                    generated,
                    () => generated.NullableValue = 2,
                    e => {
                    Assert.AreEqual(1, generated.NullableValue);
                    Assert.AreEqual(null, generated.NullableOldValue);
                    Assert.AreEqual(1, generated.NullableNewValue);
                }
                    );
            },
                e => {
                Assert.AreEqual(2, generated.NullableValue);
                Assert.AreEqual(null, generated.NullableOldValue);
                Assert.AreEqual(2, generated.NullableNewValue);
            }
                );

            Assert.AreEqual(2, generated.NullableValue);
            Assert.AreEqual(1, generated.NullableOldValue);
            Assert.AreEqual(2, generated.NullableNewValue);
        }
        public void ParentWithImplementationAndGeneratedRaiseMethod()
        {
            var generated = new ChildWithParentsGeneratedRaiseMethod2();

            Assert.Throws <Exception>(() =>
                                      DoWith.PropertyChangedEvent(
                                          generated,
                                          () => DoWith.PropertyChangingEvent(
                                              generated,
                                              () => generated.Value = 1,
                                              e => throw new Exception()),
                                          e => throw new Exception())
                                      );
        }
        public void DefaultRaiseMethod()
        {
            var generated = new DefaultRaiseMethod();

            Assert.Throws <Exception>(() =>
                                      DoWith.PropertyChangedEvent(
                                          generated,
                                          () => DoWith.PropertyChangingEvent(
                                              generated,
                                              () => generated.Value = 1,
                                              e => throw new Exception()),
                                          e => throw new Exception())
                                      );
        }
        public void ParentWithStringParameterRaiseMethod()
        {
            var generated = new ChildWithParentsStringParameterRaiseMethod4();

            Assert.Throws <Exception>(() =>
                                      DoWith.PropertyChangedEvent(
                                          generated,
                                          () => DoWith.PropertyChangingEvent(
                                              generated,
                                              () => generated.Value = 1,
                                              e => throw new Exception()),
                                          e => throw new Exception())
                                      );
        }