public async Task Get_ShouldReturnMeeting() { //arrange var meetingHandler = new MeetingRequestHandler(hostAddress); var userHandler = new UserRequestHandler(hostAddress); var placeHandler = new PlaceRequestHandler(hostAddress); Place place = TestDataHelper.GeneratePlace(); User user = TestDataHelper.GenerateUser(); Meeting meeting = TestDataHelper.GenerateMeeting(); meeting.Date = new DateTime(2016, 1, 1); meeting.InvitedPeople.Clear(); //act HttpResponseMessage response1 = await userHandler.Create(user); meeting.Owner = await response1.Content.ReadAsAsync<User>(); HttpResponseMessage response2 = await placeHandler.Create(place); meeting.Place = await response2.Content.ReadAsAsync<Place>(); HttpResponseMessage response3 = await meetingHandler.Create(meeting); Meeting resultMeet = await response3.Content.ReadAsAsync<Meeting>(); HttpResponseMessage resultResponse = await meetingHandler.Get(resultMeet.Id); resultMeet = await resultResponse.Content.ReadAsAsync<Meeting>(); //assert TestDataHelper.PrintMeetingInfo(resultMeet); Assert.IsTrue(resultResponse.IsSuccessStatusCode); }
public async Task Create_ShouldReturnCreate() { //arrange var userHandler = new UserRequestHandler(hostAddress); User user = TestDataHelper.GenerateUser(); //act HttpResponseMessage response = await userHandler.Create(user); //assert Assert.IsTrue(response.IsSuccessStatusCode); }
public async Task Get_ByEmail_ShouldReturnOk() { //arrange var userHandler = new UserRequestHandler(hostAddress); User user = TestDataHelper.GenerateUser(); //act await userHandler.Create(user); HttpResponseMessage response = await userHandler.Get(user.Email); //assert Console.WriteLine(response.StatusCode); Assert.IsTrue(response.IsSuccessStatusCode); }
public async Task Get_ByEmail_ShouldReturnSameUser() { //arrange var userHandler = new UserRequestHandler(hostAddress); User user = TestDataHelper.GenerateUser(); //act await userHandler.Create(user); HttpResponseMessage response = await userHandler.Get(user.Email); User resultUser = await response.Content.ReadAsAsync<User>(); //assert Assert.IsTrue(user.Email == resultUser.Email); Assert.IsTrue(user.FirstName == resultUser.FirstName); Assert.IsTrue(user.LastName == resultUser.LastName); }
public async Task Get_ById_ShouldReturnOk() { //arrange var userHandler = new UserRequestHandler(hostAddress); User user = TestDataHelper.GenerateUser(); //act await userHandler.Create(user); HttpResponseMessage response = await userHandler.Get(user.Email); User resultUser = await response.Content.ReadAsAsync<User>(); HttpResponseMessage resultResponse = await userHandler.Get(resultUser.Id.ToString()); //assert Assert.IsTrue(resultResponse.IsSuccessStatusCode); }
public async Task Update_ShouldReturnCreated() { //arrange var userHandler = new UserRequestHandler(hostAddress); User user = TestDataHelper.GenerateUser(); //act HttpResponseMessage response = await userHandler.Create(user); User resultUser = await response.Content.ReadAsAsync<User>(); HttpResponseMessage resultResponse = await userHandler.Update(resultUser); //assert Console.WriteLine(resultResponse.StatusCode); Assert.IsTrue(resultResponse.IsSuccessStatusCode); }
public async Task GetAllMeetingsCreatedByUser_ShouldReturnCreate() { //arrange var meetingHandler = new MeetingRequestHandler(hostAddress); var userHandler = new UserRequestHandler(hostAddress); var placeHandler = new PlaceRequestHandler(hostAddress); Place place = TestDataHelper.GeneratePlace(); User user = TestDataHelper.GenerateUser(); List<Meeting> meetings = new List<Meeting>(); List<Meeting> resultMeetings = new List<Meeting>(); //act HttpResponseMessage response1 = await userHandler.Create(user); user = await response1.Content.ReadAsAsync<User>(); HttpResponseMessage response2 = await placeHandler.Create(place); place = await response2.Content.ReadAsAsync<Place>(); for (int i = 0; i < 10; i++) { Meeting meeting = TestDataHelper.GenerateMeeting(); meeting.Owner = user; meeting.Date = new DateTime(2016, 1, 1); meeting.InvitedPeople.Clear(); meeting.Place = place; meetings.Add(meeting); } foreach (Meeting meet in meetings) { await meetingHandler.Create(meet); } HttpResponseMessage response = await meetingHandler.GetAllMeetingsCreatedByUser(user.Id); resultMeetings = await response.Content.ReadAsAsync<List<Meeting>>(); //assert foreach (Meeting meet in resultMeetings) TestDataHelper.PrintMeetingInfo(meet); Assert.IsTrue(response.IsSuccessStatusCode); }