Beispiel #1
0
        public void AddResult_Saves_Result()
        {
            var resultSet = new Mock <DbSet <Result> >();

            var mockContext = new Mock <BookmakerContext>();

            mockContext.Setup(m => m.Results).Returns(resultSet.Object);

            var resultService = new ResultService(mockContext.Object);

            resultService.AddResult(new Result());
            resultSet.Verify(m => m.Add(It.IsAny <Result>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
        public async Task <IActionResult> PostResult(int number, Guid userId)
        {
            try
            {
                await _resultService.AddResult(number, userId);

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500));
            }
        }
 public void AddResult_Should_Throw_ArgumentNullExcepton_When_Dto_Is_Null()
 {
     Assert.ThrowsException <ArgumentNullException>(() => resultService.AddResult(null));
 }