public void TestProvisionTenant() { bool handled1 = false; bool handled2 = false; DomainEventPublisher.Instance.Subscribe<TenantProvisioned>(e => handled1 = true); DomainEventPublisher.Instance.Subscribe<TenantAdministratorRegistered>(e => handled2 = true); Mock<ITenantRepository> tenantRepository = new Mock<ITenantRepository>(); tenantRepository.Setup(r => r.GetNextIdentity()).Returns(new TenantId(Guid.NewGuid().ToString())); Mock<IUserRepository> userRepository = new Mock<IUserRepository>(); Mock<IRoleRepository> roleRepository = new Mock<IRoleRepository>(); TenantProvisioningService service = new TenantProvisioningService(tenantRepository.Object, userRepository.Object, roleRepository.Object); Tenant tenant = service.ProvisionTenant("Test Tenant", "This is a test tenant.", new FullName("colin", "zhang"), new EmailAddress("*****@*****.**"), new PostalAddress("123 Pearl Street", "Boulder", "CO", "80301", "US"), new Telephone("303-555-1210"), new Telephone("303-555-1212")); Assert.IsTrue(handled1); Assert.IsTrue(handled2); Assert.NotNull(tenant.TenantId); Assert.NotNull(tenant.TenantId.Id); Assert.AreEqual(36, tenant.TenantId.Id.Length); Assert.AreEqual("Test Tenant", tenant.Name); Assert.AreEqual("This is a test tenant.", tenant.Description); }
public IdentityApplicationService(AuthenticationService authenticationService, GroupMemberService groupMemberService, TenantProvisioningService tenantProvisioningService, ITenantRepository tenantRepository, IGroupRepository groupRepository, IUserRepository userRepository) { this._authenticationService = authenticationService; this._groupMemberService = groupMemberService; this._groupRepository = groupRepository; this._tenantProvisioningService = tenantProvisioningService; this._tenantRepository = tenantRepository; this._userRepository = userRepository; }
protected override void SetUp() { base.SetUp(); this._tenantRepository = new Mock<ITenantRepository>(); this._groupRepository = new Mock<IGroupRepository>(); this._userRepository = new Mock<IUserRepository>(); this._roleRepository = new Mock<IRoleRepository>(); this._authenticationService = new AuthenticationService(_tenantRepository.Object, _userRepository.Object, ServiceLocator.GetService<IEncryptionService>()); this._groupMemberService = new GroupMemberService(this._userRepository.Object, this._groupRepository.Object); this._tenantProvisioningService = new TenantProvisioningService(_tenantRepository.Object, _userRepository.Object, _roleRepository.Object); this._identityApplicationService = new IdentityApplicationService(this._authenticationService, this._groupMemberService, this._tenantProvisioningService, this._tenantRepository.Object, this._groupRepository.Object, this._userRepository.Object); }