public void StartDateTest() { var timeNow = DateTime.Now; var timeLog = new PeopleTimeLog(TestUserEmail, TestJobID, timeNow, OneHourInSeconds); Assert.Equal <DateTime>(timeNow, timeLog.StartDateTime); Assert.Equal <DateTime>(timeNow.Date, timeLog.WorkDate); }
public void EndDateTestOneAndHalfHours() { var startDateTime = new DateTime(2012, 1, 1, 10, 0, 0); var expected = new DateTime(2012, 1, 1, 11, 30, 0); var timeLog = new PeopleTimeLog(TestUserEmail, TestJobID, startDateTime, OneAndHalfHoursInSeconds); Assert.Equal <DateTime>(expected, timeLog.EndDateTime); }
public void BillingStatusNonBillable() { var timelog = new PeopleTimeLog(TestUserEmail, TestJobID, DateTime.Now, OneAndHalfHoursInSeconds) { BillingStatus = PeopleTimeLog.BillingStatusType.NonBillable }; Assert.Equal("non-billable", timelog.BillingStatus.ConvertToString()); }
public void ConvertStringsInvalidEmail() { var invalid = PeopleTimeLog.CreateFromStrings( userEmail: null, TestJobID.ToString(), DateTime.Now.ToString(), OneHourInSeconds.ToString() ); Assert.Null(invalid); }
public void ConvertStringsInvalidDuration() { var invalid = PeopleTimeLog.CreateFromStrings( userEmail: TestUserEmail, TestJobID.ToString(), DateTime.Now.ToString(), durationInSeconds: null ); Assert.Null(invalid); }
public void ConvertStringsInvalidStartDateTime() { var invalid = PeopleTimeLog.CreateFromStrings( userEmail: TestUserEmail, TestJobID.ToString(), startDateTime: null, OneHourInSeconds.ToString() ); Assert.Null(invalid); }
public void ConvertStringsValid() { var valid = PeopleTimeLog.CreateFromStrings( TestUserEmail, TestJobID.ToString(), DateTime.Now.ToString(), OneHourInSeconds.ToString() ); Assert.NotNull(valid); Assert.IsType <PeopleTimeLog>(valid); }
/// <summary> /// Call the Add time log API for the specified <paramref name="timeLog"/>. /// </summary> /// <param name="timeLog">PeopleTimeLog object to add.</param> /// <returns>Newly created Zoho People Time Log entry (timeLogID); or empty string on failure.</returns> public async Task <string> AddTimeLogAsync(PeopleTimeLog timeLog) { ValidateTimeLog(timeLog); var uri = UriForMethod( ApiMethodUrls.Timelogs.AddTimeLog, QueryStringDictionary(timeLog)); string responseBody = await GetStringAsync(uri); string timeLogID = ParseTimeLogIDFromJson(responseBody); return(timeLogID); }
/// <summary> /// Dictionary with relevant query string parameters from the specified <paramref name="timeLog"/> object. /// </summary> /// <param name="timeLog">PeopleTimeLog object to use.</param> /// <returns>New Dictionary object with all the required parameters set /// including the AuthToken.</returns> private IDictionary <string, string> QueryStringDictionary(PeopleTimeLog timeLog) { // Required stuff. Dictionary <string, string> dictionary = new Dictionary <string, string> { { "authtoken", AuthToken }, { "user", timeLog.UserEmail }, { "jobId", timeLog.JobID }, { "workDate", timeLog.WorkDate.ToString("yyyy-MM-dd") }, { "dateFormat", @"yyyy-MM-dd" }, { "billingStatus", timeLog.BillingStatus.ConvertToString() }, { "fromTime", timeLog.StartDateTime.ToString("hh:mmtt") }, { "toTime", timeLog.EndDateTime.ToString("hh:mmtt") }, }; // Optional stuff. dictionary.Add("projectId", timeLog.ProjectID ?? string.Empty); dictionary.Add("projectName", timeLog.ProjectName ?? string.Empty); dictionary.Add("jobName", timeLog.JobName ?? string.Empty); dictionary.Add("workItem", timeLog.WorkItem ?? string.Empty); dictionary.Add("description", timeLog.Description ?? string.Empty); return(dictionary); }
public void TypeTimeSpan() { var timeLog = new PeopleTimeLog(TestUserEmail, TestJobID, DateTime.Now, OneHourInTimeSpan); Assert.IsType <PeopleTimeLog>(timeLog); }
public void ConvertStringsInvalid() { var invalid = PeopleTimeLog.CreateFromStrings(null, null, null, null); Assert.Null(invalid); }