public void TestGetGoals()
        {
            var options = new DbContextOptionsBuilder <MyPracticeJournalContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            using (var db = new  MyPracticeJournalContext(options))
            {
                db.Goals.Add(new Goal {
                    Name = "One"
                });
                db.Goals.Add(new Goal {
                    Name = "Two"
                });
                db.Goals.Add(new Goal {
                    Name = "Three"
                });
                db.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var context = new MyPracticeJournalContext(options))
            {
                var service = new GoalService(_mapper, context);
                var result  = service.GetGoal(1);
                Assert.IsNotNull(result);
            }
        }
示例#2
0
        public void ShouldThrowANullReferenceExceptionWhenGoalWithIDDoesNotExist()
        {
            //Arrange
            int expectedGoalID = 1;

            mockGoalRepository.Setup(gr => gr.GetGoal(It.Is <int>(val => val == expectedGoalID))).Returns(null as Goal);
            IGoalService service = new GoalService(mockGoalRepository.Object);

            //Act
            Action failAction = () => service.GetGoal(expectedGoalID);

            //Assert
            failAction.Should().Throw <ArgumentOutOfRangeException>();
        }
示例#3
0
        public Goal GetAGoal(string teamName, string goalName)
        {
            var goal = _goalService.GetGoal(teamName, goalName);

            return(goal);
        }
示例#4
0
 public GoalDTO Get(int id)
 {
     return(goalService.GetGoal(id));
 }