Beispiel #1
0
        public async Task Should_Send_QRCode()
        {
            // Arrange
            var expectedFileName = "ARPA_QRCode_Per_Former.png";
            var expectedFile     = File.ReadAllBytes(
                Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                             "Files",
                             expectedFileName));
            var expectedQrCodeFile = new SendQRCode.QrCodeFile
            {
                Content  = expectedFile,
                FileName = expectedFileName
            };

            var command = new SendQRCode.Command
            {
                Username = UserTestSeedData.Performer.UserName
            };

            // Act
            SendQRCode.QrCodeFile result = await _handler.Handle(command, new CancellationToken());

            // Assert
            result.Should().BeEquivalentTo(expectedQrCodeFile);
            await _emailSender.Received().SendTemplatedEmailAsync(Arg.Any <ITemplate>(), Arg.Any <string>(), Arg.Any <IList <EmailAttachment> >());
        }
Beispiel #2
0
        public async Task <SendQRCode.QrCodeFile> SendMyQrCodeAsync()
        {
            var command = new SendQRCode.Command {
                Username = _userAccessor.UserName
            };

            return(await _mediator.Send(command));
        }
Beispiel #3
0
        public void Should_Map_SendQrCode_Command()
        {
            // Arrange
            var dto = new SetRoleDto
            {
                Username  = UserTestSeedData.Performer.UserName,
                RoleNames = new[] { RoleNames.Staff }
            };

            // Act
            SendQRCode.Command command = _mapper.Map <SendQRCode.Command>(dto);

            // Assert
            command.Username.Should().BeEquivalentTo(dto.Username);
        }
Beispiel #4
0
        public async Task SetRoleAsync(SetRoleDto setRoleDto)
        {
            SetRole.Command command   = _mapper.Map <SetRole.Command>(setRoleDto);
            var             isNewUser = await _mediator.Send(command);

            if (isNewUser)
            {
                SendActivationInfo.Command activationCommand = _mapper.Map <SendActivationInfo.Command>(setRoleDto);
                await _mediator.Send(activationCommand);
            }

            if (setRoleDto.RoleNames.Contains(RoleNames.Performer))
            {
                SendQRCode.Command codeCommand = _mapper.Map <SendQRCode.Command>(setRoleDto);
                await _mediator.Send(codeCommand);
            }
        }