public void Should_not_refresh_readonly_property()
        {
            DISetup.SetupContainer();
            DISetup.Container.Register <FakeModel>();
            var model = DISetup.Container.GetInstance <FakeModel>();

            model.Dummy4 = new FakeLocalizableWithReadonlyProperty();
            var changedEvents  = new List <string>();
            var changingEvents = new List <string>();

            model.Dummy4.PropertyChanged += (s, e) =>
            {
                changedEvents.Add(e.PropertyName);
            };
            model.Dummy4.PropertyChanging += (s, e) =>
            {
                changingEvents.Add(e.PropertyName);
            };
            var invocation = new Mock <Castle.DynamicProxy.IInvocation>();

            invocation.Setup(p => p.InvocationTarget).Returns(model);
            invocation.Setup(p => p.Proxy).Returns(model.Dummy4);
            var prop    = model.GetType().GetProperty("Dummy4");
            var args    = new LocalizationRefreshArgs(invocation.Object, prop);
            var handler = new LocalizationModelRefreshHandler();

            handler.Refresh(args);
            changedEvents.Count.Should().Be(0);
            changingEvents.Count.Should().Be(0);
        }
        public void CanRefresh_should_be_false()
        {
            var fake    = new FakeModel();
            var prop    = fake.GetType().GetProperty("Dummy1");
            var handler = new LocalizationModelRefreshHandler();
            var args    = new LocalizationRefreshArgs(null, prop);

            handler.CanRefresh(args).Should().BeFalse();
        }
        public void Should_refresh_property()
        {
            DISetup.SetupContainer();
            DISetup.Container.Register <FakeModel>();
            var model = DISetup.Container.GetInstance <FakeModel>();

            model.Dummy2 = new FakeLocalizableModel()
            {
                FakeProp = "1"
            };
            var changedEvents  = new List <string>();
            var changingEvents = new List <string>();
            var initialValue   = model.Dummy2.FakeProp;
            var finalValue     = string.Empty;

            model.Dummy2.PropertyChanged += (s, e) =>
            {
                changedEvents.Add(e.PropertyName);
            };
            model.Dummy2.PropertyChanging += (s, e) =>
            {
                changingEvents.Add(e.PropertyName);
            };
            var invocation = new Mock <Castle.DynamicProxy.IInvocation>();

            invocation.Setup(p => p.InvocationTarget).Returns(model);
            invocation.Setup(p => p.Proxy).Returns(model.Dummy2);
            var prop    = model.GetType().GetProperty("Dummy2");
            var args    = new LocalizationRefreshArgs(invocation.Object, prop);
            var handler = new LocalizationModelRefreshHandler();

            handler.Refresh(args);
            changedEvents.Count.Should().Be(2);
            changedEvents.GroupBy(s => s).Select(s => s.First()).Count().Should().Be(1);
            changingEvents.Count.Should().Be(2);
            changingEvents.GroupBy(s => s).Select(s => s.First()).Count().Should().Be(1);
            model.Dummy2.FakeProp.Should().Be(initialValue);
        }