示例#1
0
        internal Suggestion(IDatabaseTimeEntry timeEntry, SuggestionProviderType providerType)
        {
            ProviderType = providerType;

            TaskId      = timeEntry.TaskId;
            ProjectId   = timeEntry.ProjectId;
            IsBillable  = timeEntry.Billable;
            Description = timeEntry.Description;
            WorkspaceId = timeEntry.WorkspaceId;

            if (timeEntry.Project == null)
            {
                return;
            }

            HasProject   = true;
            ProjectName  = timeEntry.Project.Name;
            ProjectColor = timeEntry.Project.Color;

            ClientName = timeEntry.Project.Client?.Name ?? "";
            HasClient  = !string.IsNullOrEmpty(ClientName);

            if (timeEntry.Task == null)
            {
                return;
            }

            TaskName = timeEntry.Task.Name;
            HasTask  = true;
        }
            private Suggestion createSuggestion(SuggestionProviderType type = SuggestionProviderType.MostUsedTimeEntries)
            {
                var timeEntry = Substitute.For <IThreadSafeTimeEntry>();

                timeEntry.Duration.Returns((long)TimeSpan.FromMinutes(30).TotalSeconds);
                timeEntry.Description.Returns("Testing");
                timeEntry.WorkspaceId.Returns(10);
                return(new Suggestion(timeEntry, type));
            }
示例#3
0
        internal Suggestion(CalendarItem calendarItem, long workspaceId, SuggestionProviderType providerType)
        {
            Ensure.Argument.IsNotNullOrWhiteSpaceString(calendarItem.Description, nameof(calendarItem.Description));

            WorkspaceId = workspaceId;
            Description = calendarItem.Description;

            ProviderType = providerType;
        }
            public async Task TracksSuggestionStarted(SuggestionProviderType type)
            {
                var suggestion = createSuggestion(type);
                await ViewModel.Initialize();

                ViewModel.StartTimeEntry.Execute(suggestion);

                TestScheduler.Start();

                AnalyticsService.SuggestionStarted.Received().Track(type);
            }
 private Suggestion createSuggestionWithWorkspace(long workspaceId, string description, long taskId, long projectId, SuggestionProviderType type = SuggestionProviderType.MostUsedTimeEntries)
 => new Suggestion(
     TimeEntry.Builder.Create(0)
     .SetDescription(description)
     .SetStart(DateTimeOffset.UtcNow)
     .SetAt(DateTimeOffset.UtcNow)
     .SetTaskId(taskId)
     .SetProjectId(projectId)
     .SetWorkspaceId(workspaceId)
     .SetUserId(12)
     .Build(),
     type
     );
 private Suggestion createSuggestion(string description, long taskId, long projectId, SuggestionProviderType type = SuggestionProviderType.MostUsedTimeEntries)
 => createSuggestionWithWorkspace(11, description, taskId, projectId, type);
 private Suggestion createDefaultSuggestionFor(SuggestionProviderType type)
 => createSuggestion("Description", 12, 20, type);
 private Suggestion makeSuggestion(string description, long?projectId, SuggestionProviderType type)
 => new Suggestion(new MockTimeEntry
 {
     Description = description,
     ProjectId   = projectId
 }, type);