Пример #1
0
        public async Task AddKudosLog_UserIsAdminButTotalPointsIsNull_AddKudosLogWithExplicitAmountIsInvoked()
        {
            // Arrange
            const int explicitAmount = 123456;
            var       request        = new AddKudosLogViewModel
            {
                TotalPointsPerReceiver = null
            };
            var mappedRequest = new AddKudosLogDto();

            _mapper.Map <AddKudosLogViewModel, AddKudosLogDto>(request).Returns(mappedRequest);
            _permissionService.UserHasPermissionAsync(Arg.Any <UserAndOrganizationDto>(), AdministrationPermissions.Kudos)
            .Returns(true);

            // Act
            var response = await _kudosController.AddKudosLog(request);

            var result = await response.ExecuteAsync(CancellationToken.None);

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            await _kudosService.DidNotReceive().AddKudosLogAsync(mappedRequest, explicitAmount);

            await _kudosService.Received(1).AddKudosLogAsync(mappedRequest);
        }