Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
Refactors timeline integration tests to make it more pluggable
Browse files Browse the repository at this point in the history
  • Loading branch information
PoLaKoSz committed Dec 15, 2018
1 parent 75660ff commit 5435711
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 43 deletions.
19 changes: 19 additions & 0 deletions src/Models/Track.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,24 @@ public Track(string artist, string name)
Artist = artist;
Name = name;
}


public override string ToString()
{
return string.Format("{0} - {1}", Artist, Name);
}

public override bool Equals(object obj)
{
var another = (Track)obj;

if (!Artist.Equals(another.Artist))
return false;

if (!Name.Equals(another.Name))
return false;

return true;
}
}
}
198 changes: 198 additions & 0 deletions tests/Integration/EndPoints/HomePage/TimeLine/WithElements.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
using System.Collections.Generic;
using PoLaKoSz.MusicFM.Models;

namespace PoLaKoSz.MusicFM.Tests.Integration.EndPoints.HomePage.TimeLine
{
class WithElements : TimeLineBase
{
private static readonly List<Track> _raw;
private static readonly List<Track> _cleaned;



static WithElements()
{
_raw = new List<Track>()
{
new Track("MUSIC KILLERS LIVE", "AT THE TURNTABLE: NIGEL STATELY"),
new Track("AT THE TURNTABLE", "NIGEL STATELY"),
new Track("David Guetta Ft. Nicky Minaj & Jason Derulo", "Goodbye"),
new Track("Zoli Vekony Ft. James Cash", "Moments"),
new Track("Wellhello", "Odaút (Pixa Remix - Radio Edit)"),
new Track("Radics Gigi & Talán Attila", "Fade Away"),
new Track("(MK DJ) Willcox", "In My Head (Radio Edit)"),
new Track("New Level Empire", "Homelights"),
new Track("Cloud9+", "Scars"),
new Track("Andrewboy", "Születésnapomra"),
new Track("Anymood", "In Your Eyes"),
new Track("Juli Fabian & Zoohacker", "Sizzlin' (Zoohacker Edit)"),
new Track("Crazibiza And Block & Crown", "That Same Feeling (Luca Debonaire Remix)"),
new Track("Metrush", "Cover It Up"),
new Track("Cloud 9+ Ft. Járai Márk & Fura Csé", "Valaki mondja el"),
new Track("Julian Kid", "Back 2 U"),
new Track("T-Maniac", "Bang It Louder"),
new Track("Király Viktor ft. DMC", "Running Out of Time"),
new Track("Radics Gigi", "Budapest Szerelem"),
new Track("Goldhand", "Believe In Me"),
new Track("Kállay Saunders Band", "Juliet"),
new Track("Pápai Joci", "Kirakós"),
new Track("Wolf Kati", "What about my dreams"),
new Track("Veréb Tamás", "Éjszakai járat"),
new Track("Cubicore & Shane 54", "Budokan"),
new Track("Kállay Saunders", "I Don't Really Care"),
new Track("ByeAlex és a Slepp", "Menned kéne"),
new Track("Martin Tay", "Be Proud (Canard Remix)"),
new Track("(MK DJ) Willcox", "Tequila"),
new Track("Edo Denova Ft. Tóth Andi", "Smells Like Teen Spirit"),
new Track("Divello & Syntax feat. Chris L", "Long Way Home"),
new Track("DRBRS, Fekete Vonat Ft. Halott Pénz", "Hol van az a lány"),
new Track("Crazibiza", "Desert Storm"),
new Track("Max & Sims", "Keep It Warm"),
new Track("Unique", "Egy lépéssel a föld felett"),
new Track("Kállay Saunders And Joe Dean", "Talk That"),
new Track("The Biebers", "Rakjuk össze!"),
new Track("Earth N Days", "Turkish Bazar"),
new Track("Wellhello", "Az utolsó hibám"),
new Track("Julian Kid", "Give It To Me (Radio Edit)"),
new Track("Janicsák Veca", "Hazudjunk igazat"),
new Track("Király Viktor", "Budapest Girl"),
new Track("Cubicore & Shane 54", "Out Of Time"),
new Track("Heincz Gábor 'Biga'", "Learning to Let Go"),
new Track("Golden Life", "Family (Nigel Stately Remix)"),
new Track("Follow The Flow", "Maradok távol"),
new Track("Wellhello", "Odaút"),
new Track("Post Malone", "Better Now"),
new Track("DJ Khaled Ft. Rihanna & Bryson Tiller", "Wild Thoughts"),
new Track("Rudimental Ft. James Arthur", "Sun Comes Up"),
new Track("Rita Ora", "Let You Love Me"),
new Track("Tiesto", "Jackie Chan (Clean Version)"),
new Track("Marshmello And Bastille", "Happier"),
new Track("Black Coffee And David Guetta Ft. Delilah Montagu", "Drive"),
new Track("Don Diablo Ft. Emeli Sande & Gucci Mane", "Survive"),
new Track("Sia", "Chandelier"),
new Track("Train", "Shake Up Christmas"),
new Track("Calvin Harris Ft. Sam Smith", "Promises"),
new Track("Matoma & Enrique Iglesias", "I Don't Dance (Without You)"),
new Track("Cheat Codes & Little Mix", "Only You"),
new Track("Dom Dolla", "Take It"),
new Track("P!nk", "Secrets"),
new Track("G-Eazy feat. Halsey", "Him & I"),
new Track("Alesso", "Remedy"),
new Track("KAZKA", "Plakala"),
new Track("Silk City ft. Dua Lipa", "Electricity"),
new Track("Armin van Buuren Ft. Conrad", "Sex, Love and Water"),
new Track("Marshmello And Bastille", "Happier"),
new Track("Follow The Flow", "Anyám mondta"),
new Track("Post Malone", "Better Now"),
new Track("Lucas & Steve Ft. Brandy", "I Could Be Wrong"),
new Track("(MK DJ) Antonyo", "Give Me The Night"),
new Track("Kelly Clarkson", "Underneath the Tree"),
new Track("Wellhello", "Nem olyan lány"),
new Track("Fatboy Slim", "Praise You (Purple Disco Machine Remix)"),
new Track("New Level Empire & Republic", "Valódi"),
new Track("Radics Gigi", "Moment"),
new Track("New Level Empire", "Odafuthatnánk"),
new Track("Max & Sims", "Keep It Warm"),
new Track("Zoli Vekony Ft. James Cash", "Moments"),
new Track("New Level Empire", "Megtörténtünk"),
new Track("(MK DJ) Willcox", "Tequila"),
new Track("New Level Empire", "Valahol"),
new Track("Gashi Ft. French Montana & Dj Snake", "Creep On Me"),
new Track("Rita Ora", "Anywhere"),
};

_cleaned = new List<Track>()
{
new Track("David Guetta Ft. Nicky Minaj & Jason Derulo", "Goodbye"),
new Track("Zoli Vekony Ft. James Cash", "Moments"),
new Track("Wellhello", "Odaút (Pixa Remix - Radio Edit)"),
new Track("Radics Gigi & Talán Attila", "Fade Away"),
new Track("Willcox", "In My Head (Radio Edit)"),
new Track("New Level Empire", "Homelights"),
new Track("Cloud9+", "Scars"),
new Track("Andrewboy", "Születésnapomra"),
new Track("Anymood", "In Your Eyes"),
new Track("Juli Fabian & Zoohacker", "Sizzlin' (Zoohacker Edit)"),
new Track("Crazibiza And Block & Crown", "That Same Feeling (Luca Debonaire Remix)"),
new Track("Metrush", "Cover It Up"),
new Track("Cloud 9+ Ft. Járai Márk & Fura Csé", "Valaki mondja el"),
new Track("Julian Kid", "Back 2 U"),
new Track("T-Maniac", "Bang It Louder"),
new Track("Király Viktor ft. DMC", "Running Out of Time"),
new Track("Radics Gigi", "Budapest Szerelem"),
new Track("Goldhand", "Believe In Me"),
new Track("Kállay Saunders Band", "Juliet"),
new Track("Pápai Joci", "Kirakós"),
new Track("Wolf Kati", "What about my dreams"),
new Track("Veréb Tamás", "Éjszakai járat"),
new Track("Cubicore & Shane 54", "Budokan"),
new Track("Kállay Saunders", "I Don't Really Care"),
new Track("ByeAlex és a Slepp", "Menned kéne"),
new Track("Martin Tay", "Be Proud (Canard Remix)"),
new Track("Willcox", "Tequila"),
new Track("Edo Denova Ft. Tóth Andi", "Smells Like Teen Spirit"),
new Track("Divello & Syntax feat. Chris L", "Long Way Home"),
new Track("DRBRS, Fekete Vonat Ft. Halott Pénz", "Hol van az a lány"),
new Track("Crazibiza", "Desert Storm"),
new Track("Max & Sims", "Keep It Warm"),
new Track("Unique", "Egy lépéssel a föld felett"),
new Track("Kállay Saunders And Joe Dean", "Talk That"),
new Track("The Biebers", "Rakjuk össze!"),
new Track("Earth N Days", "Turkish Bazar"),
new Track("Wellhello", "Az utolsó hibám"),
new Track("Julian Kid", "Give It To Me (Radio Edit)"),
new Track("Janicsák Veca", "Hazudjunk igazat"),
new Track("Király Viktor", "Budapest Girl"),
new Track("Cubicore & Shane 54", "Out Of Time"),
new Track("Heincz Gábor 'Biga'", "Learning to Let Go"),
new Track("Golden Life", "Family (Nigel Stately Remix)"),
new Track("Follow The Flow", "Maradok távol"),
new Track("Wellhello", "Odaút"),
new Track("Post Malone", "Better Now"),
new Track("DJ Khaled Ft. Rihanna & Bryson Tiller", "Wild Thoughts"),
new Track("Rudimental Ft. James Arthur", "Sun Comes Up"),
new Track("Rita Ora", "Let You Love Me"),
new Track("Tiesto", "Jackie Chan (Clean Version)"),
new Track("Marshmello And Bastille", "Happier"),
new Track("Black Coffee And David Guetta Ft. Delilah Montagu", "Drive"),
new Track("Don Diablo Ft. Emeli Sande & Gucci Mane", "Survive"),
new Track("Sia", "Chandelier"),
new Track("Train", "Shake Up Christmas"),
new Track("Calvin Harris Ft. Sam Smith", "Promises"),
new Track("Matoma & Enrique Iglesias", "I Don't Dance (Without You)"),
new Track("Cheat Codes & Little Mix", "Only You"),
new Track("Dom Dolla", "Take It"),
new Track("P!nk", "Secrets"),
new Track("G-Eazy feat. Halsey", "Him & I"),
new Track("Alesso", "Remedy"),
new Track("KAZKA", "Plakala"),
new Track("Silk City ft. Dua Lipa", "Electricity"),
new Track("Armin van Buuren Ft. Conrad", "Sex, Love and Water"),
new Track("Marshmello And Bastille", "Happier"),
new Track("Follow The Flow", "Anyám mondta"),
new Track("Post Malone", "Better Now"),
new Track("Lucas & Steve Ft. Brandy", "I Could Be Wrong"),
new Track("Antonyo", "Give Me The Night"),
new Track("Kelly Clarkson", "Underneath the Tree"),
new Track("Wellhello", "Nem olyan lány"),
new Track("Fatboy Slim", "Praise You (Purple Disco Machine Remix)"),
new Track("New Level Empire & Republic", "Valódi"),
new Track("Radics Gigi", "Moment"),
new Track("New Level Empire", "Odafuthatnánk"),
new Track("Max & Sims", "Keep It Warm"),
new Track("Zoli Vekony Ft. James Cash", "Moments"),
new Track("New Level Empire", "Megtörténtünk"),
new Track("Willcox", "Tequila"),
new Track("New Level Empire", "Valahol"),
new Track("Gashi Ft. French Montana & Dj Snake", "Creep On Me"),
new Track("Rita Ora", "Anywhere"),
};
}

public WithElements()
: base(_raw, _cleaned)
{
base.SetResponseFromServer(@"HomePage\timeline.html");
}
}
}
57 changes: 57 additions & 0 deletions tests/Integration/EndPoints/HomePage/TimeLineBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using NUnit.Framework;
using PoLaKoSz.MusicFM.Models;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace PoLaKoSz.MusicFM.Tests.Integration.EndPoints.HomePage
{
abstract class TimeLineBase : TestClassBase
{
private readonly PoLaKoSz.MusicFM.EndPoints.HomePage _homePage;
private readonly List<Track> _raw;
private readonly List<Track> _cleaned;



public TimeLineBase(List<Track> raw, List<Track> cleaned)
{
_homePage = new PoLaKoSz.MusicFM.EndPoints.HomePage(base.HttpClient);
_raw = raw;
_cleaned = cleaned;
}



[Test]
public async Task Check_Cleaned_Tracklist_Count()
{
var actual = await _homePage.Timeline();

Assert.That(actual.Count, Is.EqualTo(_cleaned.Count));
}

[Test]
public async Task Check_Raw_Tracklist_Count()
{
var actual = await _homePage.Timeline(new CleanerMock());

Assert.That(actual.Count, Is.EqualTo(_raw.Count));
}

[Test]
public async Task Can_Parse_Timeline_Without_Any_Formatting()
{
var actual = await _homePage.Timeline(new CleanerMock());

CollectionAssert.AreEqual(_raw, actual);
}

[Test]
public async Task Can_Parse_Timeline_With_Formatting()
{
var actual = await _homePage.Timeline();

CollectionAssert.AreEqual(_cleaned, actual);
}
}
}
42 changes: 0 additions & 42 deletions tests/Integration/EndPoints/HomePageTests.cs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Integration/Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<None Update="StaticResources\MusicKillers\zoohacker.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="StaticResources\timeline.html">
<None Update="StaticResources\HomePage\timeline.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions tests/Integration/TestClassBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,16 @@ protected void SetServerResponse(string fileName)
{
HttpClient.ResponseFromServer = File.ReadAllText(Path.Combine(_path, $"{fileName}.html"));
}

/// <summary>
/// Get the source code from a previously saved file.
/// </summary>
/// <param name="fileName">Non null file name WITH extension
/// and relative or absolute path.</param>
/// <returns>Non null string.</returns>
protected void SetResponseFromServer(string fileName)
{
HttpClient.ResponseFromServer = File.ReadAllText(Path.Combine(_path, fileName));
}
}
}

0 comments on commit 5435711

Please sign in to comment.