Skip to content

Commit

Permalink
Merge branch 'release/3.805.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-ci committed Jul 18, 2024
2 parents 77e8e62 + 1fa5f7e commit 3a2f5cf
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<!-- These properties will be shared for all projects -->
<PropertyGroup>
<VersionPrefix>3.804.0</VersionPrefix>
<VersionPrefix>3.805.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
50 changes: 50 additions & 0 deletions src/VirtoCommerce.Skyflow.Core/Models/SkyflowCard.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using VirtoCommerce.Platform.Core.Common;

namespace VirtoCommerce.Skyflow.Core.Models
{
Expand Down Expand Up @@ -28,6 +29,55 @@ public class SkyflowCard

[JsonPropertyName("user_id")]
public string UserId { get; set; }

[JsonPropertyName("active")]
public bool Active
{
get
{
return CheckIsActive();
}
}

private bool CheckIsActive()
{
var month = 0;
var year = 0;
if (!CardExpiration.IsNullOrEmpty())
{
// format MM/YY
var parts = CardExpiration.Split('/');
if (parts.Length == 2)
{
month = int.Parse(parts[0]);
year = int.Parse(parts[1]);
}
}

if (!ExpiryMonth.IsNullOrEmpty())
{
month = int.Parse(ExpiryMonth);
}
if (!ExpiryYear.IsNullOrEmpty())
{
year = int.Parse(ExpiryYear);
}

if (year != 0 && month != 0)
{
// 08/20

if (year < 100)
{
year += 2000;
}

var now = System.DateTime.UtcNow;
return year > now.Year || (year == now.Year && month >= now.Month);
}

return true;
}
}

public class SkyflowItemModel
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.Skyflow.Web/module.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<id>VirtoCommerce.Skyflow</id>
<version>3.804.0</version>
<version>3.805.0</version>
<version-tag></version-tag>

<platformVersion>3.800.0</platformVersion>
Expand Down
1 change: 1 addition & 0 deletions src/VirtoCommerce.Skyflow.XApi/Schemas/SkyflowCardType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public SkyflowCardType()
Field(x => x.ExpiryYear, nullable: true);
Field(x => x.SkyflowId);
Field(x => x.UserId);
Field(x => x.Active);
}
}
43 changes: 43 additions & 0 deletions tests/VirtoCommerce.Skyflow.Tests/SkyflowCardTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using VirtoCommerce.Skyflow.Core.Models;
using Xunit;

namespace VirtoCommerce.Skyflow.Tests;

[Trait("Category", "Unit")]
public class SkyflowCardTest
{
[Theory]
[InlineData("10", "20", false)]
[InlineData("01", "38", true)]
[InlineData("02", "98", true)]
public void MonthYearTest(string month, string year, bool isActive)
{
var card = new SkyflowCard { ExpiryMonth = month, ExpiryYear = year, };

Assert.Equal(isActive, card.Active);
}

[Theory]
[InlineData("10/20", false)]
[InlineData("01/2038", true)]
[InlineData("02/98", true)]
public void ExpireDateTest(string expireDate, bool isActive)
{
var card = new SkyflowCard { CardExpiration = expireDate };

Assert.Equal(isActive, card.Active);
}

[Fact]
public void CurrentMonthTests()
{
var month = DateTime.UtcNow.Month.ToString("00");
var year = DateTime.UtcNow.Year.ToString("00");
var card = new SkyflowCard { ExpiryMonth = month, ExpiryYear = year, };

Assert.True(card.Active);
}


}
13 changes: 0 additions & 13 deletions tests/VirtoCommerce.Skyflow.Tests/Test.cs

This file was deleted.

0 comments on commit 3a2f5cf

Please sign in to comment.