예제 #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));
            }
        }
예제 #2
0
        public void SetUp()
        {
            _mockFactory = new Mock <IRateLimitRuleFactory>();
            _validator   = new ApiRequestValidator(_mockFactory.Object);

            _mockRuleSuccess = new Mock <IRateLimitRule>();
            _mockRuleSuccess.Setup(x => x.Validate("me", "res", null)).Returns(true);

            _mockRuleFailure = new Mock <IRateLimitRule>();
            _mockRuleFailure.Setup(x => x.Validate("me", "res", null)).Returns(false);
        }
예제 #3
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);
        }
예제 #4
0
 public BaseController()
 {
     Task.WaitAll(Task.Run(async() =>
     {
         Server = new TestServer(new WebHostBuilder()
                                 .UseEnvironment("Test")
                                 .UseStartup <Startup>()
                                 );
         Host = Server.Host;
         ApiRequestValidator = new ApiRequestValidator();
         var basicDataSeeder = new BasicDataSeeder(Host, ApiRequestValidator);
         await basicDataSeeder.SeedBasicDataViaApi();
     }));
 }
예제 #5
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);
        }