public void HtmlContent()
        {
            // arrange
            var vm = new RichTextFieldViewModel();

            var raises = false;
            Mock.NonPublic.Arrange(vm, "RaisePropertyChanged", "HtmlContent").DoInstead(() => { raises = true; });

            // act
            vm.HtmlContent = @"&nbsp;<p style=""margin-top: 0px;margin-bottom: 0px;line-height: 1.15;""><span style=""font-family: 'Verdana';font-size: 11px;"">Hello World!</span></p>";

            // assert
            Assert.AreEqual(@"&nbsp;<p style=""margin-top: 0px;margin-bottom: 0px;line-height: 1.15;""><span style=""font-family: 'Verdana';font-size: 11px;"">Hello World!</span></p>", vm.Value);
            Assert.IsTrue(raises);

            // arrange
            raises = false;

            // act
            vm.HtmlContent = null;

            // assert
            Assert.IsFalse(raises);

            // arrange
            //var privateAccessor = new PrivateAccessor(vm);
            //privateAccessor.SetField("_stopTyping", true);

            // act
            vm.HtmlContent = @"&nbsp;<p style=""margin-top: 0px;margin-bottom: 0px;line-height: 1.15;""><span style=""font-family: 'Verdana';font-size: 11px;"">Hello World!</span></p>";

            // assert
            Assert.IsTrue(raises);
        }
Exemplo n.º 2
0
        public void RichFieldTests()
        {
            // arrange
            var fieldViewModel = new RichTextFieldViewModel();
            var popupViewModel = new ExportFactory<RichTextFieldViewModel>(() => new Tuple<RichTextFieldViewModel, Action>(fieldViewModel, null));

            var fieldFactory = new FieldFactory { RichTextFieldViewModelFactory = popupViewModel };

            var model = new ModelStub();
            var property = model.GetType().GetProperty("RichTextField");

            // act
            var viewModel = fieldFactory.CreateField(property, null, model, new DetailsViewModel(), false);

            // assert
            Assert.IsTrue(viewModel is RichTextFieldViewModel);
        }
        public void PropertiesTests()
        {
            var vm = new RichTextFieldViewModel();

            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.NumberOfCharacters);
        }
        public void ChangingHtmlContentShouldNotDoubleRaisePropertyChangedEvent()
        {
            // arrange
            var vm = new RichTextFieldViewModel();
            int eventsCount = 0;
            vm.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == "HtmlContent")
                    {
                        eventsCount++;
                    }
                };
            vm.HtmlContent = "test";

            Assert.AreEqual(1, eventsCount);
        }
        public void ValueChangedShouldUpdateHtmlText()
        {
            // arrange
            var vm = new RichTextFieldViewModel();
            vm.Value = "test";

            Assert.AreEqual("test", vm.HtmlContent);

            vm.Value = "test2";

            Assert.AreEqual("test2", vm.HtmlContent);
        }