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(); }
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); }
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); }
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); }
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); }
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); }