public void BaseLookup_SetsDialogTitle() { lookup = new BaseLookupProxy <Role, RoleView>(urlHelper); String expected = ResourceProvider.GetLookupTitle(typeof(RoleView).Name.Replace("View", "")); String actual = lookup.DialogTitle; Assert.Equal(expected, actual); }
public void BaseLookup_SetsLookupUrl() { urlHelper.Action(Arg.Is <UrlActionContext>(context => context.Action == typeof(Role).Name && context.Controller == "Lookup")).Returns("Test"); lookup = new BaseLookupProxy <Role, RoleView>(urlHelper); String actual = lookup.LookupUrl; String expected = "Test"; Assert.Equal(expected, actual); }
public void BaseLookup_SetsUnitOfWork() { IUnitOfWork unitOfWork = Substitute.For <IUnitOfWork>(); lookup = new BaseLookupProxy <Role, RoleView>(unitOfWork); Object actual = lookup.BaseUnitOfWork; Object expected = unitOfWork; Assert.Same(expected, actual); }
public void GetModels_FromUnitOfWork() { IUnitOfWork unitOfWork = Substitute.For <IUnitOfWork>(); lookup = new BaseLookupProxy <Role, RoleView>(unitOfWork); unitOfWork.Select <Role>().To <RoleView>().Returns(new RoleView[0].AsQueryable()); Object expected = unitOfWork.Select <Role>().To <RoleView>(); Object actual = lookup.BaseGetModels(); 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); lookup = new BaseLookupProxy <Role, RoleView>(unitOfWork); lookup.CurrentFilter.Id = role.Id; RoleView expected = unitOfWork.Select <Role>().To <RoleView>().Single(); RoleView actual = lookup.BaseFilterById(null).Single(); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.Title, actual.Title); Assert.Equal(expected.Id, actual.Id); }
public BaseLookupTests() { urlHelper = Substitute.For <IUrlHelper>(); lookup = new BaseLookupProxy <Role, RoleView>(urlHelper); using (TestingContext context = new TestingContext()) context.DropData(); }