示例#1
0
 private void GoalSetup()
 {
     AutoMapper.Mapper.CreateMap<ContestEventGoal, ContestEventGoalViewModel>()
         .ForMember(dest => dest.Result, opt => opt.ResolveUsing<GoalDataResolver>());
     profileRepositoryMock = new Moq.Mock<IProfileRepository>();
     profileRepositoryMock.Setup(t => t.RetrieveGoals()).Returns(goals);
     controller = new GoalController(profileRepositoryMock.Object);
 }
示例#2
0
        public void GetAllGoalsNoneReturnTest()
        {
            IList<ContestEventGoal> contestEventGoals = null;
            profileRepositoryMock.Setup(t => t.RetrieveGoals()).Returns(contestEventGoals);

            GoalController controller = new GoalController(profileRepositoryMock.Object);
            var results = controller.Get() as IEnumerable<ContestEventGoalViewModel>;

            Assert.IsNotNull(results);
            Assert.AreEqual(0, results.Count());
        }
示例#3
0
        public void GetAllGoalsTest()
        {
            profileRepositoryMock.Setup(t => t.RetrieveGoals()).Returns(new List<ContestEventGoal>(){
                new ContestEventGoal(){ Event = new Event(){ EventName = "test"}, Id = 1},
                new ContestEventGoal() { Event = new Event(){ EventName = "test2"}, Id = 2},
                new ContestEventGoal() { Event = new Event(){ EventName = "test3"}, Id = 3}
            });

            GoalController controller = new GoalController(profileRepositoryMock.Object);
            var results = controller.Get() as IEnumerable<ContestEventGoalViewModel>;

            Assert.IsNotNull(results);
            Assert.AreEqual(3, results.Count());
            Assert.AreEqual("test", results.First(t => t.Id == 1).Event.Name);
        }