mirror of
https://github.com/bitwarden/server.git
synced 2025-02-18 02:11:22 +01:00
71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
|
using Bit.Core.Enums;
|
|||
|
using Bit.Core.Models.StaticStore;
|
|||
|
using Bit.Core.Utilities;
|
|||
|
using Xunit;
|
|||
|
|
|||
|
namespace Bit.Core.Test.Utilities;
|
|||
|
|
|||
|
|
|||
|
public class StaticStoreTests
|
|||
|
{
|
|||
|
[Fact]
|
|||
|
public void StaticStore_Initialization_Success()
|
|||
|
{
|
|||
|
var plans = StaticStore.Plans;
|
|||
|
Assert.NotNull(plans);
|
|||
|
Assert.NotEmpty(plans);
|
|||
|
Assert.Equal(17, plans.Count());
|
|||
|
}
|
|||
|
|
|||
|
[Theory]
|
|||
|
[InlineData(PlanType.EnterpriseAnnually)]
|
|||
|
public void StaticStore_GetPasswordManagerPlanByPlanType_Success(PlanType planType)
|
|||
|
{
|
|||
|
var plan = StaticStore.GetPasswordManagerPlan(planType);
|
|||
|
|
|||
|
Assert.NotNull(plan);
|
|||
|
Assert.Equal(planType, plan.Type);
|
|||
|
}
|
|||
|
|
|||
|
[Theory]
|
|||
|
[InlineData(PlanType.EnterpriseAnnually)]
|
|||
|
public void StaticStore_GetSecretsManagerPlanByPlanType_Success(PlanType planType)
|
|||
|
{
|
|||
|
var plan = StaticStore.GetSecretsManagerPlan(planType);
|
|||
|
|
|||
|
Assert.NotNull(plan);
|
|||
|
Assert.Equal(planType, plan.Type);
|
|||
|
}
|
|||
|
|
|||
|
[Theory]
|
|||
|
[InlineData(PlanType.EnterpriseAnnually)]
|
|||
|
public void StaticStore_GetPasswordManagerPlan_ReturnsPasswordManagerPlans(PlanType planType)
|
|||
|
{
|
|||
|
var plan = StaticStore.GetPasswordManagerPlan(planType);
|
|||
|
Assert.NotNull(plan);
|
|||
|
Assert.Equal(BitwardenProductType.PasswordManager, plan.BitwardenProduct);
|
|||
|
}
|
|||
|
|
|||
|
[Theory]
|
|||
|
[InlineData(PlanType.EnterpriseAnnually)]
|
|||
|
public void StaticStore_GetSecretsManagerPlan_ReturnsSecretManagerPlans(PlanType planType)
|
|||
|
{
|
|||
|
var plan = StaticStore.GetSecretsManagerPlan(planType);
|
|||
|
Assert.NotNull(plan);
|
|||
|
Assert.Equal(BitwardenProductType.SecretsManager, plan.BitwardenProduct);
|
|||
|
}
|
|||
|
|
|||
|
[Theory]
|
|||
|
[InlineData(PlanType.EnterpriseAnnually, BitwardenProductType.PasswordManager)]
|
|||
|
public void StaticStore_AddDuplicatePlans_SingleOrDefaultThrowsException(PlanType planType, BitwardenProductType bitwardenProductType)
|
|||
|
{
|
|||
|
var plansStore = new List<Plan>
|
|||
|
{
|
|||
|
new Plan { Type = PlanType.EnterpriseAnnually, BitwardenProduct = BitwardenProductType.PasswordManager },
|
|||
|
new Plan { Type = PlanType.EnterpriseAnnually, BitwardenProduct = BitwardenProductType.PasswordManager }
|
|||
|
};
|
|||
|
|
|||
|
Assert.Throws<InvalidOperationException>(() => plansStore.SingleOrDefault(p => p.Type == planType && p.BitwardenProduct == bitwardenProductType));
|
|||
|
}
|
|||
|
}
|