public void AddEvent(string calendarId, CommonEvent e, int timeZoneOffset) { string start, end; start = XmlConvert.ToString(e.StartedAt.Value.AddMinutes(timeZoneOffset), XmlDateTimeSerializationMode.Utc); end = XmlConvert.ToString(e.EndedAt.Value.AddMinutes(timeZoneOffset), XmlDateTimeSerializationMode.Utc); var query = DynamicJson.Serialize( new { summary = e.Title, description = e.Description, location = e.Place, start = new { dateTime = start }, end = new { dateTime = end }, }); var url = string.Format("https://www.googleapis.com/calendar/v3/calendars/{0}", calendarId); using (var cl = new WebClient { Encoding = Encoding.UTF8 }) { cl.Headers.Add("Authorization", "Bearer " + AccessToken); cl.Headers.Add("content-type", "application/json"); cl.UploadString(url + "/events", "POST", query); } }
public void テスト対象の開催日時がnullの場合() { var e = new CommonEvent(0, "100", "TEST", new DateTime(2013, 10, 1, 13, 0, 0), null, "", "", "", "", "", ""); sut = new CommonEvent(0, "100", "TEST", null, null, "", "", "", "", "", ""); ; sut.CompareTo(e).Is(1); }
public ActionResult AddEvent(CommonEvent.WebSvcType webSvc, string id, string title, DateTime startedAtUtcTime, DateTime endedAtUtcTime, string address, string place, string ownerNickname, string url, string eventUrl) { DateTime startedAt = EventCollector.Utils.GetJstTime(startedAtUtcTime); DateTime endedAt = EventCollector.Utils.GetJstTime(endedAtUtcTime); var description = string.Format("{0}\n" + "日時:{1}\n" + "住所:{2} {3}", eventUrl, startedAt.ToString("yyyy/MM/dd hh:mm"), address, place); var viewModel = new AddCalendarViewModel(); viewModel.Event = new CommonEvent(webSvc, id, title, startedAt, endedAt, address, place, description, ownerNickname, url, eventUrl); var api = new GoogleApis(Session["access_token"].ToString()); viewModel.CalendarList = api.GetCalendarList(); return View(viewModel); }
public void 比較対象の開催日時がnullの場合() { var e = new CommonEvent(0, "100", "TEST", null, null, "", "", "", "", "", ""); ; sut.CompareTo(e).Is(-1); }
public void テスト対象の方が遅く開催される場合() { var e = new CommonEvent(0, "100", "TEST", new DateTime(2013, 9, 30), null, "", "", "", "", "", ""); sut.CompareTo(e).Is(1); }
public void テスト対象と同じ日時に開催される場合() { var e = new CommonEvent(0, "100", "TEST", new DateTime(2013, 10, 1, 13, 0, 0), null, "", "", "", "", "", ""); sut.CompareTo(e).Is(0); }
public void MyTestInitialize() { sut = new CommonEvent(0, "100", "TEST", new DateTime(2013, 10, 1, 13, 0, 0), null, "", "", "", "", "", ""); }