public void Confirm_RedirectsToPageWhenPassedInvalidToken()
        {
            var mailingService = new Mock <IMailingService>();
            var controller     = new UnsubscribeController(_context, mailingService.Object);

            var result = controller.Confirm("Invalid token");

            Assert.IsType <RedirectToPageResult>(result);
        }
Beispiel #2
0
        public async Task WhenCorrelationIdIsInvalid_ThenShouldReturnBadRequest(
            UnsubscribeController controller)
        {
            //arrange

            //act
            var result = await controller.Get("INVALID", new CancellationToken());

            //assert
            result.Should().NotBeNull().And.BeOfType <BadRequestObjectResult>();
        }
Beispiel #3
0
        public async Task WhenValidCorrelationIdIsSupplied_ThenShouldReturnOk(
            UnsubscribeController controller,
            Guid correlationId)
        {
            //arrange

            //act
            var result = await controller.Get(correlationId.ToString(), new CancellationToken());

            //assert
            result.Should().NotBeNull().And.BeOfType <OkResult>();
        }
        public void Confirm_SendsUnsubscriptionConfirmation()
        {
            var lastAddress    = _context.Addresses.Last();
            var mailingService = new Mock <IMailingService>();

            mailingService.Setup(m => m.SendUnsubscribeConfirmation(lastAddress.Email));
            var controller = new UnsubscribeController(_context, mailingService.Object);

            controller.Confirm(lastAddress.UnsubscribeToken);

            mailingService.Verify(m => m.SendUnsubscribeConfirmation(lastAddress.Email));
        }
        public void Confirm_MakesAddressInactive()
        {
            var lastAddress    = _context.Addresses.Last();
            var mailingService = new Mock <IMailingService>();

            mailingService.Setup(m => m.SendUnsubscribeConfirmation(lastAddress.Email));
            var controller = new UnsubscribeController(_context, mailingService.Object);

            controller.Confirm(lastAddress.UnsubscribeToken);

            Assert.Equal(false, _context.Addresses.Last().Subscribed);
        }