示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#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);

            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);
        }
示例#6
0
 public BaseLookupTests()
 {
     urlHelper = Substitute.For <IUrlHelper>();
     lookup    = new BaseLookupProxy <Role, RoleView>(urlHelper);
     using (TestingContext context = new TestingContext()) context.DropData();
 }