示例#1
0
            private Task <bool> InvokeTransformUserToOrganization(int affectedRecords, User admin = null)
            {
                // Arrange
                var service = new TestableUserService();
                var account = new User("Account");

                admin = admin ?? new User("Admin")
                {
                    Credentials = new Credential[] {
                        new CredentialBuilder().CreateExternalCredential(
                            issuer: "AzureActiveDirectory",
                            value: "abc123",
                            identity: "Admin",
                            tenantId: "zyx987")
                    }
                };

                service.MockDatabase
                .Setup(db => db.ExecuteSqlResourceAsync(It.IsAny <string>(), It.IsAny <object[]>()))
                .Returns(Task.FromResult(affectedRecords));

                service.MockSecurityPolicyService
                .Setup(sp => sp.SubscribeAsync(It.IsAny <User>(), It.IsAny <IUserSecurityPolicySubscription>()))
                .Returns(Task.FromResult(true));

                // Act
                return(service.TransformUserToOrganization(account, admin, "token"));
            }
示例#2
0
            public async Task WhenSqlResultIsPositive_ReturnsTrue(int affectedRecords)
            {
                // Arrange
                var service = new TestableUserService();
                var account = new User("Account");
                var admin   = new User("Admin");

                admin.Credentials.Add(
                    new CredentialBuilder().CreateExternalCredential(
                        issuer: "MicrosoftAccount",
                        value: "abc123",
                        identity: "Admin",
                        tenantId: "zyx987"));

                service.MockDatabase
                .Setup(db => db.ExecuteSqlResourceAsync(It.IsAny <string>(), It.IsAny <object[]>()))
                .Returns(Task.FromResult(affectedRecords));

                // Act
                Assert.True(await service.TransformUserToOrganization(account, admin, "token"));
            }