示例#1
0
        public void AddAction_NoId_Throws()
        {
            html.Grid.ViewContext.HttpContext.RequestServices.GetService <IAuthorization>().Returns((IAuthorization)null);
            IGridColumnsOf <Object> gridColumns = new GridColumns <Object>(new Grid <Object>(new Object[0]));

            gridColumns.Grid.ViewContext = html.Grid.ViewContext;

            IGridColumn <Object, IHtmlContent> column = gridColumns.AddAction("Delete", "fa fa-times");

            String actual   = Assert.Throws <Exception>(() => column.ValueFor(new GridRow <Object>(new Object()))).Message;
            String expected = "Object type does not have an id.";

            Assert.Equal(expected, actual);
        }
        public void AddAction_NoId_Throws()
        {
            IAuthorization          authorization = html.Grid.ViewContext !.HttpContext.RequestServices.GetRequiredService <IAuthorization>();
            IGridColumnsOf <Object> gridColumns   = new GridColumns <Object>(new Grid <Object>(Array.Empty <Object>()));

            authorization.IsGrantedFor(Arg.Any <Int64?>(), Arg.Any <String>()).Returns(true);
            gridColumns.Grid.ViewContext = html.Grid.ViewContext;

            IGridColumn <Object, IHtmlContent> column = gridColumns.AddAction("Delete", "fa fa-times");

            String actual   = Assert.Throws <Exception>(() => column.ValueFor(new GridRow <Object>(new Object(), 0))).Message;
            String expected = "Object type does not have an id.";

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void AddAction_NoId_Throws()
        {
            IUrlHelperFactory       factory     = Substitute.For <IUrlHelperFactory>();
            IGridColumnsOf <Object> gridColumns = new GridColumns <Object>(new Grid <Object>(Array.Empty <Object>()));

            html.Grid.ViewContext?.HttpContext.RequestServices.GetService(typeof(IUrlHelperFactory)).Returns(factory);
            html.Grid.ViewContext?.HttpContext.RequestServices.GetService(typeof(IAuthorization)).ReturnsNull();
            factory.GetUrlHelper(html.Grid.ViewContext).Returns(Substitute.For <IUrlHelper>());
            gridColumns.Grid.ViewContext = html.Grid.ViewContext;

            IGridColumn <Object, IHtmlContent> column = gridColumns.AddAction("Delete", "fa fa-times");

            String actual   = Assert.Throws <Exception>(() => column.ValueFor(new GridRow <Object>(new Object(), 0))).Message;
            String expected = "Object type does not have an id.";

            Assert.Equal(expected, actual);
        }