예제 #1
0
        public ActionResult Index(string sortOrder, string searchString, int?page)
        {
            BaseMakeVehicleService makes = new VehicleMakeService();
            var makesToDisplay           = makes.Index(sortOrder, searchString, page);

            return(View(makesToDisplay.ToPagedList(page ?? 1, 5)));
        }
예제 #2
0
        public async void FindMakeAsync_Returns_PagedList_Makers()
        {
            var sortMock      = new Mock <ISortingParams>();
            var filterMock    = new Mock <IFilteringParams>();
            var pageMock      = new Mock <IPagingParams>();
            var pagedListMock = new Mock <IPagedList <IVehicleMake> >();

            pagedListMock.Setup(s => s.Count).Returns(10);
            pagedListMock.Setup(s => s.PageNumber).Returns(10);
            pagedListMock.Setup(s => s.PageSize).Returns(10);
            pagedListMock.Setup(s => s.TotalItemCount).Returns(10);


            repoMock.Setup(s => s.FindMakeAsync(It.IsAny <IFilteringParams>(),
                                                It.IsAny <ISortingParams>(),
                                                It.IsAny <IPagingParams>()))
            .Returns(Task.FromResult(pagedListMock.Object));

            uowMock.SetupGet(s => s.Makers).Returns(repoMock.Object);



            var makeService = new VehicleMakeService(uowMock.Object);
            var result      = await makeService.FindMakeAsync(filterMock.Object, sortMock.Object, pageMock.Object);

            //Assert
            Assert.Equal(10, result.TotalItemCount);
            Assert.Equal(10, result.Count);
            Assert.Equal(10, result.PageSize);
            Assert.Equal(10, result.PageNumber);
        }
예제 #3
0
        public VehicleMakeViewModel(VehicleMakeService vehicleMakeService, IMapper m)
        {
            vms          = vehicleMakeService;
            vehicleMake  = AutofacHelper.GetInstance().GetContainer().Resolve <VehicleMakeModel>();
            mapper       = m;
            VehicleMakes = new ObservableCollection <VehicleMakeModel>();
            GetVehicleMake();

            CreateComand = new Command(() =>
            {
                CreateCommandFunction();
            });

            DeleteComand = new Command(() =>
            {
                DeleteCommandFunction();
            });

            UpdateCommand = new Command(() =>
            {
                UpdateCommandFunction();
            });

            SelectedMakeCommand = new Command(() =>
            {
                SeletedMakeCommandFunction();
            });

            SearchCommand = new Command(() =>
            {
                SearchFunction();
            });
        }
        // GET: VehicleModel/Edit/5
        public ActionResult Edit(Guid?id)
        {
            var _service2 = new VehicleMakeService();
            var makes     = _service2.GetAll();

            ViewBag.List = new SelectList(makes, "Id", "Name");
            return(View(_serviceModel.Get(id)));
        }
예제 #5
0
        public ActionResult Delete(int id)
        {
            BaseMakeVehicleService makeToDelete = new VehicleMakeService();

            makeToDelete.Delete(id);

            return(RedirectToAction("Index", "VehicleMakes"));
        }
예제 #6
0
        public ActionResult Save(VehicleMake vehiclemake)
        {
            BaseMakeVehicleService makeToSave = new VehicleMakeService();

            makeToSave.Save(vehiclemake);

            return(RedirectToAction("Index", "VehicleMakes"));
        }
예제 #7
0
        public async void GetMakeAsync_Returns_IVehicleMake()
        {
            repoMock.Setup(s => s.GetAsync(It.IsAny <Guid>())).Returns(Task.FromResult(new Mock <IVehicleMake>().Object));
            uowMock.SetupGet(s => s.Makers).Returns(repoMock.Object);

            var makeService = new VehicleMakeService(uowMock.Object);
            var make        = await makeService.GetMakeAsync(Guid.NewGuid());

            //Assert
            Assert.NotNull(make);
            Assert.IsAssignableFrom <IVehicleMake>(make);
        }
예제 #8
0
        public ActionResult Edit(int id)
        {
            BaseMakeVehicleService makeToEdit = new VehicleMakeService();
            var vehicleMakeToEdit             = makeToEdit.Edit(id);

            if (vehicleMakeToEdit == null)
            {
                return(HttpNotFound());
            }

            return(View("VehicleMakeForm", vehicleMakeToEdit));
        }
예제 #9
0
        public async void RemoveMakeAsync_Returns_1()
        {
            repoMock.Setup(s => s.RemoveAsync(It.IsAny <Guid>())).Returns(Task.FromResult(1));
            uowMock.SetupGet(s => s.Makers).Returns(repoMock.Object);
            uowMock.Setup(s => s.CommitAsync()).Returns(Task.FromResult(1));


            var makeService = new VehicleMakeService(uowMock.Object);
            var result      = await makeService.RemoveMakeAsync(Guid.NewGuid());

            //Assert
            Assert.Equal(1, result);
        }
예제 #10
0
        public async void UpdateMakeAsync_Returns_1()
        {
            repoMock.Setup(s => s.UpdateAsync(It.IsAny <IVehicleMake>()));
            uowMock.SetupGet(s => s.Makers).Returns(repoMock.Object);
            uowMock.Setup(s => s.CommitAsync()).Returns(Task.FromResult(1));


            var makeService = new VehicleMakeService(uowMock.Object);
            var result      = await makeService.UpdateMakeAsync(new Mock <IVehicleMake>().Object);

            //Assert
            Assert.Equal(1, result);
        }
예제 #11
0
        public void GetAllAsync_Returns_Enumerable_IVehicleMakeBase()
        {
            var list = new Mock <IEnumerable <IVehicleMakeBase> >();

            repoMock.Setup(s => s.GetMakerBaseAsync()).Returns(new Task <IEnumerable <IVehicleMakeBase> >(() => list.Object));
            uowMock.SetupGet(s => s.Makers).Returns(repoMock.Object);


            var makeService = new VehicleMakeService(uowMock.Object);
            var make        = makeService.GetAllMakeAsync();


            //Assert
            Assert.IsAssignableFrom <Task <IEnumerable <IVehicleMakeBase> > >(make);
        }
예제 #12
0
        public async void AddMakeAsync_Returns_Maker()
        {
            Guid guid  = Guid.NewGuid();
            var  maker = new Mock <IVehicleMake>();

            maker.Setup(s => s.Id).Returns(guid);
            repoMock.Setup(s => s.AddAsync(It.IsAny <IVehicleMake>())).Returns(Task.FromResult(maker.Object));
            uowMock.SetupGet(s => s.Makers).Returns(repoMock.Object);

            var makeService = new VehicleMakeService(uowMock.Object);
            var make        = await makeService.AddMakeAsync(maker.Object);

            //Assert
            Assert.NotNull(make);
            Assert.Equal(guid, make.Id);
        }
예제 #13
0
 public MakeController(VehicleMakeService service)
 {
     this.service = service;
 }
예제 #14
0
 public AddVehicleMakerVievModel(ObservableCollection <VehicleMake> vehicleMakes)
 {
     vehicleMakeService = new VehicleMakeService();
     vehicleMakeService.SetVehicleMakeList(vehicleMakes);
 }
예제 #15
0
 public VehicleMakeController()
 {
     VehicleMakeService = AutofacConfig.Container.Resolve <VehicleMakeService>();
     mapper             = AutofacConfig.Container.Resolve <IMapper>();
 }
예제 #16
0
 public EditVehicleMakeViewModel(VehicleMake vm, ObservableCollection <VehicleMake> lVehicleMake)
 {
     vehicleMake        = vm;
     vehicleMakeService = new VehicleMakeService();
     vehicleMakeService.SetVehicleMakeList(lVehicleMake);
 }