예제 #1
0
        public void ScheduleFieldTests()
        {
            // arrange
            var fieldViewModel = new ScheduleDateFieldViewModel();
            var popupViewModel = new ExportFactory<ScheduleDateFieldViewModel>(() => new Tuple<ScheduleDateFieldViewModel, Action>(fieldViewModel, null));

            var fieldFactory = new FieldFactory { ScheduleDateFieldViewModelFactory = popupViewModel };

            var model = new ModelStub { ScheduleDateField = DateTime.Now };
            var property = model.GetType().GetProperty("ScheduleDateField");

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

            // assert
            Assert.IsTrue(viewModel is ScheduleDateFieldViewModel);
        }
예제 #2
0
        public void BlockedContentTests()
        {
            // arrange
            var fieldViewModel = new FieldViewModel();
            var popupViewModel = new ExportFactory<FieldViewModel>(() => new Tuple<FieldViewModel, Action>(fieldViewModel, null));

            var fieldFactory = new FieldFactory { FieldViewModelFactory = popupViewModel };

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

            var detailViewMdoel = new DetailsViewModel();

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

            // assert
            Assert.IsTrue(viewModel is FieldViewModel);
        }
예제 #3
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);
        }
예제 #4
0
        public void CreateField_Returns_SingleItemViewDisplayListFieldViewModel()
        {
            // Arrange.
            const string ProcessName = "TestProcess";

            var fieldViewModel = Mock.Create<ISingleItemViewDisplayListFieldViewModel>(Behavior.Loose);
            var fieldViewModelFactory =
                new ExportFactory<ISingleItemViewDisplayListFieldViewModel>(
                    () => Tuple.Create<ISingleItemViewDisplayListFieldViewModel, Action>(fieldViewModel, () => { }));

            var list = Mock.Create<IDisplayListItemList>(Behavior.Loose);
            var displayListManager = Mock.Create<IDisplayListManager>(Behavior.Loose);
            var model = new ModelStub
                            {
                                ProcessName = ProcessName,
                                SingleItemViewDisplayList = list,
                                SingleItemViewDisplayList_Manager = displayListManager
                            };

            var property = TestsHelper.ExtractProperty(() => model.SingleItemViewDisplayList);
            var detailsViewModel = Mock.Create<IDetailsViewModel>(Behavior.Loose);
            var dtm = Mock.Create<IDynamicTypeManager>(Behavior.Loose);
            Mock.Arrange(() => dtm.GetDisplayListItemType(ProcessName, property.Name)).Returns(typeof(DisplayListItem));

            var fieldFactory = new FieldFactory
                                   {
                                       TheDynamicTypeManager = dtm,
                                       SingleItemViewDisplayListFieldViewModelFactory = fieldViewModelFactory
                                   };

            // Act.
            var result = (ISingleItemViewDisplayListFieldViewModel)fieldFactory.CreateField(property, null, model, detailsViewModel, false);

            // Assert.
            Assert.IsNotNull(result);
            Assert.AreEqual("DisplayListSingleItemView", result.FieldType);
            Assert.AreSame(property, result.Property);
            Assert.AreSame(detailsViewModel, result.ParentDetailsVM);
            Mock.Assert(() => result.Init(model, list, detailsViewModel), Occurs.Once());
            Assert.AreSame(typeof(DisplayListItem), result.ItemType);
            Assert.AreEqual("RefProcess", result.ReferencedProcess);
            Assert.AreSame(displayListManager, result.DisplayListManager);
        }
예제 #5
0
        public void TextFieldTests()
        {
            // arrange
            var fieldViewModel = new TextFieldViewModel();
            var popupViewModel = new ExportFactory<TextFieldViewModel>(() => new Tuple<TextFieldViewModel, Action>(fieldViewModel, null));

            var fieldFactory = new FieldFactory { TextFieldViewModelFactory = popupViewModel };

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

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

            // assert
            Assert.AreEqual(2, ((TextFieldViewModel)viewModel).NumberOfRows);
        }
예제 #6
0
        public void DateTimeFieldTests()
        {
            // arrange
            var fieldViewModel = new DateTimeFieldViewModel();
            var popupViewModel = new ExportFactory<DateTimeFieldViewModel>(() => new Tuple<DateTimeFieldViewModel, Action>(fieldViewModel, null));

            var fieldFactory = new FieldFactory { DateTimeFieldViewModelFactory = popupViewModel };

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

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

            // assert
            Assert.AreEqual("Time", ((DateTimeFieldViewModel)viewModel).InputMode);
        }