Ejemplo n.º 1
0
        public BaseDatalistTests()
        {
            HttpContext.Current = HttpContextFactory.CreateHttpContext();
            urlHelper           = new UrlHelper(HttpContext.Current.Request.RequestContext);

            datalist = new BaseDatalistProxy <Role, RoleView>(urlHelper);
        }
Ejemplo n.º 2
0
        public void BaseDatalist_SetsUnitOfWork()
        {
            datalist = new BaseDatalistProxy <Role, RoleView>(unitOfWork);

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

            Assert.AreSame(expected, actual);
        }
Ejemplo n.º 3
0
        public void BaseDatalist_SetsDialogTitle()
        {
            datalist = new BaseDatalistProxy <Role, RoleView>();

            String expected = ResourceProvider.GetDatalistTitle <Role>();
            String actual   = datalist.DialogTitle;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void BaseDatalist_SetsDatalistUrl()
        {
            datalist = new BaseDatalistProxy <Role, RoleView>(urlHelper);

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

            Assert.Equal(expected, actual);
        }
        public void BaseDatalist_SetsDialogTitle()
        {
            datalist = new BaseDatalistProxy <Role, RoleView>(urlHelper);

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

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 6
0
        public void GetModels_ReturnsModelsFromUnitOfWork()
        {
            unitOfWork.Select <Role>().To <RoleView>().Returns(Enumerable.Empty <RoleView>().AsQueryable());
            datalist = new BaseDatalistProxy <Role, RoleView>(unitOfWork);

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

            Assert.AreSame(expected, actual);
        }
Ejemplo n.º 7
0
        public void BaseDatalist_SetsUnitOfWork()
        {
            IUnitOfWork unitOfWork = Substitute.For <IUnitOfWork>();

            datalist = new BaseDatalistProxy <Role, RoleView>(unitOfWork);

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

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public void BaseDatalist_SetsDatalistUrl()
        {
            HttpRequest request = HttpContext.Current.Request;

            datalist = new BaseDatalistProxy <Role, RoleView>();
            UrlHelper url = new UrlHelper(request.RequestContext);

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

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
        public void GetModels_ReturnsModelsProjectedToViews()
        {
            IUnitOfWork unitOfWork = Substitute.For <IUnitOfWork>();

            datalist = new BaseDatalistProxy <Role, RoleView>(unitOfWork);
            unitOfWork.Repository <Role>().ProjectTo <RoleView>().Returns(Enumerable.Empty <RoleView>().AsQueryable());

            IQueryable <RoleView> expected = unitOfWork.Repository <Role>().ProjectTo <RoleView>();
            IQueryable <RoleView> actual   = datalist.BaseGetModels();

            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 10
0
        public void GetModels_ReturnsModelsFromUnitOfWork()
        {
            IUnitOfWork unitOfWork = Substitute.For <IUnitOfWork>();

            datalist = new BaseDatalistProxy <Role, RoleView>(unitOfWork);
            unitOfWork.Select <Role>().To <RoleView>().Returns(new RoleView[0].AsQueryable());

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

            Assert.Same(expected, actual);
        }
Ejemplo n.º 11
0
        public void FilterById_FiltersByCurrentFilterId()
        {
            RoleView firstRole  = ObjectFactory.CreateRoleView(1);
            RoleView secondRole = ObjectFactory.CreateRoleView(2);

            IUnitOfWork unitOfWork = Substitute.For <IUnitOfWork>();

            datalist = new BaseDatalistProxy <Role, RoleView>(unitOfWork);
            IQueryable <RoleView> models = new[] { firstRole, secondRole }.AsQueryable();

            datalist.CurrentFilter.Id = firstRole.Id;

            IQueryable expected = models.Where(role => role.Id == firstRole.Id);
            IQueryable actual   = datalist.BaseFilterById(models);

            Assert.Equal(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 BaseDatalistProxy <Role, RoleView>(unitOfWork);

            datalist.CurrentFilter.Id = role.Id;

            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);
        }
Ejemplo n.º 13
0
 public void TestFixtureSetUp()
 {
     HttpContext.Current = HttpContextFactory.CreateHttpContext();
     datalist            = new BaseDatalistProxy <Role, RoleView>();
     unitOfWork          = Substitute.For <IUnitOfWork>();
 }
Ejemplo n.º 14
0
 public void SetUp()
 {
     HttpContext.Current = new HttpMock().HttpContext;
     datalist            = new BaseDatalistProxy <Role, RoleView>();
 }