Esempio n. 1
0
        public async Task SaveRequestsToServiceTest()
        {
            const int number = 3;

            _uow.CommitAsync().Returns(number);

            int result = await _requestsService.SaveRequestsToDbAsync(RequestsGenerator.GetNRequestModels(number));

            Assert.Equal(number, result);
        }
Esempio n. 2
0
        public async Task SaveToDatabaseReturnsCorrectNumberOfAddedItemsOnSuccess()
        {
            // Arrange
            _service.SaveRequestsToDbAsync(_requests).Returns(_numberOfRequests);
            RequestsController controller = new RequestsController(_service);

            // Act
            IHttpActionResult actionResult = await controller.SaveToDatabase(_requests);

            var contentResult = actionResult as OkNegotiatedContentResult <string>;

            // Assert
            Assert.NotNull(contentResult);
            Assert.NotNull(contentResult.Content);
            Assert.Equal(contentResult.Content, SuccessMessage.PostSuccess(_numberOfRequests));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> SaveToDatabase(IEnumerable <RequestModel> requests)
        {
            try
            {
                int recordsSaved = await _requestsService.SaveRequestsToDbAsync(requests);

                string msg = SuccessMessage.PostSuccess(recordsSaved);
                Logger.Info(msg);
                return(Ok(msg));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(InternalServerError());
            }
        }