Esempio n. 1
0
        public void GetAllGoals()
        {
            var goals = _goalService.GetGoals();

            Assert.AreEqual(1000, goals[0].Target);
            Assert.AreEqual(.25, goals[1].Progress);
        }
Esempio n. 2
0
        public void ShouldReturnAllGoalsOrderedById()
        {
            //Arrange
            IEnumerable <Goal> knownGoals = new List <Goal>()
            {
                new Goal(3, "Testing Goal 3", null, 103, GoalStatus.Open, false),
                new Goal(1, "Testing Goal 1", null, 101, GoalStatus.Open, false),
                new Goal(10, "Testing Goal 3", null, 110, GoalStatus.Cancelled, false),
                new Goal(5, "Testing Goal 5", null, 105, GoalStatus.Complete, true),
            };

            IEnumerable <Goal> orderedExpectedGoals = knownGoals.OrderBy(g => g.Id);

            //Setup the repository
            mockGoalRepository.Setup(gr => gr.GetGoals()).Returns(knownGoals);
            IGoalService goalService = new GoalService(mockGoalRepository.Object);

            //Act
            IEnumerable <Goal> returnedGoals = goalService.GetGoals();

            //Assert
            returnedGoals.Should().NotBeNull();
            returnedGoals.Should().BeInAscendingOrder(g => g.Id);
            IEnumerable <int> orderedIds = orderedExpectedGoals.Select(g => g.Id);

            returnedGoals.Select(g => g.Id).Should().ContainInOrder(orderedIds);
        }
Esempio n. 3
0
        public ActionResult Edit(int id)
        {
            var        service     = CreateBuildService();
            var        detail      = service.GetBuildById(id);
            var        userId      = Guid.Parse(User.Identity.GetUserId());
            CarService serviceCar2 = new CarService(userId);

            ViewBag.Cars = serviceCar2.GetCars();
            DecalService serviceDecal2 = new DecalService(userId);

            ViewBag.Decals = serviceDecal2.GetDecals();
            WheelsService serviceWheels2 = new WheelsService(userId);

            ViewBag.Wheelss = serviceWheels2.GetWheels();
            GoalService serviceGoal2 = new GoalService(userId);

            ViewBag.Goals = serviceGoal2.GetGoals();

            var model =
                new BuildEdit
            {
                BuildID   = detail.BuildID,
                BuildName = detail.BuildName,
            };

            return(View(model));
        }
Esempio n. 4
0
        public ActionResult Create(BuildCreate model)
        {
            var        userId     = Guid.Parse(User.Identity.GetUserId());
            CarService serviceCar = new CarService(userId);

            ViewBag.Cars = serviceCar.GetCars();
            DecalService serviceDecal = new DecalService(userId);

            ViewBag.Decals = serviceDecal.GetDecals();
            WheelsService serviceWheels = new WheelsService(userId);

            ViewBag.Wheelss = serviceWheels.GetWheels();
            GoalService serviceGoal = new GoalService(userId);

            ViewBag.Goals = serviceGoal.GetGoals();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBuildService();

            if (service.CreateBuild(model))
            {
                TempData["SaveResult"] = "Your build was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Build could not be created.");

            return(View(model));
        }
Esempio n. 5
0
        // GET: Goal
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new GoalService(userId);
            var model   = service.GetGoals();

            return(View(model));
        }
Esempio n. 6
0
        //GET
        public ActionResult Create()
        {
            var        userId     = Guid.Parse(User.Identity.GetUserId());
            CarService serviceCar = new CarService(userId);

            ViewBag.Cars = serviceCar.GetCars();
            DecalService serviceDecal = new DecalService(userId);

            ViewBag.Decals = serviceDecal.GetDecals();
            WheelsService serviceWheels = new WheelsService(userId);

            ViewBag.Wheelss = serviceWheels.GetWheels();
            GoalService serviceGoal = new GoalService(userId);

            ViewBag.Goals = serviceGoal.GetGoals();
            return(View());
        }
Esempio n. 7
0
        public ActionResult Edit(int id, BuildEdit model)
        {
            var        service     = CreateBuildService();
            var        detail      = service.GetBuildById(id);
            var        userId      = Guid.Parse(User.Identity.GetUserId());
            CarService serviceCar2 = new CarService(userId);

            ViewBag.Cars = serviceCar2.GetCars();
            DecalService serviceDecal2 = new DecalService(userId);

            ViewBag.Decals = serviceDecal2.GetDecals();
            WheelsService serviceWheels2 = new WheelsService(userId);

            ViewBag.Wheelss = serviceWheels2.GetWheels();
            GoalService serviceGoal2 = new GoalService(userId);

            ViewBag.Goals = serviceGoal2.GetGoals();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.BuildID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service2 = CreateBuildService();

            if (service2.UpdateBuild(model))
            {
                TempData["SaveResult"] = "Your build was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your build could not be updated.");
            return(View(model));
        }