示例#1
0
        public DatalistTests()
        {
            HttpContext.Current = HttpContextFactory.CreateHttpContext();
            urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

            datalist = new DatalistProxy<Role, RoleView>(urlHelper);
            using (TestingContext context = new TestingContext()) context.DropData();
        }
示例#2
0
        public void Datalist_SetsDatalistUrl()
        {
            datalist = new DatalistProxy<Role, RoleView>(urlHelper);

            String expected = urlHelper.Action(typeof(Role).Name, AbstractDatalist.Prefix, new { area = "" });
            String actual = datalist.DatalistUrl;

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void Datalist_SetsDialogTitle()
        {
            datalist = new DatalistProxy<Role, RoleView>(urlHelper);

            String expected = ResourceProvider.GetDatalistTitle(typeof(RoleView).Name.Replace("View", ""));
            String actual = datalist.DialogTitle;

            Assert.Equal(expected, actual);
        }
示例#4
0
        public void Datalist_SetsUnitOfWork()
        {
            IUnitOfWork unitOfWork = Substitute.For<IUnitOfWork>();
            datalist = new DatalistProxy<Role, RoleView>(unitOfWork);

            Object actual = datalist.BaseUnitOfWork;
            Object expected = unitOfWork;

            Assert.Same(expected, actual);
        }
示例#5
0
        public void FilterById_FromCurrentFilter()
        {
            TestingContext context = new TestingContext();
            Role role = ObjectFactory.CreateRole();
            context.Set<Role>().Add(role);
            context.SaveChanges();

            IUnitOfWork unitOfWork = new UnitOfWork(context);
            datalist = new DatalistProxy<Role, RoleView>(unitOfWork);

            datalist.CurrentFilter.Id = role.Id.ToString();

            RoleView expected = unitOfWork.Select<Role>().To<RoleView>().Single();
            RoleView actual = datalist.BaseFilterById(null).Single();

            Assert.Equal(expected.CreationDate, actual.CreationDate);
            Assert.Equal(expected.Title, actual.Title);
            Assert.Equal(expected.Id, actual.Id);
        }
示例#6
0
        public void GetModels_FromUnitOfWork()
        {
            IUnitOfWork unitOfWork = Substitute.For<IUnitOfWork>();
            datalist = new DatalistProxy<Role, RoleView>(unitOfWork);
            unitOfWork.Select<Role>().To<RoleView>().Returns(new RoleView[0].AsQueryable());

            Object expected = unitOfWork.Select<Role>().To<RoleView>();
            Object actual = datalist.BaseGetModels();

            Assert.Same(expected, actual);
        }