Skip to content

Commit

Permalink
Added new photo size type "J", fixed set Id for Market (#1603)
Browse files Browse the repository at this point in the history
## Список изменений
- Добавлен новый тип размера изображений "J".
- Исправлено присвоение Id для вложений типа Market.

##### Обязательно выполните следующие пункты:
- [x] Проверьте что ваш код не содержит конфликтов, и исправьте их по
необходимости
- [x] Напишите тесты, и обязательно проверьте что не падают другие.


![image](https://github.com/vknet/vk/assets/17874234/ea2d3287-bde8-45af-b73e-44881711e8bb)

---------

Co-authored-by: dslekom <dslekom@zzlogistics.ru>
  • Loading branch information
dslekom and dslekom authored Dec 15, 2023
1 parent d663218 commit 377ac3c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
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}";
}
}

0 comments on commit 377ac3c

Please sign in to comment.