예제 #1
0
        public void GetNotVisible()
        {
            var myNativeProperty = new MyReadableNativePropertyClass();

            // ReSharper disable once ObjectCreationAsStatement we want to see the constructor throw an exception
            Action thrower = () => new NativeReadableProperty <string>(myNativeProperty, nameof(myNativeProperty.SetOnly));

            thrower.Should().Throw <ArgumentException>();
        }
예제 #2
0
        public void WrongProperty()
        {
            var myNativeProperty = new MyReadableNativePropertyClass();

            myNativeProperty.ChangeGreeting("hi");

            // ReSharper disable once ObjectCreationAsStatement we want to see the constructor throw an exception
            Action thrower = () => new NativeReadableProperty <int>(myNativeProperty, nameof(myNativeProperty.Greeting) + "_wrong");

            thrower.Should().Throw <ArgumentException>();
        }
예제 #3
0
        public void InitialValue()
        {
            int nativeEvents = 0, kokoEvents = 0;
            var myNativeProperty = new MyReadableNativePropertyClass();

            myNativeProperty.PropertyChanged += delegate { nativeEvents++; };

            myNativeProperty.ChangeGreeting("hello");
            nativeEvents.Should().Be(1);

            var kokoProperty = new NativeReadableProperty <string>(myNativeProperty, nameof(myNativeProperty.Greeting));

            kokoProperty.PropertyChanged += delegate { kokoEvents++; };
            kokoProperty.Value.Should().Be("hello");
            kokoEvents.Should().Be(0, "not changed while koko property existed yet");
        }
예제 #4
0
        public void NativeChange()
        {
            int nativeEvents = 0, kokoEvents = 0;
            var myNativeProperty = new MyReadableNativePropertyClass();

            myNativeProperty.PropertyChanged += delegate { nativeEvents++; };
            myNativeProperty.ChangeGreeting("hello");

            var kokoProperty = new NativeReadableProperty <string>(myNativeProperty, nameof(myNativeProperty.Greeting));

            kokoProperty.PropertyChanged += delegate { kokoEvents++; };

            myNativeProperty.ChangeGreeting("howdy");
            kokoProperty.Value.Should().Be("howdy");
            kokoEvents.Should().Be(1);
            nativeEvents.Should().Be(2);
        }