public async Task GivenValidRequest_ReturnOkAndUpdatedTaskItem() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var taskId = new Guid("de14a885-71d4-4da0-bb17-048d74d33ada"); PinTaskItemCommand command = new PinTaskItemCommand() { Id = taskId, IsPin = true }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/TaskItems/Pin/{taskId}", content); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <TaskItemModel>(response); vm.ShouldBeOfType <TaskItemModel>(); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidRequest_SendMessage() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var receiverUserId = Guid.Parse("9c7ff9c5-90bd-4207-9dff-01da2ceece21"); MessageDto newMessage = new MessageDto() { AttachFiles = null, ConversationId = new Guid("b73477a4-f61d-46fa-873c-7d71c01dfbd2"), Date = DateTime.UtcNow, IsPin = false, Message = "ABC123456", Type = "received" }; var content = IntegrationTestHelper.GetRequestContent(newMessage); var response = await client.PostAsync($"/api/MessagesSmartphone/SendMessageToUser/{receiverUserId}", content); response.EnsureSuccessStatusCode(); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidRequest_ShouldCreateNotification() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var validUserId = new Guid("66EDB7C7-11BF-40A5-94AB-75A3364FEF60"); var command = new CreateNotificationCommand() { MessageContent = "message 2 @USER2", ConversationId = Guid.NewGuid().ToString(), MessageId = Guid.NewGuid().ToString(), RegUserName = "******", isRead = false, ToUser = new List <UserModel>() { new UserModel { UserId = new Guid("66edb7c7-11bf-40a5-94ab-75a3364fef60"), DisplayName = "USER2" } }, Type = "Mention" }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync($"/api/Notifications/", content); response.EnsureSuccessStatusCode(); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidRequest_SendMessage() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var receiverUserId = Guid.Parse("9c7ff9c5-90bd-4207-9dff-01da2ceece21"); MessageDto newMessage = new MessageDto() { AttachFiles = null, ConversationId = new Guid("b73477a4-f61d-46fa-873c-7d71c01dfbd2"), Date = DateTime.UtcNow, IsPin = false, Message = "ABC123456", Type = "received" }; var connection = new HubConnectionBuilder().WithUrl("http://localhost/chathub" , options => { options.HttpMessageHandlerFactory = _ => _factory.Server.CreateHandler(); options.AccessTokenProvider = () => _factory.GetAccessTokenByUserAsync("testuser", "testuser"); } ) .Build(); await connection.StartAsync(); var connection1 = new HubConnectionBuilder().WithUrl("http://localhost/chathub" , options => { options.HttpMessageHandlerFactory = _ => _factory.Server.CreateHandler(); options.AccessTokenProvider = () => _factory.GetAccessTokenByUserAsync("testuser3", "testuser3"); } ) .Build(); await connection1.StartAsync(); var content = IntegrationTestHelper.GetRequestContent(newMessage); var response = await client.PostAsync($"/api/Messages/SendMessageToUser/{receiverUserId}", content); response.EnsureSuccessStatusCode(); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidUserId_ShouldReturnUserData() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var validUserId = Guid.Parse("020cdee0-8ecd-408a-b662-cd4d9cdf0100"); // login user id var response = await client.GetAsync($"/api/Directory/users/{validUserId}"); UserDto content = await IntegrationTestHelper.GetResponseContent <UserDto>(response); response.StatusCode.ShouldBe(HttpStatusCode.OK); content.ShouldBeOfType(typeof(UserDto)); content.UserId.ShouldBe(validUserId.ToString()); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidUserId_ReturnConversationsListVm() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var validUserId = Guid.Parse("9c7ff9c5-90bd-4207-9dff-01da2ceece21"); var response = await client.GetAsync($"/api/Conversation/GetAll/{validUserId}"); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <List <ConversationModel> >(response); vm.ShouldBeOfType <List <ConversationModel> >(); vm.Count.ShouldBe(2); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidUserId_ShouldReturnConversationLastContent() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var userId = Guid.Parse("020cdee0-8ecd-408a-b662-cd4d9cdf0100"); var response = await client.GetAsync($"/api/MessageChat/GetLastOf/{userId}"); var listVm = await IntegrationTestHelper.GetResponseContent <List <ConversationLastContentModel> >(response); response.StatusCode.ShouldBe(HttpStatusCode.OK); foreach (ConversationLastContentModel vm in listVm) { vm.Conversation.Members.ShouldContain(member => member.UserId == userId); } // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidUserId_ReturnConversationMessageModel_HaveMessageList() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var command = new CreateConversationCommand() { Type = "pair", Members = new List <UserModel>() { new UserModel() { UserId = new Guid("9c7ff9c5-90bd-4207-9dff-01da2ceece21"), DisplayName = "TestUser4" }, new UserModel() { UserId = new Guid("020cdee0-8ecd-408a-b662-cd4d9cdf0100"), DisplayName = "TestUser5" } }, }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync($"/api/Conversation/CreateOrGet/", content); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <ConversationMessageModel>(response); vm.ShouldBeOfType <ConversationMessageModel>(); vm.Conversation.Id.ShouldBe(new Guid("b73477a4-f61d-46fa-873c-7d71c01dfbd2")); vm.LstMessageChat.Count.ShouldBe(1); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidRequestWithIsPin_ShouldUpdateMessage() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var messageId = Guid.Parse("b73477a4-f61d-46fa-873c-7d71c01dfbdf"); UpdateMessageChatCommand command = new UpdateMessageChatCommand() { MessageId = Guid.Parse("b73477a4-f61d-46fa-873c-7d71c01dfbdf"), IsPin = true, }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/Messages/{messageId}", content); response.EnsureSuccessStatusCode(); response.StatusCode.ShouldBe(HttpStatusCode.OK); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidUserId_ShouldReturn() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var conversationId = Guid.Parse("020cdee0-8ecd-408a-b662-cd4d9cdf0102"); var response = await client.GetAsync($"/api/MessageChat/GetByConversation/{conversationId}"); response.StatusCode.ShouldBe(HttpStatusCode.OK); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidUserId_ReturnReturnNotificationInTeam() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var validUserId = new Guid("66edb7c7-11bf-40a5-94ab-75a3364fef60"); var response = await client.GetAsync($"/api/Notifications/ByTeam/{validUserId}"); response.EnsureSuccessStatusCode(); List <NotificationModel> vm = await IntegrationTestHelper.GetResponseContent <List <NotificationModel> >(response); vm.Count.ShouldBe(1); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidConversationId_ReturnsMessage() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var validConversationId = new Guid("B73477A4-F61D-46FA-873C-7D71C01DFBDF"); var validMessageId = new Guid("96149786-A9F7-4B6A-A932-5DDB15A84D1A"); var response = await client.GetAsync($"/api/MessagesSmartphone/RecentMessage/{validConversationId}"); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <MessageChatModel>(response); vm.ShouldBeOfType <MessageChatModel>(); vm.Id.ShouldBe(validMessageId); // release DB _factory.DisposeDbForTests(context); }
public async Task ReturnsTeamsListVm() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); string loginUserId = "020cdee0-8ecd-408a-b662-cd4d9cdf0100"; var response = await client.GetAsync($"/api/Team/GetAll/{loginUserId}"); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <List <TeamModel> >(response); vm.ShouldBeOfType <List <TeamModel> >(); vm.Count.ShouldBe(3); // release DB _factory.DisposeDbForTests(context); }
public async Task ReturnsTeamsListVm() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); string keword = "Team 1"; var response = await client.GetAsync($"/api/Team/GetAllByTeamName/{keword}"); Debug.WriteLine("33333333"); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <List <TeamModel> >(response); vm.ShouldBeOfType <List <TeamModel> >(); vm.Count.ShouldBe(1); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenInvalidMessageId_ShouldRaiseBadRequest() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var messageId = Guid.Parse("B73477A4-F61D-46FA-873C-7D71C01DFBDF"); PinAttachFileCommand command = new PinAttachFileCommand() { MessageId = Guid.NewGuid(), BlobStorageUrl = "", IsPinFile = true }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/Messages/pin-attached-file/{messageId}", content); response.StatusCode.ShouldBe(HttpStatusCode.BadRequest); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidRequestWithAttachfile_ShouldUpdateTaskWithAttachfile() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var listAttachFiles = new List <AttachFileModel>(); // Mock Attachfile 1 var formData1 = _factory.MockUploadFileAction("file1.txt", "data file 1"); var uploadResponse1 = await client.PostAsync($"/api/Upload/", formData1); var fileAfterUpload1 = await IntegrationTestHelper.GetResponseContent <FileListDto>(uploadResponse1); listAttachFiles.Add(new AttachFileModel() { FileName = fileAfterUpload1.Files[0].FileName, FileStorageName = fileAfterUpload1.Files[0].FileStorageName, BlobStorageUrl = fileAfterUpload1.Files[0].BlobStorageUrl, FileSize = fileAfterUpload1.Files[0].FileSize, ThumbnailImage = fileAfterUpload1.Files[0].ThumbnailImage, LocalUrl = fileAfterUpload1.Files[0].LocalUrl }); string taskId = "197d0438-e04b-453d-b5de-eca05960c6ae"; UpdateTaskItemCommand command1 = new UpdateTaskItemCommand() { Name = "Task With AttachFiles", Description = "Description Test", TeamId = Guid.Parse(taskId), AttachFiles = listAttachFiles, Assignee = new UserModel() { UserId = Guid.NewGuid(), DisplayName = Guid.NewGuid().ToString() }, Deadline = DateTime.UtcNow, Id = new Guid(taskId), Status = '2', Tags = new List <TagModel>(), Relations = new List <RelatedObjectModel>() }; var content1 = IntegrationTestHelper.GetRequestContent(command1); var response1 = await client.PutAsync($"/api/TaskItems/Update/{taskId}", content1); response1.EnsureSuccessStatusCode(); // Mock Attachfile 2 var formData2 = _factory.MockUploadFileAction("file2.txt", "data file 2"); var uploadResponse2 = await client.PostAsync($"/api/Upload/", formData2); var fileAfterUpload2 = await IntegrationTestHelper.GetResponseContent <FileListDto>(uploadResponse2); listAttachFiles = new List <AttachFileModel>(); listAttachFiles.Add(new AttachFileModel() { FileName = fileAfterUpload2.Files[0].FileName, FileStorageName = fileAfterUpload2.Files[0].FileStorageName, BlobStorageUrl = fileAfterUpload2.Files[0].BlobStorageUrl, FileSize = fileAfterUpload2.Files[0].FileSize, ThumbnailImage = fileAfterUpload2.Files[0].ThumbnailImage, LocalUrl = fileAfterUpload2.Files[0].LocalUrl }); UpdateTaskItemCommand command2 = new UpdateTaskItemCommand() { Name = "Task With AttachFiles", Description = "Description Test", TeamId = Guid.Parse(taskId), AttachFiles = listAttachFiles, Assignee = new UserModel() { UserId = Guid.NewGuid(), DisplayName = Guid.NewGuid().ToString() }, Deadline = DateTime.UtcNow, Id = new Guid(taskId), Status = '2', Tags = new List <TagModel>(), Relations = new List <RelatedObjectModel>() }; var content2 = IntegrationTestHelper.GetRequestContent(command2); var response2 = await client.PutAsync($"/api/TaskItems/Update/{taskId}", content2); response2.EnsureSuccessStatusCode(); // release DB _factory.DisposeDbForTests(context); }
public async Task GivenValidTeamId_ReturnsTaskItemsListVm() { var client = await _factory.GetAuthenticatedClientAsync(); // init DB for test var context = _factory.InitializeDbForTests(); var keyword = "Team"; var response = await client.GetAsync($"/api/Search/userAndTeam/?keyword={keyword}"); response.EnsureSuccessStatusCode(); var vm = await IntegrationTestHelper.GetResponseContent <List <SearchModel> >(response); vm.ShouldBeOfType <List <SearchModel> >(); vm.Count.ShouldBe(5); // release DB _factory.DisposeDbForTests(context); }