Example #1
0
        public async Task NotifyTriangleTasks_HasTasksToNotify_Notify()
        {
            IEmailService    emailService    = A.Fake <IEmailService>();
            IWorkTaskService workTaskService = A.Fake <IWorkTaskService>();

            TaskTriangleBuilder taskTriangleBuilder = new TaskTriangleBuilder();
            TaskTriangle        taskTriangle        = taskTriangleBuilder.AddContent("content1")
                                                      .AddResource("resource1")
                                                      .AddPercentageProgressToNotify(60)
                                                      .SetTime("20/09/2020", DayPeriod.Noon, 4, halfWorkDay: true)
                                                      .Build();

            IWorkTask workTask = A.Fake <IWorkTask>();

            A.CallTo(() => workTask.TaskMeasurement).Returns(taskTriangle);

            List <IWorkTask> workTasks = new List <IWorkTask>()
            {
                workTask
            };

            A.CallTo(() => workTaskService.FindWorkTasksByConditionAsync(A <Func <IWorkTask, bool> > .Ignored))
            .Returns(workTasks);

            NotifierService notifierService = new NotifierService(
                emailService, workTaskService, NullLogger <NotifierService> .Instance);

            await notifierService.NotifyTriangleTasks().ConfigureAwait(false);

            A.CallTo(() => emailService.SendEmail(A <string> .Ignored)).MustHaveHappenedOnceExactly();
        }
Example #2
0
        public async Task Serialize_WithTaskMeasurement_AsExpected()
        {
            JsonSerializerWrapper jsonSerializerWrapper = new JsonSerializerWrapper();

            TaskGroupFactory tasksGroupFactory = new TaskGroupFactory(
                A.Fake <IIDProducer>(), NullLogger <TaskGroupFactory> .Instance);

            OperationResult <ITasksGroup> tasksGroupA = tasksGroupFactory.CreateGroup("a group", mTasksGroupProducer);
            string taskId = tasksGroupFactory.CreateTask(tasksGroupA.Value, "task 1", mWorkTaskProducer).Value.ID;

            TaskTriangleBuilder taskTriangleBuilder = new TaskTriangleBuilder();

            taskTriangleBuilder.SetTime("18/10/2020".ToDateTime(), TimeSpan.FromDays(3.5))
            .AddContent("todo 1")
            .AddContent("todo 2")
            .AddResource("one developer");

            tasksGroupA.Value.SetMeasurement(taskId, taskTriangleBuilder.Build());
            tasksGroupA.Value.GetTask(taskId).Value.TaskMeasurement.Content.MarkContentDone("todo 2");

            List <ITasksGroup> entities = new List <ITasksGroup>
            {
                tasksGroupA.Value,
            };

            string tempSerializedFile = Path.GetRandomFileName();

            try
            {
                await jsonSerializerWrapper.Serialize(entities, tempSerializedFile).ConfigureAwait(false);

                string text = await File.ReadAllTextAsync(tempSerializedFile).ConfigureAwait(false);

                Assert.Contains("\"StartTime\": \"2020-10-18T00:00:00\"", text);
                Assert.Contains("\"ExpectedDuration\": \"3.12:00:00\"", text);
                Assert.Contains("\"todo 1\": false", text);
                Assert.Contains("\"todo 2\": true", text);
                Assert.Contains("\"one developer\"", text);
            }
            finally
            {
                File.Delete(tempSerializedFile);
            }
        }