Esempio n. 1
0
        public void Details_finds_the_correct_issue_when_called()
        {
            // Act
            var result = controller.Details(1) as ViewResult;

            // Assert
            result.Model.ShouldDeepEqual(votableIssue.ConvertToDetailsViewModel(""));
        }
        public void Can_be_converted_from_a_raw_entity_with_an_extension_method()
        {
            // Arrange
            Issue issueEntity = Mock.Of <Issue>(
                i => i.Title == "Title" &&
                i.ShortDescription == "Short" &&
                i.LongDescription == "Long" &&
                i.StateAbbrev == "MO" &&
                i.IsStateIssue == true &&
                i.FundingGoal == 50000.00 &&
                i.Id == 1 &&
                i.FundingRaised == 2500 &&
                i.GetPrettyPercentage() == "60" &&
                i.GetVoteForUser("test") == Mock.Of <Vote>(v => v.IsUpvote == true) &&
                i.TotalVotes() == 12
                );

            // Act
            DetailsViewModel vm = issueEntity.ConvertToDetailsViewModel("test");

            // Assert
            Assert.AreEqual(1, vm.Id);
            Assert.AreEqual("Title", vm.Title);
            Assert.AreEqual("Short", vm.ShortDescription);
            Assert.AreEqual("Long", vm.LongDescription);
            Assert.AreEqual(12, vm.VoteCount);
            Assert.AreEqual("MO", vm.IssueScope);
            Assert.AreEqual("60", vm.ApprovalPercentage);
            Assert.AreEqual(2500, vm.FundingRaised);
            Assert.AreEqual(50000, vm.FundingGoal);
            Assert.AreEqual("btn-success", vm.UpvoteButtonColor);
            Assert.AreEqual("btn-default", vm.DownvoteButtonColor);
        }
Esempio n. 3
0
        // GET: Issues/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Issue issue = _repo.Find((int)id);

            if (issue == null)
            {
                return(HttpNotFound());
            }
            return(View(issue.ConvertToDetailsViewModel(User.Identity.GetUserId())));
        }