@ -50,6 +50,7 @@ public class OrganizationsControllerTests : IDisposable
@@ -50,6 +50,7 @@ public class OrganizationsControllerTests : IDisposable
private readonly IUpdateSecretsManagerSubscriptionCommand _ updateSecretsManagerSubscriptionCommand ;
private readonly IUpgradeOrganizationPlanCommand _ upgradeOrganizationPlanCommand ;
private readonly IAddSecretsManagerSubscriptionCommand _ addSecretsManagerSubscriptionCommand ;
private readonly IPushNotificationService _ pushNotificationService ;
private readonly OrganizationsController _ sut ;
@ -75,6 +76,7 @@ public class OrganizationsControllerTests : IDisposable
@@ -75,6 +76,7 @@ public class OrganizationsControllerTests : IDisposable
_ updateSecretsManagerSubscriptionCommand = Substitute . For < IUpdateSecretsManagerSubscriptionCommand > ( ) ;
_ upgradeOrganizationPlanCommand = Substitute . For < IUpgradeOrganizationPlanCommand > ( ) ;
_ addSecretsManagerSubscriptionCommand = Substitute . For < IAddSecretsManagerSubscriptionCommand > ( ) ;
_ pushNotificationService = Substitute . For < IPushNotificationService > ( ) ;
_ sut = new OrganizationsController (
_ organizationRepository ,
@ -96,7 +98,8 @@ public class OrganizationsControllerTests : IDisposable
@@ -96,7 +98,8 @@ public class OrganizationsControllerTests : IDisposable
_l icensingService ,
_ updateSecretsManagerSubscriptionCommand ,
_ upgradeOrganizationPlanCommand ,
_ addSecretsManagerSubscriptionCommand ) ;
_ addSecretsManagerSubscriptionCommand ,
_ pushNotificationService ) ;
}
public void Dispose ( )
@ -358,8 +361,20 @@ public class OrganizationsControllerTests : IDisposable
@@ -358,8 +361,20 @@ public class OrganizationsControllerTests : IDisposable
public async Task EnableCollectionEnhancements_Success ( Organization organization )
{
organization . FlexibleCollections = false ;
var admin = new OrganizationUser { UserId = Guid . NewGuid ( ) , Type = OrganizationUserType . Admin } ;
var owner = new OrganizationUser { UserId = Guid . NewGuid ( ) , Type = OrganizationUserType . Owner } ;
var user = new OrganizationUser { UserId = Guid . NewGuid ( ) , Type = OrganizationUserType . User } ;
var invited = new OrganizationUser
{
UserId = null ,
Type = OrganizationUserType . Admin ,
Email = "invited@example.com"
} ;
var orgUsers = new List < OrganizationUser > { admin , owner , user , invited } ;
_ currentContext . OrganizationOwner ( organization . Id ) . Returns ( true ) ;
_ organizationRepository . GetByIdAsync ( organization . Id ) . Returns ( organization ) ;
_ organizationUserRepository . GetManyByOrganizationAsync ( organization . Id , null ) . Returns ( orgUsers ) ;
await _ sut . EnableCollectionEnhancements ( organization . Id ) ;
@ -368,6 +383,9 @@ public class OrganizationsControllerTests : IDisposable
@@ -368,6 +383,9 @@ public class OrganizationsControllerTests : IDisposable
Arg . Is < Organization > ( o = >
o . Id = = organization . Id & &
o . FlexibleCollections ) ) ;
await _ pushNotificationService . Received ( 1 ) . PushSyncVaultAsync ( admin . UserId . Value ) ;
await _ pushNotificationService . Received ( 1 ) . PushSyncVaultAsync ( owner . UserId . Value ) ;
await _ pushNotificationService . DidNotReceive ( ) . PushSyncVaultAsync ( user . UserId . Value ) ;
}
[Theory, AutoData]
@ -381,6 +399,7 @@ public class OrganizationsControllerTests : IDisposable
@@ -381,6 +399,7 @@ public class OrganizationsControllerTests : IDisposable
await _ organizationRepository . DidNotReceiveWithAnyArgs ( ) . EnableCollectionEnhancements ( Arg . Any < Guid > ( ) ) ;
await _ organizationService . DidNotReceiveWithAnyArgs ( ) . ReplaceAndUpdateCacheAsync ( Arg . Any < Organization > ( ) ) ;
await _ pushNotificationService . DidNotReceiveWithAnyArgs ( ) . PushSyncVaultAsync ( Arg . Any < Guid > ( ) ) ;
}
[Theory, AutoData]
@ -395,5 +414,6 @@ public class OrganizationsControllerTests : IDisposable
@@ -395,5 +414,6 @@ public class OrganizationsControllerTests : IDisposable
await _ organizationRepository . DidNotReceiveWithAnyArgs ( ) . EnableCollectionEnhancements ( Arg . Any < Guid > ( ) ) ;
await _ organizationService . DidNotReceiveWithAnyArgs ( ) . ReplaceAndUpdateCacheAsync ( Arg . Any < Organization > ( ) ) ;
await _ pushNotificationService . DidNotReceiveWithAnyArgs ( ) . PushSyncVaultAsync ( Arg . Any < Guid > ( ) ) ;
}
}