Exemplo n.º 1
0
        public void AddColumns_Values()
        {
            List<String> expected = new List<String>();
            TestModel model = new TestModel { FirstRelationModel = new TestRelationModel { Value = "Test" } };
            foreach (LookupColumn column in lookup.Columns)
                expected.Add(GetValue(model, column.Name));

            lookup.BaseAddColumns(row, model);

            Assert.Equal(expected, row.Values);
        }
Exemplo n.º 2
0
        public void AddAutocomplete_RelationValue()
        {
            lookup.Columns.Clear();
            lookup.Columns.Add(new LookupColumn("FirstRelationModel.Value", ""));
            TestModel model = new TestModel { FirstRelationModel = new TestRelationModel { Value = "Test" } };
            PropertyInfo firstProperty = typeof(TestRelationModel).GetProperty("Value");

            lookup.BaseAddAutocomplete(row, model);

            Assert.Equal(firstProperty.GetValue(model.FirstRelationModel).ToString(), row.First().Value);
        }
Exemplo n.º 3
0
        public void AddAutocomplete_Value()
        {
            TestModel model = new TestModel();
            PropertyInfo firstProperty = model.GetType().GetProperty(lookup.Columns.First().Name);

            lookup.BaseAddAutocomplete(row, model);

            Assert.Equal(firstProperty.GetValue(model).ToString(), row.First().Value);
        }
Exemplo n.º 4
0
        public void AddId_Value()
        {
            TestModel model = new TestModel { Id = "Test" };

            lookup.BaseAddId(row, model);

            Assert.True(row.ContainsValue(model.Id));
        }
Exemplo n.º 5
0
 public LookupExtensionsTests()
 {
     lookup = new TestLookupProxy();
     testModel = new TestModel();
     html = MockHtmlHelper();
 }
        private IHtmlHelper<TestModel> MockHtmlHelper()
        {
            IOptions<MvcViewOptions> options = Substitute.For<IOptions<MvcViewOptions>>();
            IModelMetadataProvider provider = new EmptyModelMetadataProvider();
            options.Value.Returns(new MvcViewOptions());

            IHtmlGenerator generator = new DefaultHtmlGenerator(
                Substitute.For<IAntiforgery>(),
                options,
                provider,
                Substitute.For<IUrlHelperFactory>(),
                HtmlEncoder.Default,
                new ClientValidatorCache());

            HtmlHelper<TestModel> htmlHelper = new HtmlHelper<TestModel>(
                generator,
                Substitute.For<ICompositeViewEngine>(),
                provider,
                Substitute.For<IViewBufferScope>(),
                HtmlEncoder.Default,
                UrlEncoder.Default,
                new ExpressionTextCache());

            TestModel model = new TestModel();
            model.ParentId = "Model's parent ID";
            ViewContext context = new ViewContext();
            context.ViewData = new ViewDataDictionary<TestModel>(context.ViewData, model);

            htmlHelper.Contextualize(context);

            return htmlHelper;
        }