Skip to content

Commit

Permalink
Рефакторинг. Тесты.
Browse files Browse the repository at this point in the history
  • Loading branch information
K1llMan committed Jan 26, 2023
1 parent 886792f commit 9d2e32d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
36 changes: 36 additions & 0 deletions src/Yandex.Music.Api.Tests/Tests/Models/ModelsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using FluentAssertions;

using Xunit;
using Xunit.Abstractions;
using Xunit.Extensions.Ordering;

using Yandex.Music.Api.Models.Account;
using Yandex.Music.Api.Models.Common;
using Yandex.Music.Api.Models.Track;
using Yandex.Music.Api.Tests.Traits;

namespace Yandex.Music.Api.Tests.Tests.API
{
[Collection("Yandex Test Harness")]
[TestBeforeAfter]
public class ModelsTest : YandexTest
{
public ModelsTest(YandexTestHarness fixture, ITestOutputHelper output) : base(fixture, output)
{
}

[Fact]
[YandexTrait(TraitGroup.Models)]
public void YTrackAlbumPair_ValidData_True()
{
YTrackAlbumPair pair = new() {
Id = "1"
};

pair.ToString().Should().Be("1");

pair.AlbumId = "1";
pair.ToString().Should().Be("1:1");
}
}
}
2 changes: 1 addition & 1 deletion src/Yandex.Music.Api.Tests/Traits/TraitGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Yandex.Music.Api.Tests.Traits
{
public enum TraitGroup
{
AccountAPI,
Models,
AlbumAPI,
ArtistAPI,
LibraryAPI,
Expand Down
10 changes: 2 additions & 8 deletions src/Yandex.Music.Api/Models/Track/YTrackAlbumPair.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Text;
using System.Linq;

namespace Yandex.Music.Api.Models.Track
{
Expand All @@ -10,13 +10,7 @@ public class YTrackAlbumPair : IEquatable<YTrackAlbumPair>

public override string ToString()
{
var sb = new StringBuilder(Id);
if (string.IsNullOrWhiteSpace(AlbumId))
return sb.ToString();

sb.Append(':');
sb.Append(AlbumId);
return sb.ToString();
return string.Join(":", new[] { Id, AlbumId }.Where(s => !string.IsNullOrEmpty(s)));
}

#region IEquatable
Expand Down

0 comments on commit 9d2e32d

Please sign in to comment.