Beispiel #1
0
 public MvcLookupTests()
 {
     url    = Substitute.For <IUrlHelper>();
     lookup = new MvcLookup <Role, RoleView>(url);
     using (TestingContext context = new TestingContext())
         context.DropData();
 }
Beispiel #2
0
        public void MvcLookup_Defaults()
        {
            MvcLookup actual = Substitute.For <MvcLookup>();

            Assert.Empty(actual.AdditionalFilters);
            Assert.Equal(20, actual.Filter.Rows);
            Assert.Empty(actual.Columns);
        }
Beispiel #3
0
        public LookupControllerTests()
        {
            unitOfWork = Substitute.For <IUnitOfWork>();
            controller = Substitute.ForPartsOf <LookupController>(unitOfWork);

            lookup = Substitute.For <MvcLookup>();
            filter = new LookupFilter();
        }
        public void MvcLookup_SetsTitle()
        {
            lookup = new MvcLookup <Role, RoleView>(url);

            String expected = ResourceProvider.GetLookupTitle(typeof(RoleView).Name.Replace("View", ""));
            String actual   = lookup.Title;

            Assert.Equal(expected, actual);
        }
        public void MvcLookup_Defaults()
        {
            MvcLookup actual = Substitute.For<MvcLookup>();

            Assert.Equal("MvcLookupDialog", actual.Dialog);
            Assert.Empty(actual.AdditionalFilters);
            Assert.NotNull(actual.Filter);
            Assert.Empty(actual.Columns);
        }
Beispiel #6
0
        public void GetModels_FromUnitOfWork()
        {
            unitOfWork.Select <Role>().To <RoleView>().Returns(new RoleView[0].AsQueryable());

            Object actual   = new MvcLookup <Role, RoleView>(unitOfWork).GetModels();
            Object expected = unitOfWork.Select <Role>().To <RoleView>();

            Assert.Same(expected, actual);
        }
        public void MvcLookup_SetsUrl()
        {
            url.Action(Arg.Is <UrlActionContext>(context => context.Action == typeof(Role).Name && context.Controller == "Lookup")).Returns("Test");
            lookup = new MvcLookup <Role, RoleView>(url);

            String expected = "Test";
            String actual   = lookup.Url;

            Assert.Equal(expected, actual);
        }
Beispiel #8
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 MvcLookup <Role, RoleView>(unitOfWork);

            lookup.Filter.Id = role.Id.ToString();

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

            Assert.Equal(expected.CreationDate, actual.CreationDate);
            Assert.Equal(expected.Title, actual.Title);
            Assert.Equal(expected.Id, actual.Id);
        }
 public MvcLookupTests()
 {
     url    = Substitute.For <IUrlHelper>();
     lookup = new MvcLookup <Role, RoleView>(url);
 }
        public virtual JsonResult GetData(MvcLookup lookup, LookupFilter filter)
        {
            lookup.Filter = filter;

            return(Json(lookup.GetData()));
        }
Beispiel #11
0
 public MvcLookupTests()
 {
     lookup = new Mock<MvcLookup>().Object;
 }
Beispiel #12
0
 public MvcLookupTests()
 {
     unitOfWork = Substitute.For <IUnitOfWork>();
     lookup     = new MvcLookup <Role, RoleView>(unitOfWork);
 }