public async Task SearchMessage_NoParams() { // Arrange await new AddMessage(_fixture).AddInfoMessage_Success(); var search = new NewSearch(null); // Act var response = await _client.PostAsync("/search", search.AsJson()); // Assert Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task SearchTextAndMessageId_Success() { // Arrange await new AddMessage(_fixture).AddInfoMessage_Success(); var search = new NewSearch("error", (long)Constants.MessageType.Error); // Act var response = await _client.PostAsync("/search", search.AsJson()); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var messages = JsonConvert.DeserializeObject <List <Models.DTOs.Message.Search> >(await response.Content.ReadAsStringAsync()); Assert.IsType <List <Models.DTOs.Message.Search> >(messages); Assert.NotEmpty(messages); Assert.True(messages.Exists(q => q.MessageTypeId == (long)Constants.MessageType.Error && q.Text.Contains(search.Text))); }
public async Task SearchMessageId_Success() { // Arrange await new AddMessageControllerTests().AddInfoMessage_Success(); //load at least one message var search = new NewSearch(null, (long)Constants.MessageType.Info); // Act var response = await _client.PostAsync("/search", search.AsJson()); // Assert Assert.IsType <HttpResponseMessage>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var messages = JsonConvert.DeserializeObject <List <Models.DTOs.Message.Get> >(await response.Content.ReadAsStringAsync()); Assert.IsType <List <Models.DTOs.Message.Get> >(messages); Assert.NotEmpty(messages); Assert.True(messages.Exists(q => q.MessageType.Id == (long)Constants.MessageType.Info)); }
public async Task SearchInsertDate_Success() { // Arrange long oneMinuteAgo = now(); await new AddMessage(_fixture).AddInfoMessage_Success(); var search = new NewSearch(null, null, oneMinuteAgo); // Act var response = await _client.PostAsync("/search", search.AsJson()); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var messages = JsonConvert.DeserializeObject <List <Models.DTOs.Message.Search> >(await response.Content.ReadAsStringAsync()); Assert.IsType <List <Models.DTOs.Message.Search> >(messages); Assert.NotEmpty(messages); }
public async Task SearchText_NoResults() { // Arrange await new AddMessage(_fixture).AddInfoMessage_Success(); var searchText = "asdf112233"; var search = new NewSearch(searchText, null, null); // Act var response = await _client.PostAsync("/search", search.AsJson()); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var messages = JsonConvert.DeserializeObject <List <Models.DTOs.Message.Search> >(await response.Content.ReadAsStringAsync()); Assert.IsType <List <Models.DTOs.Message.Search> >(messages); Assert.Empty(messages); }
public async Task SearchStartAndEndDate_Success() { // Arrange long oneMinuteAgo = now(); await new AddMessageControllerTests().AddInfoMessage_Success(); //load at least one message long here = now(); var search = new NewSearch(null, null, oneMinuteAgo, here); // Act var response = await _client.PostAsync("/search", search.AsJson()); // Assert Assert.IsType <HttpResponseMessage>(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var messages = JsonConvert.DeserializeObject <List <Models.DTOs.Message.Get> >(await response.Content.ReadAsStringAsync()); Assert.IsType <List <Models.DTOs.Message.Get> >(messages); Assert.NotEmpty(messages); }