public void Filter_Supplier_Returns_OwnNHSD() { var orgId = Guid.NewGuid().ToString(); var org = Creator.GetOrganisation(id: orgId, primaryRoleId: PrimaryRole.ApplicationServiceProvider); var otherOrgId = Guid.NewGuid().ToString(); var otherOrg = Creator.GetOrganisation(id: otherOrgId, primaryRoleId: PrimaryRole.ApplicationServiceProvider); var nhsdOrgId = Guid.NewGuid().ToString(); var nhsd = Creator.GetOrganisation(id: nhsdOrgId, primaryRoleId: PrimaryRole.GovernmentDepartment); var cont1 = Creator.GetContact(orgId: orgId); var cont2 = Creator.GetContact(orgId: orgId); var cont3 = Creator.GetContact(orgId: otherOrgId); var cont4 = Creator.GetContact(orgId: nhsdOrgId); _organisationDatastore.Setup(x => x.ByContact(cont1.Id)).Returns(org); _organisationDatastore.Setup(x => x.ByContact(cont2.Id)).Returns(org); _organisationDatastore.Setup(x => x.ByContact(cont3.Id)).Returns(otherOrg); _organisationDatastore.Setup(x => x.ByContact(cont4.Id)).Returns(nhsd); var ctx = Creator.GetContext(orgId: orgId, role: Roles.Supplier); _context.Setup(c => c.HttpContext).Returns(ctx); var filter = new ContactsFilter(_context.Object, _organisationDatastore.Object); var contacts = new[] { cont1, cont2, cont3, cont4 }; var res = filter.Filter(contacts); res.Should().BeEquivalentTo(new[] { cont1, cont2, cont4 }); }
public void Filter_None_Returns_All() { var filter = new ContactsFilter(); var contacts = new[] { Creator.GetContact(), Creator.GetContact(), Creator.GetContact() }; var res = filter.Filter(contacts); res.Should().BeEquivalentTo(contacts); }
public void Filter_NonSupplier_Returns_All(string role) { var ctx = Creator.GetContext(role: role); _context.Setup(c => c.HttpContext).Returns(ctx); var filter = new ContactsFilter(_context.Object, _organisationDatastore.Object); var contacts = new[] { Creator.GetContact(), Creator.GetContact(), Creator.GetContact() }; var res = filter.Filter(contacts); res.Should().BeEquivalentTo(contacts); }