Ejemplo n.º 1
0
 //  private ICacheProvider _cacheProvider;
 public OrgAppService(OrgRepository repository, OrgQueryRepository queryOrgRepository, CorpQueryRepository queryCorpRepository, EmployeeQueryRepository queryEmployeeRepository)
 // : base(repository)//, queryOnlyRepository)
 {
     _repository              = repository;
     _queryCorpRepository     = queryCorpRepository;
     _queryOrgRepository      = queryOrgRepository;
     _queryEmployeeRepository = queryEmployeeRepository;
 }
        public void Then_contact_username_is_Updated()
        {
            var guid = Guid.NewGuid();

            ContactQueryRepository.Setup(x => x.GetBySignInId(It.IsAny <Guid>())).Returns(Task.FromResult(
                                                                                              new Contact
            {
                Id       = guid,
                Username = "******",
                Email    = "*****@*****.**"
            }));

            IList <ContactRole> listOfRoles = new List <ContactRole> {
                new ContactRole {
                    RoleName = "SuperUser"
                }
            };

            ContactQueryRepository.Setup(x => x.GetRolesFor(It.IsAny <Guid>()))
            .Returns(Task.FromResult(listOfRoles));
            OrgQueryRepository.Setup(r => r.GetByUkPrn(12345)).ReturnsAsync(new Organisation
            {
                Status = OrganisationStatus.Live,
                EndPointAssessorOrganisationId = "EPA001",
                EndPointAssessorUkprn          = 12345,
            });
            ContactQueryRepository.Setup(r => r.GetContact("username")).ReturnsAsync(default(Contact));
            ContactQueryRepository.Setup(r => r.GetContactFromEmailAddress("*****@*****.**")).ReturnsAsync(new Contact
            {
                DisplayName = "Display Name",
                Email       = "*****@*****.**",
                Username    = "******"
            });

            ContactRepository.Setup(x => x.UpdateUserName(guid, "*****@*****.**")).Returns(Task.FromResult(default(object)));

            // Username wiil be ignored and replaced with email address
            Handler.Handle(
                new LoginRequest()
            {
                Roles = new List <string>()
                {
                    "ABC", "DEF", "EPA"
                },
                UkPrn       = 12345,
                Username    = "******",
                DisplayName = "Display Name",
                Email       = "*****@*****.**"
            }, new CancellationToken()).Wait();

            ContactRepository.Verify(m => m.UpdateUserName(guid, "*****@*****.**"));
        }
Ejemplo n.º 3
0
        public void Then_Epao_PrimaryContact_is_Updated()
        {
            ContactQueryRepository.Setup(x => x.GetBySignInId(It.IsAny <Guid>())).Returns(Task.FromResult(
                                                                                              new Contact
            {
                Id = Guid.NewGuid()
            }));

            IList <ContactRole> listOfRoles = new List <ContactRole> {
                new ContactRole {
                    RoleName = "SuperUser"
                }
            };

            ContactQueryRepository.Setup(x => x.GetRolesFor(It.IsAny <Guid>()))
            .Returns(Task.FromResult(listOfRoles));
            OrgQueryRepository.Setup(r => r.GetByUkPrn(12345)).ReturnsAsync(new Organisation
            {
                Status = OrganisationStatus.Live,
                EndPointAssessorOrganisationId = "EPA001",
                EndPointAssessorUkprn          = 12345,
                PrimaryContact = null
            });
            ContactQueryRepository.Setup(r => r.GetContact("username")).ReturnsAsync(new Contact
            {
                DisplayName = "Display Name",
                Email       = "*****@*****.**",
                Username    = "******"
            });

            Handler.Handle(
                new LoginRequest()
            {
                Roles = new List <string>()
                {
                    "ABC", "DEF", "EPA"
                },
                UkPrn       = 12345,
                Username    = "******",
                DisplayName = "Display Name",
                Email       = "*****@*****.**"
            }, new CancellationToken()).Wait();

            //Mediator.Verify(m =>
            //    m.Send(
            //        It.Is<UpdateOrganisationRequest>(r =>
            //            r.EndPointAssessorOrganisationId == "EPA001" && r.EndPointAssessorUkprn == 12345
            //            && r.PrimaryContact == "username"), It.IsAny<CancellationToken>()));
        }
        public void Then_invite_pending_is_returned_when_invite_pending_user()
        {
            OrgQueryRepository.Setup(r => r.GetByUkPrn(12345)).ReturnsAsync(new Organisation {
                Status = OrganisationStatus.New
            });
            var response = Handler.Handle(new LoginRequest()
            {
                Roles = new List <string>()
                {
                    "ABC", "DEF", "EPA"
                }, UkPrn = 12345, SignInId = Guid.Empty
            }, new CancellationToken()).Result;

            response.Result.Should().Be(LoginResult.InvitePending);
        }