public void GetOrCreateUserId_WithExistingUserId_ReturnsExistingUserId() { // Arrange var existingUserId = Guid.NewGuid(); var httpContext = Substitute.For <HttpContext>(); httpContext.Request.Cookies["USER_ID"].Returns(existingUserId.ToString()); // Act var userId = _primitiveUserIdentificationService.GetOrCreateUserId(httpContext); // Assert Assert.That(userId, Is.EqualTo(existingUserId)); httpContext.Response.Cookies.Received(0).Append("USER_ID", Arg.Any <string>(), Arg.Any <CookieOptions>()); }
public async Task VoteAsync(Guid songId) { var votingCandidate = await _votingCandidateRepository.GetBySongAsync(songId); var userIdentifier = _primitiveUserIdentificationService.GetOrCreateUserId(HttpContext); await _voteService.UpdateOrCreateAsync(votingCandidate, userIdentifier); await _unitOfWork.CommitAsync(); _messageQueueService.Send(Message.VotingMessage); }