Пример #1
0
        public async Task ReturnTheCampaignsTheUserIsAnOrgAdminFor_WhenOrganizationIdOnMessageIsNotNull()
        {
            const int orgId1 = 1;
            const int orgId2 = 2;

            Context.Campaigns.Add(new Campaign {
                Id = 1, ManagingOrganization = new Organization {
                    Id = orgId1
                }
            });
            Context.Campaigns.Add(new Campaign {
                Id = 2, ManagingOrganization = new Organization {
                    Id = orgId2
                }
            });
            Context.SaveChanges();

            var message = new IndexQuery {
                OrganizationId = orgId1
            };

            var sut    = new IndexQueryHandler(Context);
            var result = await sut.Handle(message);

            Assert.Equal(result.Single().Id, orgId1);
        }
        public async Task ReturnTheCorrectViewModel()
        {
            Context.Campaigns.Add(new Campaign { ManagingOrganization = new Organization() });
            Context.SaveChanges();

            var sut = new IndexQueryHandler(Context);
            var result = await sut.Handle(new IndexQuery());

            Assert.IsType<List<IndexViewModel>>(result);
        }
Пример #3
0
        public async Task ReturnTheCorrectViewModel()
        {
            Context.Campaigns.Add(new Campaign {
                ManagingOrganization = new Organization()
            });
            Context.SaveChanges();

            var sut    = new IndexQueryHandler(Context);
            var result = await sut.Handle(new IndexQuery());

            Assert.IsType <List <IndexViewModel> >(result);
        }
        public async Task ReturnsAllCampaigns_WhenOrganizationIdOnMessageIsNull()
        {
            const int orgId1 = 1;
            const int orgId2 = 2;

            Context.Campaigns.Add(new Campaign { Id = 1, ManagingOrganization = new Organization { Id = orgId1 } });
            Context.Campaigns.Add(new Campaign { Id = 2, ManagingOrganization = new Organization { Id = orgId2 } });
            Context.SaveChanges();

            var sut = new IndexQueryHandler(Context);
            var result = await sut.Handle(new IndexQuery());

            Assert.Equal(result.Count(), 2);
        }
Пример #5
0
        public async Task ReturnTheCorrectData()
        {
            var applicationUser = new ApplicationUser { Id = "1", UserName = "******", EmailConfirmed = true };

            Context.Add(new ApplicationUser { Id = "1", UserName = "******", EmailConfirmed = true });
            Context.SaveChanges();

            var sut = new IndexQueryHandler(Context);
            var result = await sut.Handle(new IndexQuery());

            Assert.Equal(result.Users[0].Id, applicationUser.Id);
            Assert.Equal(result.Users[0].UserName, applicationUser.UserName);
            Assert.Equal(result.Users[0].EmailConfirmed, applicationUser.EmailConfirmed);
        }
        public async Task ReturnTheCampaignsTheUserIsAnOrgAdminFor_WhenOrganizationIdOnMessageIsNotNull()
        {
            const int orgId1 = 1;
            const int orgId2 = 2;

            Context.Campaigns.Add(new Campaign { Id = 1, ManagingOrganization = new Organization { Id = orgId1 }});
            Context.Campaigns.Add(new Campaign { Id = 2, ManagingOrganization = new Organization { Id = orgId2 }});
            Context.SaveChanges();

            var message = new IndexQuery { OrganizationId = orgId1 };

            var sut = new IndexQueryHandler(Context);
            var result = await sut.Handle(message);

            Assert.Equal(result.Single().Id, orgId1);
        }
Пример #7
0
        public async Task ReturnTheCorrectData()
        {
            var applicationUser = new ApplicationUser {
                Id = "1", UserName = "******", EmailConfirmed = true
            };

            Context.Add(new ApplicationUser {
                Id = "1", UserName = "******", EmailConfirmed = true
            });
            Context.SaveChanges();

            var sut    = new IndexQueryHandler(Context);
            var result = await sut.Handle(new IndexQuery());

            Assert.Equal(result.Users[0].Id, applicationUser.Id);
            Assert.Equal(result.Users[0].UserName, applicationUser.UserName);
            Assert.Equal(result.Users[0].EmailConfirmed, applicationUser.EmailConfirmed);
        }
Пример #8
0
        public async Task ReturnsAllCampaigns_WhenOrganizationIdOnMessageIsNull()
        {
            const int orgId1 = 1;
            const int orgId2 = 2;

            Context.Campaigns.Add(new Campaign {
                Id = 1, ManagingOrganization = new Organization {
                    Id = orgId1
                }
            });
            Context.Campaigns.Add(new Campaign {
                Id = 2, ManagingOrganization = new Organization {
                    Id = orgId2
                }
            });
            Context.SaveChanges();

            var sut    = new IndexQueryHandler(Context);
            var result = await sut.Handle(new IndexQuery());

            Assert.Equal(2, result.Count());
        }