Example #1
0
        private void Observabler()
        {
            ObservedClass obs = new ObservedClass();
            NotifiedClass n1  = new NotifiedClass();
            NotifiedClass n2  = new NotifiedClass();

            obs.Attach(n1);
            obs.Attach(n1);
        }
Example #2
0
    public void NoExceptionThrownWhenPropertyChanged()
    {
        NotifiedClass obj = new NotifiedClass();

        Exception ex = Record.Exception(
            () => Assert.PropertyChanged(obj, "Property1", () => obj.Property1 = "NewValue")
            );

        Assert.Null(ex);
    }
Example #3
0
        public void NoExceptionThrownWhenPropertyChanged()
        {
            var obj = new NotifiedClass();

            var ex = Record.Exception(
                () => Assert.PropertyChanged(obj, "Property1", () => obj.Property1 = "NewValue")
            );

            Assert.Null(ex);
        }
Example #4
0
        public async void NoExceptionThrownWhenPropertyChangedAsync()
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async() => obj.Property1 = "NewValue")
                );

            Assert.Null(ex);
        }
        public void ExceptionThrownWhenPropertyNotChanged(string expectedValue)
        {
            var obj = new NotifiedClass();

            var ex = Record.Exception(
                () => Assert.PropertyChanged(obj, "Property1", () => { }, expectedValue)
            );

            Assert.IsType<PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
        }
Example #6
0
        public void ExceptionThrownWhenPropertyNotChanged()
        {
            NotifiedClass obj = new NotifiedClass();

            Exception ex = Record.Exception(
                () => Assert.PropertyChanged(obj, "Property1", () => { })
            );

            Assert.IsType<PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
        }
Example #7
0
        public void ExceptionThrownWhenWrongPropertyChanged()
        {
            var obj = new NotifiedClass();

            var ex = Record.Exception(
                () => Assert.PropertyChanged(obj, "Property1", () => obj.Property2 = 42)
            );

            Assert.IsType<PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
        }
Example #8
0
    public void ExceptionThrownWhenWrongPropertyChanged()
    {
        NotifiedClass obj = new NotifiedClass();

        Exception ex = Record.Exception(
            () => Assert.PropertyChanged(obj, "Property1", () => obj.Property2 = 42)
            );

        Assert.IsType <PropertyChangedException>(ex);
        Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
    }
Example #9
0
        public async void ExceptionThrownWhenPropertyNotChanged()
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async() => { })
                );

            Assert.IsType <PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
        }
Example #10
0
        public async void NoExceptionThrownWhenMultiplePropertyChangesIncludesCorrectProperty()
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async() =>
            {
                obj.Property2 = 12;
                obj.Property1 = "New Value";
                obj.Property2 = 42;
            })
                );

            Assert.Null(ex);
        }
Example #11
0
        public void NoExceptionThrownWhenMultiplePropertyChangesIncludesCorrectProperty()
        {
            var obj = new NotifiedClass();

            var ex = Record.Exception(
                () =>
                {
                    Assert.PropertyChanged(obj, "Property1", () =>
                    {
                        obj.Property2 = 12;
                        obj.Property1 = "New Value";
                        obj.Property2 = 42;
                    });
                }
            );

            Assert.Null(ex);
        }
Example #12
0
    public void NoExceptionThrownWhenMultiplePropertyChangesIncludesCorrectProperty()
    {
        NotifiedClass obj = new NotifiedClass();

        Exception ex = Record.Exception(
            () =>
        {
            Assert.PropertyChanged(obj, "Property1", () =>
            {
                obj.Property2 = 12;
                obj.Property1 = "New Value";
                obj.Property2 = 42;
            });
        }
            );

        Assert.Null(ex);
    }
Example #13
0
        public async void ExceptionThrownWhenPropertyNotChanged()
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async () => { })
            );

            Assert.IsType<PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
        }
        public async void NoExceptionThrownWhenMultiplePropertyChangesIncludesCorrectProperty(string expectedValue)
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async () =>
                {
                    obj.Property2 = 12;
                    obj.Property1 = "New Value";
                    obj.Property2 = 42;
                }, expectedValue)
            );

            Assert.Null(ex);
        }
Example #15
0
        public async void NoExceptionThrownWhenPropertyChangedAsync()
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async () => obj.Property1 = "NewValue")
            );

            Assert.Null(ex);
        }
        public void ExceptionThrownWhenPropertyChangedToUnexpectedValue()
        {
            var obj = new NotifiedClass();

            var ex = Record.Exception(
                () =>
                    Assert.PropertyChanged(obj, "Property1", () => obj.Property1 = "Unexpected Value", "Expected Value"));

            Assert.IsType<PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set to expected value Expected Value", ex.Message);
        }
        public async void ExceptionThrownWhenWrongPropertyChangedAsync(string expectedValue)
        {
            var obj = new NotifiedClass();

            var ex = await Record.ExceptionAsync(
                () => Assert.PropertyChangedAsync(obj, "Property1", async () => obj.Property2 = 42, expectedValue)
            );

            Assert.IsType<PropertyChangedException>(ex);
            Assert.Equal("Assert.PropertyChanged failure: Property Property1 was not set", ex.Message);
        }