Example #1
0
        public void Size_NumberOfTasks3()
        {
            ITasksGroup taskGroup = mTaskGroupFactory.CreateGroup("TestGroup", mTasksGroupProducer).Value;

            mTaskGroupFactory.CreateTask(taskGroup, "task1", mWorkTaskProducer);
            mTaskGroupFactory.CreateTask(taskGroup, "task2", mWorkTaskProducer);
            mTaskGroupFactory.CreateTask(taskGroup, "task3", mWorkTaskProducer);

            Assert.Equal(3, taskGroup.Size);
        }
Example #2
0
        public async Task Serialize_AsExpected()
        {
            JsonSerializerWrapper jsonSerializerWrapper = new JsonSerializerWrapper();

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

            OperationResult <ITasksGroup> tasksGroupA = tasksGroupFactory.CreateGroup("a group", mTasksGroupProducer);

            tasksGroupFactory.CreateTask(tasksGroupA.Value, "task 1", mWorkTaskProducer);

            OperationResult <ITasksGroup> tasksGroupB = tasksGroupFactory.CreateGroup("b group", mTasksGroupProducer);

            tasksGroupFactory.CreateTask(tasksGroupB.Value, "task 3", mWorkTaskProducer);

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

            string tempSerializedFile = Path.GetRandomFileName();

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

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

                Assert.Contains("\"GroupName\": \"a group\"", text);
                Assert.Contains("\"Description\": \"task 1\"", text);
                Assert.Contains("\"GroupName\": \"b group\"", text);
                Assert.Contains("\"Description\": \"task 3\"", text);
            }
            finally
            {
                File.Delete(tempSerializedFile);
            }
        }
Example #3
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);
            }
        }