Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new photo size type "J", fixed set Id for Market #1603

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions VkNet.Tests/Enum/StringEnums/StringEnumTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ public void PhotoSizeTypeTest()
Utilities.Deserialize<PhotoSizeType>("e")
.Should()
.Be(PhotoSizeType.E);

Utilities.Deserialize<PhotoSizeType>("j")
.Should()
.Be(PhotoSizeType.J);
}

[Fact]
Expand Down
24 changes: 24 additions & 0 deletions VkNet.Tests/Models/MarketModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using FluentAssertions;
using VkNet.Model;
using Xunit;

namespace VkNet.Tests.Models;

public class MarketModel
{
[Fact]
public void ToString_MarketShouldHaveIdAndAccessKey()
{
var market = new Market
{
Id = 1234,
OwnerId = 1234,
AccessKey = "test"
};

var result = market.ToString();

result.Should()
.Be("market1234_1234_test");
}
}
10 changes: 9 additions & 1 deletion VkNet/Enums/StringEnums/PhotoSizeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,13 @@ public enum PhotoSizeType
/// <remarks>
/// <see href="https://dev.vk.com/ru/reference/objects/photo-sizes">Документация</see>
/// </remarks>
L
L,

/// <summary>
/// В документации отсутствует описание
/// </summary>
/// <remarks>
/// <see href="https://dev.vk.com/ru/reference/objects/photo-sizes">Документация</see>
/// </remarks>
J
}
22 changes: 16 additions & 6 deletions VkNet/Model/Attachments/Market.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ public class Market : MediaAttachment
{
get => _id;

set {
if (value is null)
{
_id ??= -1;
}
}
set => _id = value ?? -1;
}

/// <summary>
Expand Down Expand Up @@ -120,4 +115,19 @@ public class Market : MediaAttachment
[JsonProperty("button_title")]
[JsonConverter(typeof(SafetyEnumJsonConverter))]
public MarketItemButtonTitle ButtonTitle { get; set; }

/// <summary>
/// Преобразовать вложение в строку.
/// </summary>
/// <returns>
/// Строковое представление
/// </returns>
public override string ToString()
{
var result = $"{Alias}{OwnerId}_{Id}";

return string.IsNullOrWhiteSpace(AccessKey)
? result
: $"{result}_{AccessKey}";
}
}
Loading