Esempio n. 1
0
        public async Task GetMailingEmails_MailingGroupHasMailingEmails_ShouldMailingList()
        {
            var mailingListDbContext = Host.Services.GetService <MailingListDbContext>();

            var user = mailingListDbContext.Users.First();

            _mailingEmailController.SetFakeHttpContextAndSetUser(user.Id);
            var mailingGroup = mailingListDbContext.MailingGroup.First(m => m.UserId == user.Id);

            var mailingEmailsRelatedToMailingGroup = mailingListDbContext.MailingEmailGroup
                                                     .Include(meg => meg.MailingEmail)
                                                     .Where(meg => meg.MailingGroupId == mailingGroup.Id)
                                                     .ToList();

            var actionResult = await _mailingEmailController.GetMailingEmails(new GetMailingEmailListRequestModel()
            {
                MailingGroupId = mailingGroup.Id,
                Skip           = 0,
                Take           = 10
            });

            ApiRequestValidator.EnsureRequestSuccess <OkObjectResult>(actionResult);

            var mailingList = ((IEnumerable <MailingEmailModel>)((OkObjectResult)actionResult).Value).ToList();

            foreach (var mailingEmail in mailingList)
            {
                Assert.Contains(mailingEmail.Id, mailingEmailsRelatedToMailingGroup.Select(meg => meg.MailingEmailId));
            }
        }
Esempio n. 2
0
        public async Task LoginIntoApp_AccountCreatedInDatabase_ShouldReturnsGuid()
        {
            var identityController = Host.Services.GetService <IdentityController>();

            var actionResult = await identityController.Login(new UserLoginRequest()
            {
                Login    = "******",
                Password = "******"
            });

            ApiRequestValidator.EnsureRequestSuccess <OkObjectResult>(actionResult);

            Assert.IsType <AuthorizationSuccessResponse>(((OkObjectResult)actionResult).Value);
        }
Esempio n. 3
0
        public async Task CreateMailingEmail_MailingGroupAndMailingEmailNotExists_ShouldReturnsGuid()
        {
            var mailingListDbContext = Host.Services.GetService <MailingListDbContext>();

            var user = mailingListDbContext.Users.First();

            _mailingEmailController.SetFakeHttpContextAndSetUser(user.Id);
            var mailingGroup = mailingListDbContext.MailingGroup.First(m => m.UserId == user.Id);

            var actionResult = await _mailingEmailController.Create(new MailingEmailRequestModel()
            {
                Email          = "*****@*****.**",
                MailingGroupId = mailingGroup.Id
            });

            ApiRequestValidator.EnsureRequestSuccess <OkObjectResult>(actionResult);

            Assert.IsType <Guid>(((OkObjectResult)actionResult).Value);
        }