예제 #1
0
        public async Task SetProjectBillingByUserRateAsync_ReturnsProject()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.SET_PROJECT_BILLING)));
            var users = new List <Models.UserWithRate>()
            {
                new Models.UserWithRate()
                {
                    Id = 1234, Rate = 10000
                },
                new Models.UserWithRate()
                {
                    Id = 5678, Rate = 10000
                }
            };
            var res = await MockApi.Object.SetProjectBillingByUserRateAsync("as:1234567890", users);

            Assert.NotNull(res);
            Assert.NotNull(res.Project.Id);
            Assert.NotNull(res.Project.Name);
            Assert.NotNull(res.Project.WorkspaceId);
            Assert.NotNull(res.Project.Workspace);
            Assert.Equal(Models.ProjectType.BOARD, res.Project.Type);
            Assert.True(res.Project.Favorite);
            Assert.NotNull(res.Project.Users);
            Assert.NotNull(res.Project.Budget);
            Assert.NotEqual(default(int), res.Project.Budget.Value);
            Assert.NotEqual(default(int), res.Project.Budget.Progress);
            Assert.Equal(Models.BudgetType.MONEY, res.Project.Budget.Type);
            Assert.NotNull(res.Project.Billing);
            Assert.Equal(Models.BillingType.FLAT_RATE, res.Project.Billing.Type);
            Assert.NotEqual(default(int), res.Project.Billing.Rate);
            Assert.NotNull(res.Project.Billing.Users);
        }
예제 #2
0
        public async Task CreateTaskAsync_ReturnsTask()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.CREATE_TASK)));
            var res = await MockApi.Object.CreateTaskAsync("ev:1234567890", "Task Name", 1234);

            Assert.NotNull(res);
            Assert.NotNull(res.Task.Id);
            Assert.NotNull(res.Task.Name);
            Assert.NotNull(res.Task.Projects);
            Assert.NotEqual(default(int), res.Task.Section);
            Assert.NotNull(res.Task.Labels);
            Assert.NotEqual(default(int), res.Task.Position);
            Assert.NotNull(res.Task.Description);
            Assert.NotEqual(default(DateTime), res.Task.DueAt);
            Assert.Equal(Models.TaskStatus.OPEN, res.Task.Status);
            Assert.NotEqual(default(int), res.Task.Time.Total);
            Assert.NotNull(res.Task.Time.Users);
            Assert.NotEqual(default(int), res.Task.Estimate.Total);
            Assert.Equal(Models.EstimateType.OVERALL, res.Task.Estimate.Type);
            Assert.NotNull(res.Task.Estimate.Users);
            Assert.Equal("Everhour", res.Task.Attributes[0].Client);
            Assert.Equal("hight", res.Task.Attributes[0].Priority);
            Assert.Equal(42, res.Task.Metrics[0].Efforts);
            Assert.Equal(199, res.Task.Metrics[0].Expenses);
        }
예제 #3
0
        public async Task CreateProjectAsyncWithRequest_ReturnsProject()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.CREATE_PROJECT)));

            var req = new Models.CreateProjectRequest()
            {
                Name  = "Test Project",
                Type  = Models.ProjectType.BOARD,
                Users = new List <int>()
                {
                    1, 2, 3
                }
            };
            var res = await MockApi.Object.CreateProjectAsync(req);

            Assert.NotNull(res);
            Assert.NotNull(res.Project.Id);
            Assert.NotNull(res.Project.Name);
            Assert.NotNull(res.Project.WorkspaceId);
            Assert.NotNull(res.Project.Workspace);
            Assert.Equal(Models.ProjectType.BOARD, res.Project.Type);
            Assert.True(res.Project.Favorite);
            Assert.NotNull(res.Project.Users);
            Assert.NotNull(res.Project.Budget);
            Assert.NotEqual(default(int), res.Project.Budget.Value);
            Assert.NotEqual(default(int), res.Project.Budget.Progress);
            Assert.Equal(Models.BudgetType.MONEY, res.Project.Budget.Type);
            Assert.NotNull(res.Project.Billing);
            Assert.Equal(Models.BillingType.FLAT_RATE, res.Project.Billing.Type);
            Assert.NotEqual(default(int), res.Project.Billing.Rate);
            Assert.NotNull(res.Project.Billing.Users);
        }
예제 #4
0
        public async Task ListProjectTasksAsync_ReturnsTasks()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.LIST_PROJECT_TASKS)));
            var res = await MockApi.Object.ListProjectTasksAsync("ev:1234567890");

            Assert.NotNull(res);
            Assert.All(res.Tasks, t => Assert.NotNull(t.Id));
            Assert.All(res.Tasks, t => Assert.NotNull(t.Name));
            Assert.All(res.Tasks, t => Assert.NotNull(t.Projects));
            Assert.All(res.Tasks, t => Assert.NotEqual(default(int), t.Section));
            Assert.All(res.Tasks, t => Assert.NotNull(t.Labels));
            Assert.All(res.Tasks, t => Assert.NotEqual(default(int), t.Position));
            Assert.All(res.Tasks, t => Assert.NotNull(t.Description));
            Assert.All(res.Tasks, t => Assert.NotEqual(default(DateTime), t.DueAt));
            Assert.All(res.Tasks, t => Assert.Equal(Models.TaskStatus.OPEN, t.Status));
            Assert.All(res.Tasks, t => Assert.NotEqual(default(int), t.Time.Total));
            Assert.All(res.Tasks, t => Assert.NotNull(t.Time.Users));
            Assert.All(res.Tasks, t => Assert.NotEqual(default(int), t.Estimate.Total));
            Assert.All(res.Tasks, t => Assert.Equal(Models.EstimateType.OVERALL, t.Estimate.Type));
            Assert.All(res.Tasks, t => Assert.NotNull(t.Estimate.Users));
            Assert.All(res.Tasks, t => Assert.Equal("Everhour", t.Attributes[0].Client));
            Assert.All(res.Tasks, t => Assert.Equal("hight", t.Attributes[0].Priority));
            Assert.All(res.Tasks, t => Assert.Equal(42, t.Metrics[0].Efforts));
            Assert.All(res.Tasks, t => Assert.Equal(199, t.Metrics[0].Expenses));
        }
예제 #5
0
        public async Task ExportTeamTimeAsyncWithParams_ReturnsTeamTime()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.EXPORT_TIME)));

            var req = new Models.ExportAllTeamTimeRequest
            {
                From   = DateTime.UtcNow,
                To     = DateTime.UtcNow.AddDays(1),
                Fields = Models.ExportAllTeamTimeField.PROJECT
                         | Models.ExportAllTeamTimeField.TASK
                         | Models.ExportAllTeamTimeField.DATE
                         | Models.ExportAllTeamTimeField.USER
            };
            var res = await MockApi.Object.ExportAllTeamTimeAsync(req);

            Assert.NotNull(res);
            Assert.All(res.TeamTimes, e => Assert.NotEqual(default(int), e.Time));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Date));
            Assert.All(res.TeamTimes, e => Assert.NotEqual(default(int), e.Time));
            Assert.All(res.TeamTimes, e => Assert.NotEqual(default(int), e.User.Id));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.User.Name));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Project.Id));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Project.Name));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Project.Workspace));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Task.Id));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Task.Name));
            Assert.All(res.TeamTimes, e => Assert.Equal(Models.TaskType.TASK, e.Task.Type));
        }
예제 #6
0
        public async Task CreateClientAsyncWithRequest_ReturnsClient()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.CREATE_CLIENT)));

            var req = new Models.CreateClientRequest()
            {
                Name     = "Test Client",
                Projects = new List <string>()
                {
                    "Test Project"
                },
                BusinessDetails = "Business Details"
            };
            var res = await MockApi.Object.CreateClientAsync(req);

            Assert.NotNull(res);
            Assert.NotEqual(default(int), res.Client.Id);
            Assert.NotNull(res.Client.Name);
            Assert.NotNull(res.Client.Projects);
            Assert.NotNull(res.Client.BusinessDetails);
            Assert.NotEqual(default(int), res.Client.Budget.Value);
            Assert.NotEqual(default(int), res.Client.Budget.Progress);
            Assert.Equal(Models.BudgetType.MONEY, res.Client.Budget.Type);
        }
예제 #7
0
        public async Task ExportAllTeamEstimatesAsyncWithParams_ReturnsTeamEstimates()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(Specification.EXPORT_ESITIMATES)
            }));

            var req = new Models.ExportAllTeamEstimatesRequest()
            {
                DueFrom = DateTime.UtcNow,
                DueTo   = DateTime.UtcNow.AddDays(1),
                Status  = Models.TaskStatus.OPEN
            };
            var res = await MockApi.Object.ExportAllTeamEstimatesAsync(req);

            Assert.NotNull(res);
            Assert.All(res.TeamEstimates, e => Assert.NotEqual(default(int), e.Time.Total));
            Assert.All(res.TeamEstimates, e => Assert.NotEqual(default(int), e.Estimate.Total));
            Assert.All(res.TeamEstimates, e => Assert.Equal(Models.EstimateType.OVERALL, e.Estimate.Type));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Project.Id));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Project.Name));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Project.Workspace));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Task.Id));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Task.Name));
            Assert.All(res.TeamEstimates, e => Assert.Equal(Models.TaskType.TASK, e.Task.Type));
        }
예제 #8
0
        public async Task DeleteProjectBillingAsync_ReturnsIsSuucessful()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse()));
            var res = await MockApi.Object.DeleteProjectBillingAsync("as:1234567890");

            Assert.True(res);
        }
예제 #9
0
        public async Task DeleteTaskEstimateAsync_ReturnsTask()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse()));
            var res = await MockApi.Object.DeleteTaskEstimateAsync("ev:9876543210");

            Assert.True(res);
        }
예제 #10
0
        public async Task DeleteSectionAsync_ReturnsSection()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse()));
            var res = await MockApi.Object.DeleteSectionAsync(1234);

            Assert.True(res);
        }
예제 #11
0
        public async Task SetTaskEstimateAsyncByOverAll_ReturnsTask()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.SET_TASK_ESTIMATE)));
            var res = await MockApi.Object.SetTaskEstimateAsyncByOverAll("ev:9876543210", 7200);

            Assert.NotNull(res);
            Assert.NotNull(res.Estimate.Total);
            Assert.NotNull(res.Estimate.Type);
            Assert.Null(res.Estimate.Users);
        }
예제 #12
0
        public async Task ListTeamUsersAsync_ReturnsUsers()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.LIST_USERS)));
            var res = await MockApi.Object.ListTeamUsersAsync();

            Assert.NotNull(res.Users);
            Assert.All(res.Users, user => Assert.NotEqual(default(int), user.Id));
            Assert.All(res.Users, user => Assert.Equal(Models.RoleType.ADMIN, user.Role));
            Assert.All(res.Users, user => Assert.Equal(Models.UserStatus.ACTIVE, user.Status));
        }
예제 #13
0
        public async Task AddTimeToTaskAsyncWithRequest_ReturnsTimeRecord()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.ADD_TIME_TO_TASK)));

            var req = new Models.AddTimeToTaskRequest()
            {
                TaskId = "ev:1234567890",
                Time   = 3600,
                Date   = DateTime.UtcNow,
                User   = 1234
            };
            var res = await MockApi.Object.AddTimeToTaskAsync(req);

            Assert.NotNull(res);
            Assert.Equal(2660155, res.TimeRecord.Id);
            Assert.Equal(3600, res.TimeRecord.Time);
            Assert.Equal(1304, res.TimeRecord.User);
            Assert.Equal(new DateTime(2018, 1, 20), res.TimeRecord.Date);
            Assert.Equal("ev:9876543210", res.TimeRecord.Task.Id);
            Assert.Equal("Task Name", res.TimeRecord.Task.Name);
            Assert.Equal(new List <string>()
            {
                "ev:1234567890"
            }, res.TimeRecord.Task.Projects);
            Assert.Equal(1234, res.TimeRecord.Task.Section);
            Assert.Equal(new List <string>()
            {
                "high", "bug"
            }, res.TimeRecord.Task.Labels);
            Assert.Equal(1, res.TimeRecord.Task.Position);
            Assert.Equal("description", res.TimeRecord.Task.Description);
            Assert.Equal(new DateTime(2018, 3, 5, 16, 0, 0), res.TimeRecord.Task.DueAt);
            Assert.Equal(Models.TaskStatus.OPEN, res.TimeRecord.Task.Status);
            Assert.Equal(7200, res.TimeRecord.Task.Time.Total);
            Assert.Equal(1304, res.TimeRecord.Task.Time.Users[0].Id);
            Assert.Equal(3600, res.TimeRecord.Task.Time.Users[0].Time);
            Assert.Equal(1543, res.TimeRecord.Task.Time.Users[1].Id);
            Assert.Equal(3600, res.TimeRecord.Task.Time.Users[1].Time);
            Assert.Equal(7200, res.TimeRecord.Task.Estimate.Total);
            Assert.Equal(Models.EstimateType.OVERALL, res.TimeRecord.Task.Estimate.Type);
            Assert.Equal(1304, res.TimeRecord.Task.Estimate.Users[0].Id);
            Assert.Equal(3600, res.TimeRecord.Task.Estimate.Users[0].Time);
            Assert.Equal(1543, res.TimeRecord.Task.Estimate.Users[1].Id);
            Assert.Equal(3600, res.TimeRecord.Task.Estimate.Users[1].Time);
            Assert.Equal("Everhour", res.TimeRecord.Task.Attributes[0].Client);
            Assert.Equal("hight", res.TimeRecord.Task.Attributes[0].Priority);
            Assert.Equal(42, res.TimeRecord.Task.Metrics[0].Efforts);
            Assert.Equal(199, res.TimeRecord.Task.Metrics[0].Expenses);
            Assert.True(res.TimeRecord.IsLocked);
            Assert.True(res.TimeRecord.IsInvoiced);
            Assert.Equal("some notes", res.TimeRecord.Comment);
        }
예제 #14
0
        public async Task StartTimerAsyncWithRequest_ReturnsTimer()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(Specification.START_TIMER)
            }));

            var req = new Models.StartTimerRequest()
            {
                TaskId   = "ev:1234567890",
                UserDate = DateTime.UtcNow,
                Comment  = "comment"
            };
            var res = await MockApi.Object.StartTimerAsync(req);

            Assert.NotNull(res);
            Assert.Equal(Models.TimerStatus.ACTIVE, res.Timer.Status);
            Assert.Equal(16, res.Timer.Duration);
            Assert.Equal(7200, res.Timer.Today);
            Assert.Equal(new DateTime(2018, 01, 16, 12, 42, 59), res.Timer.StartedAt);
            Assert.Equal(new DateTime(2018, 01, 16), res.Timer.UserDate);
            Assert.Equal("comment", res.Timer.Comment);
            Assert.Equal(1234, res.Timer.Task.Section);
            Assert.Equal(new List <string>()
            {
                "high", "bug"
            }, res.Timer.Task.Labels);
            Assert.Equal(1, res.Timer.Task.Position);
            Assert.Equal("description", res.Timer.Task.Description);
            Assert.Equal(new DateTime(2018, 3, 5, 16, 0, 0), res.Timer.Task.DueAt);
            Assert.Equal(Models.TaskStatus.OPEN, res.Timer.Task.Status);
            Assert.Equal(7200, res.Timer.Task.Time.Total);
            Assert.Equal(1304, res.Timer.Task.Time.Users[0].Id);
            Assert.Equal(3600, res.Timer.Task.Time.Users[0].Time);
            Assert.Equal(1543, res.Timer.Task.Time.Users[1].Id);
            Assert.Equal(3600, res.Timer.Task.Time.Users[1].Time);
            Assert.Equal(7200, res.Timer.Task.Estimate.Total);
            Assert.Equal(Models.EstimateType.OVERALL, res.Timer.Task.Estimate.Type);
            Assert.Equal(1304, res.Timer.Task.Estimate.Users[0].Id);
            Assert.Equal(3600, res.Timer.Task.Estimate.Users[0].Time);
            Assert.Equal(1543, res.Timer.Task.Estimate.Users[1].Id);
            Assert.Equal(3600, res.Timer.Task.Estimate.Users[1].Time);
            Assert.Equal("Everhour", res.Timer.Task.Attributes[0].Client);
            Assert.Equal("hight", res.Timer.Task.Attributes[0].Priority);
            Assert.Equal(42, res.Timer.Task.Metrics[0].Efforts);
            Assert.Equal(199, res.Timer.Task.Metrics[0].Expenses);
            Assert.Equal(1304, res.Timer.User.Id);
            Assert.Equal("User Name", res.Timer.User.Name);
            Assert.Equal("CEO", res.Timer.User.Headline);
            Assert.Equal(Models.RoleType.ADMIN, res.Timer.User.Role);
            Assert.Equal(Models.UserStatus.ACTIVE, res.Timer.User.Status);
        }
예제 #15
0
        public void AddTerm_AddingDuplicateWithCacheEnabled_DoesNotThrow()
        {
            var termCache = new List <string>();

            termCache.Add("hello");
            MockApi.Setup(x => x.GetAllTermsInTermListAsStringsAsync(sut.ListID.ToString(), sut.Language))
            .Returns(Task.FromResult(termCache));

            sut.EnableTermCache();

            sut.AddTerm("hello").Wait();
        }
예제 #16
0
        public async Task ListTeamTimeRecordsAsyncWithFromTo_ReturnsTimeRecord()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.LIST_TEAM_TIME_RECORDS)));

            var res = await MockApi.Object.ListTeamTimeRecordsAsync(DateTime.UtcNow, DateTime.UtcNow);

            Assert.NotNull(res);
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(2660155, t.Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(3600, t.Time));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1304, t.User));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(new DateTime(2018, 1, 20), t.Date));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal("ev:9876543210", t.Task.Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal("Task Name", t.Task.Name));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(new List <string>()
            {
                "ev:1234567890"
            }, t.Task.Projects));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1234, t.Task.Section));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(new List <string>()
            {
                "high", "bug"
            }, t.Task.Labels));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1, t.Task.Position));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal("description", t.Task.Description));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(new DateTime(2018, 3, 5, 16, 0, 0), t.Task.DueAt));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(Models.TaskStatus.OPEN, t.Task.Status));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(7200, t.Task.Time.Total));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1304, t.Task.Time.Users[0].Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(3600, t.Task.Time.Users[0].Time));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1543, t.Task.Time.Users[1].Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(3600, t.Task.Time.Users[1].Time));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(7200, t.Task.Estimate.Total));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(Models.EstimateType.OVERALL, t.Task.Estimate.Type));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1304, t.Task.Estimate.Users[0].Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(3600, t.Task.Estimate.Users[0].Time));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1543, t.Task.Estimate.Users[1].Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(3600, t.Task.Estimate.Users[1].Time));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal("Everhour", t.Task.Attributes[0].Client));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal("hight", t.Task.Attributes[0].Priority));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(42, t.Task.Metrics[0].Efforts));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(199, t.Task.Metrics[0].Expenses));
            Assert.All(res.TeamTimeRecords, t => Assert.True(t.IsLocked));
            Assert.All(res.TeamTimeRecords, t => Assert.True(t.IsInvoiced));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal("some notes", t.Comment));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(4622379, t.History[0].Id));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(1304, t.History[0].CreatedBy));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(3600, t.History[0].Time));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(0, t.History[0].PreviousTime));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(Models.HistoryStatus.TIMER, t.History[0].Status));
            Assert.All(res.TeamTimeRecords, t => Assert.Equal(new DateTime(2018, 1, 16, 12, 42, 59), t.History[0].CreatedAt));
        }
예제 #17
0
        public async Task UpdateSectionAsync_ReturnsSection()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.UPDATE_SECTION)));
            var res = await MockApi.Object.UpdateSectionAsync(1234, "Test Section");

            Assert.NotNull(res);
            Assert.NotEqual(default(int), res.Section.Id);
            Assert.NotNull(res.Section.Name);
            Assert.NotEqual(default(int), res.Section.Position);
            Assert.NotNull(res.Section.Project);
            Assert.Equal(Models.SectionStatus.OPEN, res.Section.Status);
        }
예제 #18
0
        public async Task ListProjectSectionsAsync_ReturnsSections()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.LIST_PROJECT_SECTIONS)));
            var res = await MockApi.Object.ListProjectSectionsAsync("ev:1234567890");

            Assert.NotNull(res);
            Assert.All(res.Sections, s => Assert.NotEqual(default(int), s.Id));
            Assert.All(res.Sections, s => Assert.NotNull(s.Name));
            Assert.All(res.Sections, s => Assert.NotEqual(default(int), s.Position));
            Assert.All(res.Sections, s => Assert.NotNull(s.Project));
            Assert.All(res.Sections, s => Assert.Equal(Models.SectionStatus.OPEN, s.Status));
        }
예제 #19
0
        public async Task MeAsync_ReturnsUser()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(Specification.ME)
            }));
            var res = await MockApi.Object.MeAsync();

            Assert.NotNull(res);
            Assert.NotEqual(default(int), res.Me.Id);
            Assert.Equal(Models.RoleType.ADMIN, res.Me.Role);
            Assert.Equal(Models.UserStatus.ACTIVE, res.Me.Status);
        }
예제 #20
0
        public void AddTerm_AddingDuplicateWithCacheDisabled_Throws()
        {
            var termCache = new List <string>();
            var term      = "hello";

            termCache.Add(term);
            MockApi.Setup(x => x.GetAllTermsInTermListAsStringsAsync(sut.ListID.ToString(), sut.Language))
            .Returns(Task.FromResult(termCache));
            MockApi.Setup(x => x.AddTermToTermListAsync(sut.ListID.ToString(), term, sut.Language))
            .Throws <Exception>();
            sut.DisableTermCache();

            Assert.Throws <AggregateException>(() => sut.AddTerm("hello").Wait());
        }
예제 #21
0
        public async Task ListAllClientsAsync_ReturnsClients()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.LIST_CLIENTS)));
            var res = await MockApi.Object.ListAllClientsAsync();

            Assert.NotNull(res);
            Assert.All(res.Clients, c => Assert.NotEqual(default(int), c.Id));
            Assert.All(res.Clients, c => Assert.NotNull(c.Name));
            Assert.All(res.Clients, c => Assert.NotNull(c.Projects));
            Assert.All(res.Clients, c => Assert.NotNull(c.BusinessDetails));
            Assert.All(res.Clients, c => Assert.NotEqual(default(int), c.Budget.Value));
            Assert.All(res.Clients, c => Assert.NotEqual(default(int), c.Budget.Progress));
            Assert.All(res.Clients, c => Assert.Equal(Models.BudgetType.MONEY, c.Budget.Type));
        }
예제 #22
0
        public async Task UpdateClientAsync_ReturnsClient()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.UPDATE_CLIENT)));

            var res = await MockApi.Object.UpdateClientAsync(1234, "Test Client");

            Assert.NotNull(res);
            Assert.NotEqual(default(int), res.Client.Id);
            Assert.NotNull(res.Client.Name);
            Assert.NotNull(res.Client.Projects);
            Assert.NotNull(res.Client.BusinessDetails);
            Assert.NotEqual(default(int), res.Client.Budget.Value);
            Assert.NotEqual(default(int), res.Client.Budget.Progress);
            Assert.Equal(Models.BudgetType.MONEY, res.Client.Budget.Type);
        }
예제 #23
0
        public async Task ListTeamUsersTimersAsync_ReturnsTimers()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(Specification.LIST_TEAM_USERS_TIMERS)
            }));

            var res = await MockApi.Object.ListTeamUsersTimersAsync();

            Assert.NotNull(res);
            Assert.All(res.Timers, e => Assert.Equal(Models.TimerStatus.ACTIVE, e.Status));
            Assert.All(res.Timers, e => Assert.Equal(16, e.Duration));
            Assert.All(res.Timers, e => Assert.Equal(7200, e.Today));
            Assert.All(res.Timers, e => Assert.Equal(new DateTime(2018, 01, 16, 12, 42, 59), e.StartedAt));
            Assert.All(res.Timers, e => Assert.Equal(new DateTime(2018, 01, 16), e.UserDate));
            Assert.All(res.Timers, e => Assert.Equal("comment", e.Comment));
            Assert.All(res.Timers, e => Assert.Equal(1234, e.Task.Section));
            Assert.All(res.Timers, e => Assert.Equal(new List <string>()
            {
                "high", "bug"
            }, e.Task.Labels));
            Assert.All(res.Timers, e => Assert.Equal(1, e.Task.Position));
            Assert.All(res.Timers, e => Assert.Equal("description", e.Task.Description));
            Assert.All(res.Timers, e => Assert.Equal(new DateTime(2018, 3, 5, 16, 0, 0), e.Task.DueAt));
            Assert.All(res.Timers, e => Assert.Equal(Models.TaskStatus.OPEN, e.Task.Status));
            Assert.All(res.Timers, e => Assert.Equal(7200, e.Task.Time.Total));
            Assert.All(res.Timers, e => Assert.Equal(1304, e.Task.Time.Users[0].Id));
            Assert.All(res.Timers, e => Assert.Equal(3600, e.Task.Time.Users[0].Time));
            Assert.All(res.Timers, e => Assert.Equal(1543, e.Task.Time.Users[1].Id));
            Assert.All(res.Timers, e => Assert.Equal(3600, e.Task.Time.Users[1].Time));
            Assert.All(res.Timers, e => Assert.Equal(7200, e.Task.Estimate.Total));
            Assert.All(res.Timers, e => Assert.Equal(Models.EstimateType.OVERALL, e.Task.Estimate.Type));
            Assert.All(res.Timers, e => Assert.Equal(1304, e.Task.Estimate.Users[0].Id));
            Assert.All(res.Timers, e => Assert.Equal(3600, e.Task.Estimate.Users[0].Time));
            Assert.All(res.Timers, e => Assert.Equal(1543, e.Task.Estimate.Users[1].Id));
            Assert.All(res.Timers, e => Assert.Equal(3600, e.Task.Estimate.Users[1].Time));
            Assert.All(res.Timers, e => Assert.Equal("Everhour", e.Task.Attributes[0].Client));
            Assert.All(res.Timers, e => Assert.Equal("hight", e.Task.Attributes[0].Priority));
            Assert.All(res.Timers, e => Assert.Equal(42, e.Task.Metrics[0].Efforts));
            Assert.All(res.Timers, e => Assert.Equal(199, e.Task.Metrics[0].Expenses));
            Assert.All(res.Timers, e => Assert.Equal(1304, e.User.Id));
            Assert.All(res.Timers, e => Assert.Equal("User Name", e.User.Name));
            Assert.All(res.Timers, e => Assert.Equal("CEO", e.User.Headline));
            Assert.All(res.Timers, e => Assert.Equal(Models.RoleType.ADMIN, e.User.Role));
            Assert.All(res.Timers, e => Assert.Equal(Models.UserStatus.ACTIVE, e.User.Status));
        }
예제 #24
0
        public async Task ExportAllTeamEstimatesAsync_ReturnsTeamEstimates()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.EXPORT_ESITIMATES)));

            var res = await MockApi.Object.ExportAllTeamEstimatesAsync();

            Assert.NotNull(res);
            Assert.All(res.TeamEstimates, e => Assert.NotEqual(default(int), e.Time.Total));
            Assert.All(res.TeamEstimates, e => Assert.NotEqual(default(int), e.Estimate.Total));
            Assert.All(res.TeamEstimates, e => Assert.Equal(Models.EstimateType.OVERALL, e.Estimate.Type));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Project.Id));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Project.Name));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Project.Workspace));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Task.Id));
            Assert.All(res.TeamEstimates, e => Assert.NotNull(e.Task.Name));
            Assert.All(res.TeamEstimates, e => Assert.Equal(Models.TaskType.TASK, e.Task.Type));
        }
예제 #25
0
        public async Task ExportAllTeamTimeAsync_ReturnsTeamTime()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.EXPORT_TIME)));
            var res = await MockApi.Object.ExportAllTeamTimeAsync(DateTime.UtcNow, DateTime.UtcNow.AddDays(1));

            Assert.NotNull(res);
            Assert.All(res.TeamTimes, e => Assert.NotEqual(default(int), e.Time));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Date));
            Assert.All(res.TeamTimes, e => Assert.NotEqual(default(int), e.User.Id));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.User.Name));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Project.Id));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Project.Name));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Project.Workspace));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Task.Id));
            Assert.All(res.TeamTimes, e => Assert.NotNull(e.Task.Name));
            Assert.All(res.TeamTimes, e => Assert.Equal(Models.TaskType.TASK, e.Task.Type));
        }
예제 #26
0
        public async Task SetTaskEstimateAsyncWithRequest_ReturnsTask()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.SET_TASK_ESTIMATE)));

            var res = await MockApi.Object.SetTaskEstimateAsyncByUsers("ev:9876543210", new List <Models.UserWithTaskEstimate>()
            {
                new Models.UserWithTaskEstimate()
                {
                    Id = 1234, TaskEstimate = 3600
                }
            });

            Assert.NotNull(res);
            Assert.NotNull(res.Estimate.Total);
            Assert.NotNull(res.Estimate.Type);
            Assert.Null(res.Estimate.Users);
        }
예제 #27
0
        public async Task UpdateTaskAsyncWithRequest_ReturnsTask()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.UPDATE_TASK)));

            var req = new Models.UpdateTaskRequest()
            {
                Id      = "ev:9876543210",
                Name    = "Task Name",
                Section = 1234,
                Labels  = new List <string>()
                {
                    "Label1", "Label2"
                },
                Position    = 1,
                Description = "Description",
                DueAt       = DateTime.UtcNow,
                Status      = Models.TaskStatus.OPEN
            };
            var res = await MockApi.Object.UpdateTaskAsync(req);

            Assert.NotNull(res);
            Assert.NotNull(res.Task.Id);
            Assert.NotNull(res.Task.Name);
            Assert.NotNull(res.Task.Projects);
            Assert.NotEqual(default(int), res.Task.Section);
            Assert.NotNull(res.Task.Labels);
            Assert.NotEqual(default(int), res.Task.Position);
            Assert.NotNull(res.Task.Description);
            Assert.NotEqual(default(DateTime), res.Task.DueAt);
            Assert.Equal(Models.TaskStatus.OPEN, res.Task.Status);
            Assert.NotEqual(default(int), res.Task.Time.Total);
            Assert.NotNull(res.Task.Time.Users);
            Assert.NotEqual(default(int), res.Task.Estimate.Total);
            Assert.Equal(Models.EstimateType.OVERALL, res.Task.Estimate.Type);
            Assert.NotNull(res.Task.Estimate.Users);
            Assert.Equal("Everhour", res.Task.Attributes[0].Client);
            Assert.Equal("hight", res.Task.Attributes[0].Priority);
            Assert.Equal(42, res.Task.Metrics[0].Efforts);
            Assert.Equal(199, res.Task.Metrics[0].Expenses);
        }
예제 #28
0
        public async Task CreateSectionAsyncWithReqest_ReturnsSection()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.CREATE_SECTION)));

            var req = new Models.CreateSectionRequest()
            {
                ProjectId = "as:1234567890",
                Name      = "Test Section",
                Position  = 1,
                Status    = Models.SectionStatus.OPEN
            };
            var res = await MockApi.Object.CreateSectionAsync(req);

            Assert.NotNull(res);
            Assert.NotEqual(default(int), res.Section.Id);
            Assert.NotNull(res.Section.Name);
            Assert.NotEqual(default(int), res.Section.Position);
            Assert.NotNull(res.Section.Project);
            Assert.Equal(Models.SectionStatus.OPEN, res.Section.Status);
        }
예제 #29
0
        public async Task ListAllProjectsAsync_ReturnsProjects()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.LIST_ALL_PROJECTS)));
            var res = await MockApi.Object.ListAllProjectsAsync();

            Assert.NotNull(res);
            Assert.All(res.Projects, p => Assert.NotNull(p.Id));
            Assert.All(res.Projects, p => Assert.NotNull(p.Name));
            Assert.All(res.Projects, p => Assert.NotNull(p.WorkspaceId));
            Assert.All(res.Projects, p => Assert.NotNull(p.Workspace));
            Assert.All(res.Projects, p => Assert.Equal(Models.ProjectType.BOARD, p.Type));
            Assert.All(res.Projects, p => Assert.True(p.Favorite));
            Assert.All(res.Projects, p => Assert.NotNull(p.Users));
            Assert.All(res.Projects, p => Assert.NotNull(p.Budget));
            Assert.All(res.Projects, p => Assert.NotEqual(default(int), p.Budget.Value));
            Assert.All(res.Projects, p => Assert.NotEqual(default(int), p.Budget.Progress));
            Assert.All(res.Projects, p => Assert.Equal(Models.BudgetType.MONEY, p.Budget.Type));
            Assert.All(res.Projects, p => Assert.NotNull(p.Billing));
            Assert.All(res.Projects, p => Assert.Equal(Models.BillingType.FLAT_RATE, p.Billing.Type));
            Assert.All(res.Projects, p => Assert.NotEqual(default(int), p.Billing.Rate));
            Assert.All(res.Projects, p => Assert.NotNull(p.Billing.Users));
        }
예제 #30
0
        public async Task RetrieveProjectAsync_ReturnsProject()
        {
            MockApi.Setup(x => x.ExecuteAsync(It.IsAny <HttpRequestMessage>()))
            .Returns(Task.FromResult(GenerateMockResponse(Specification.RETRIEVE_PROJECT)));
            var res = await MockApi.Object.RetrieveProjectAsync("as:1234567890");

            Assert.NotNull(res);
            Assert.NotNull(res.Project.Id);
            Assert.NotNull(res.Project.Name);
            Assert.NotNull(res.Project.WorkspaceId);
            Assert.NotNull(res.Project.Workspace);
            Assert.Equal(Models.ProjectType.BOARD, res.Project.Type);
            Assert.True(res.Project.Favorite);
            Assert.NotNull(res.Project.Users);
            Assert.NotNull(res.Project.Budget);
            Assert.NotEqual(default(int), res.Project.Budget.Value);
            Assert.NotEqual(default(int), res.Project.Budget.Progress);
            Assert.Equal(Models.BudgetType.MONEY, res.Project.Budget.Type);
            Assert.NotNull(res.Project.Billing);
            Assert.Equal(Models.BillingType.FLAT_RATE, res.Project.Billing.Type);
            Assert.NotEqual(default(int), res.Project.Billing.Rate);
            Assert.NotNull(res.Project.Billing.Users);
        }