public void ShouldAddLoadedResourcesForMethodWhenGettingGoalById()
        {
            //Arrange
            int                expectedId           = 10;
            string             expectedSqlStatement = "SELECT * FROM Goals;";
            IEnumerable <Goal> expectedGoals        = new List <Goal>()
            {
                new Goal(expectedId, "Testing Goal", "Mock Testing Goal", 100, GoalStatus.Open, false)
            };

            mockDataAccess.Setup(da => da.ExecuteQuery <Goal>(It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(expectedGoals);
            mockSqlStringService.Setup(ss => ss.GetSqlFromResource(It.IsAny <string>())).Returns <string>(val => { return($"{val} - {expectedSqlStatement}"); });
            IGoalRepository repository = new GoalRepository(mockDataAccess.Object, mockSqlStringService.Object);

            //Act
            Goal goal = repository.GetGoal(expectedId);

            //Assert
            goal.Should().NotBeNull();
            goal.Id.Should().Be(expectedId);

            GoalRepository goalRepo = (GoalRepository)repository;
            Dictionary <string, string> loadedResources = goalRepo.LoadedResources[nameof(repository.GetGoal)];

            loadedResources.Should().NotBeNull();
            loadedResources.Count.Should().Be(1);
        }
Beispiel #2
0
        public void GetGoal()
        {
            var repository     = new GoalRepository(GetTestFileFolder());
            var goal           = repository.GetGoal("8D642D0F-9CE1-4CF9-8CA6-828DFA25214E");
            var taskReferences = goal.TaskReferences[0];

            Assert.Equal("8D642D0F-9CE1-4CF9-8CA6-828DFA25214E", goal.Id);
            Assert.Equal("Highway to Hell Solo", goal.Title);
            Assert.Equal(2, goal.TaskReferences.Count);
            Assert.Equal("9306A3B1-6AAD-43F6-B083-C4D9FD045048", taskReferences.Id);
        }
Beispiel #3
0
        public void LoadGoalTasksFromTaskReferences()
        {
            var repository = new GoalRepository(GetTestFileFolder());
            var goal       = repository.GetGoal("8D642D0F-9CE1-4CF9-8CA6-828DFA25214E");
            var tasks      = repository.GetTasks(goal.TaskReferences);

            Assert.Equal(2, tasks.Count);
            Assert.Equal("290D51D0-6918-41CE-9734-8EA7870DB218", tasks[1].Id);
            Assert.Equal("Highway to Hell - Lick 2", tasks[1].Title);
            Assert.Equal(0, tasks[1].Initial);
            Assert.Equal(100, tasks[1].Target);
            Assert.Equal(3, tasks[1].Activity.Count);
            Assert.Equal(DateTime.Parse("2019-05-04"), tasks[1].Activity[0].Date);
            Assert.Equal(33.33, tasks[1].Activity[0].Value);
        }
Beispiel #4
0
 public GoalModel Get(int id)
 {
     return(GoalRepository.GetGoal(id));
 }