public async Task CreateCalendarWithEventsShouldReturnOperationalResultCalendarFailure() { var messages = new Dictionary <string, HttpResponseMessage>() { [this._googleCalendarSettings.CalendarsEndpoint] = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, }, [this._googleCalendarSettings.EventsEndpoint] = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, } }; using var testMessageHandler = new TestMessageHandler(messages); using (var httpClient = new HttpClient(testMessageHandler)) { var googleCalendarService = new GoogleCalendarService( httpClient, this._adventSettings, this._testSettings, this._googleCalendarSettings); // Act var createdCalendar = await googleCalendarService.CreateNewCalendarWithEvents().ConfigureAwait(false); // Assert Assert.IsType <OperationalResult>(createdCalendar); Assert.Equal(OperationalResultStatus.CalendarFailure, createdCalendar.Status); } }
public async Task CreateCalendarWithEventsShouldReturnOperationalResultSuccess() { // Arrange var newCalendarId = "1"; var eventsUrl = this.GetEventsUrl(newCalendarId); var messages = new Dictionary <string, HttpResponseMessage>() { [this._googleCalendarSettings.CalendarsEndpoint] = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent( JsonConvert.SerializeObject(new CalendarDto() { Id = newCalendarId }), Encoding.UTF8, MediaTypeNames.Application.Json) }, [eventsUrl] = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, } }; using var testMessageHandler = new TestMessageHandler(messages); using var httpClient = new HttpClient(testMessageHandler); var googleCalendarService = new GoogleCalendarService( httpClient, this._adventSettings, this._testSettings, this._googleCalendarSettings); // Act var createdCalendar = await googleCalendarService.CreateNewCalendarWithEvents().ConfigureAwait(false); // Assert Assert.IsType <OperationalResult>(createdCalendar); Assert.Equal(OperationalResultStatus.Success, createdCalendar.Status); }