public void Filter_Supplier_Returns_OwnNHSD()
        {
            var orgId = Guid.NewGuid().ToString();
            var org   = Creator.GetOrganisation(id: orgId, primaryRoleId: PrimaryRole.ApplicationServiceProvider);

            _organisationDatastore.Setup(x => x.ById(orgId)).Returns(org);

            var otherOrgId = Guid.NewGuid().ToString();
            var otherOrg   = Creator.GetOrganisation(id: otherOrgId, primaryRoleId: PrimaryRole.ApplicationServiceProvider);

            _organisationDatastore.Setup(x => x.ById(otherOrgId)).Returns(otherOrg);

            var nhsdOrgId = Guid.NewGuid().ToString();
            var nhsd      = Creator.GetOrganisation(id: nhsdOrgId, primaryRoleId: PrimaryRole.GovernmentDepartment);

            _organisationDatastore.Setup(x => x.ById(nhsdOrgId)).Returns(nhsd);

            var ctx = Creator.GetContext(orgId: orgId, role: Roles.Supplier);

            _context.Setup(c => c.HttpContext).Returns(ctx);

            var filter   = new ContactFilter(_context.Object, _organisationDatastore.Object);
            var cont1    = GetContact(orgId: orgId);
            var cont2    = GetContact(orgId: orgId);
            var cont3    = GetContact(orgId: otherOrgId);
            var cont4    = GetContact(orgId: nhsdOrgId);
            var contacts = new[] { cont1, cont2, cont3, cont4 };


            var res = filter.Filter(contacts.AsQueryable());


            res.Should().BeEquivalentTo(new[] { cont1, cont2, cont4 });
        }
示例#2
0
        public void Filter_None_Returns_All()
        {
            var orgFilt  = new OrganisationsFilter();
            var govOrg   = Creator.GetOrganisation(id: Guid.NewGuid().ToString(), primaryRoleId: PrimaryRole.GovernmentDepartment);
            var supp1Org = Creator.GetOrganisation(id: Guid.NewGuid().ToString(), primaryRoleId: PrimaryRole.ApplicationServiceProvider);
            var supp2Org = Creator.GetOrganisation(id: Guid.NewGuid().ToString(), primaryRoleId: PrimaryRole.ApplicationServiceProvider);
            var orgs     = new[] { govOrg, supp1Org, supp2Org };

            var filterOrg = orgFilt.Filter(orgs.ToList());

            filterOrg.Should().BeEquivalentTo(orgs);
        }
示例#3
0
        public void Filter_Supplier_Returns_NotOther()
        {
            var suppOrgId = Guid.NewGuid().ToString();
            var ctx       = Creator.GetContext(orgId: suppOrgId, role: Roles.Supplier);

            _context.Setup(c => c.HttpContext).Returns(ctx);
            var orgFilt  = new OrganisationFilter(_context.Object);
            var govOrg   = Creator.GetOrganisation(id: Guid.NewGuid().ToString(), primaryRoleId: PrimaryRole.GovernmentDepartment);
            var supp1Org = Creator.GetOrganisation(id: suppOrgId, primaryRoleId: PrimaryRole.ApplicationServiceProvider);
            var supp2Org = Creator.GetOrganisation(id: Guid.NewGuid().ToString(), primaryRoleId: PrimaryRole.ApplicationServiceProvider);
            var orgs     = new[] { govOrg, supp1Org, supp2Org };

            var filterOrg = orgFilt.Filter(orgs.ToList().AsQueryable());

            filterOrg.Should().BeEquivalentTo(new[] { govOrg, supp1Org });
        }