public void Authorize_NoUserProfile() { // Arrange. var providerViewModel = new ProviderViewModelBuilder().With(new List <ProviderSiteViewModel> { new ProviderSiteViewModel() }).Build(); MockProviderProvider.Setup(p => p.GetProviderViewModel(It.IsAny <string>(), true)).Returns(providerViewModel); MockProviderUserProvider.Setup(p => p.GetProviderUsers(It.IsAny <string>())) .Returns(new List <ProviderUserViewModel> { new ProviderUserViewModel() }); var mediator = GetMediator(); var principal = new ClaimsPrincipalBuilder().WithName("User001").WithUkprn("00001").WithRole(Roles.Faa).Build(); // Act. var response = mediator.Authorize(principal); // Assert. response.AssertMessage(ProviderUserMediatorCodes.Authorize.NoUserProfile, AuthorizeMessages.NoUserProfile, UserMessageLevel.Info); }
public void Authorize_Ok_ShouldSetProviderId() { // Arrange. var providerViewModel = new ProviderViewModelBuilder() .With(42) .With(new List <ProviderSiteViewModel> { new ProviderSiteViewModel() }).Build(); MockProviderProvider .Setup(mock => mock.GetProviderViewModel(It.IsAny <string>(), true)) .Returns(providerViewModel); MockProviderUserProvider .Setup(mock => mock.GetUserProfileViewModel(It.IsAny <string>())) .Returns(new ProviderUserViewModel { EmailAddressVerified = true }); var mediator = GetMediator(); var principal = new ClaimsPrincipalBuilder() .WithName("User001") .WithUkprn("00001") .WithRole(Roles.Faa) .Build(); // Act. var response = mediator.Authorize(principal); // Assert. response.AssertCodeAndMessage(ProviderUserMediatorCodes.Authorize.Ok); response.ViewModel.ProviderId.Should().Be(providerViewModel.ProviderId); }