1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-24 12:35:25 +01:00
bitwarden-server/test/Api.Test/Utilities/EnumMatchesAttributeTests.cs
Conner Turnbull 721d2969d4
[PM-8830] Billing Enums Rename (#4180)
* Renamed ProductType to ProductTierType

* Renamed Product properties to ProductTier

* Moved ProductTierType to Bit.Core.Billing.Enums namespace from Bit.Core.Enums

* Moved PlanType enum to Bit.Core.Billing.Enums

* Moved StaticStore to Bit.Core.Billing.Models.StaticStore namespace

* Added ProductType enum

* dotnet format
2024-06-14 15:34:47 -04:00

65 lines
1.6 KiB
C#

using Bit.Api.Utilities;
using Bit.Core.Billing.Enums;
using Bit.Core.Enums;
using Xunit;
namespace Bit.Api.Test.Utilities;
public class EnumMatchesAttributeTests
{
[Fact]
public void IsValid_NullInput_False()
{
var enumMatchesAttribute =
new EnumMatchesAttribute<PlanType>(PlanType.TeamsMonthly, PlanType.EnterpriseMonthly);
var result = enumMatchesAttribute.IsValid(null);
Assert.False(result);
}
[Fact]
public void IsValid_NullAccepted_False()
{
var enumMatchesAttribute =
new EnumMatchesAttribute<PlanType>();
var result = enumMatchesAttribute.IsValid(PlanType.TeamsMonthly);
Assert.False(result);
}
[Fact]
public void IsValid_EmptyAccepted_False()
{
var enumMatchesAttribute =
new EnumMatchesAttribute<PlanType>([]);
var result = enumMatchesAttribute.IsValid(PlanType.TeamsMonthly);
Assert.False(result);
}
[Fact]
public void IsValid_ParseFails_False()
{
var enumMatchesAttribute =
new EnumMatchesAttribute<PlanType>(PlanType.TeamsMonthly, PlanType.EnterpriseMonthly);
var result = enumMatchesAttribute.IsValid(GatewayType.Stripe);
Assert.False(result);
}
[Fact]
public void IsValid_Matches_True()
{
var enumMatchesAttribute =
new EnumMatchesAttribute<PlanType>(PlanType.TeamsMonthly, PlanType.EnterpriseMonthly);
var result = enumMatchesAttribute.IsValid(PlanType.TeamsMonthly);
Assert.True(result);
}
}