Beispiel #1
0
        public async Task AddUserToDialogAsyncAddsUserCallsSaveChanges_and_ReturnsServiceResponseWithData()
        {
            UserDialogAddDTO userDialogAddDTO = new UserDialogAddDTO();

            _dialogRepositoryMock.Setup(r => r.GetAsync(It.IsAny <int>())).Returns(Task.FromResult(new Dialog()));

            ServiceResponse <int> serviceResponse = await _service.AddUserToDialogAsync(userDialogAddDTO);

            _dialogRepositoryMock.Verify(r => r.AddUserToDialog(It.IsAny <UserDialog>()), Times.Once);
            _dbContextMock.Verify(r => r.SaveChangesAsync(CancellationToken.None), Times.AtLeast(1));
            Assert.IsAssignableFrom <ServiceResponse <int> >(serviceResponse);
            Assert.True(serviceResponse.Success);
        }
Beispiel #2
0
        public async Task <IActionResult> Post(UserDialogAddDTO userDialogAddDTO)
        {
            ServiceResponse <int> serviceResponse = await _dialogService.AddUserToDialogAsync(userDialogAddDTO);

            if (serviceResponse.Success == false)
            {
                return(BadRequest(serviceResponse.Message));
            }
            return(Ok(serviceResponse));
        }