-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods to add artists and events, including unit tests
- Loading branch information
1 parent
7333293
commit 3fca6a5
Showing
7 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using GloboTicket.Catalog.Repositories; | ||
using GloboTicket.Catalog.Infrastructure; | ||
using GloboTicket.Catalog; | ||
using Microsoft.Extensions.Logging; | ||
namespace unittests | ||
{ | ||
[TestClass] | ||
public class EventRepositoryTests | ||
{ | ||
private Mock<ILogger<EventRepository>> mockLogger; | ||
private EventRepository eventRepository; | ||
|
||
[TestInitialize] | ||
public void TestInitialize() | ||
{ | ||
mockLogger = new Mock<ILogger<EventRepository>>(); | ||
eventRepository = new EventRepository(mockLogger.Object); | ||
} | ||
|
||
[TestMethod] | ||
public async Task AddArtist_ShouldReturnAddedArtist() | ||
{ | ||
var artist = await eventRepository.AddArtist("Artist3", "Genre3"); | ||
Assert.AreEqual("Artist3", artist.Name); | ||
Assert.AreEqual("Genre3", artist.Genre); | ||
} | ||
|
||
|
||
|
||
[TestMethod] | ||
public async Task GetArtistById_ShouldReturnCorrectArtist() | ||
{ | ||
var addedArtist = await eventRepository.AddArtist("Artist4", "Genre4"); | ||
|
||
var artist = await eventRepository.GetArtistById(addedArtist.Id); | ||
Assert.AreEqual(addedArtist.Id, artist.Id); | ||
} | ||
|
||
[TestMethod] | ||
public async Task AddEvent_ShouldReturnAddedEvent() | ||
{ | ||
var @event = new Event { EventId = Guid.NewGuid(), Name = "Event3" }; | ||
var result = await eventRepository.AddEvent(@event); | ||
Assert.AreEqual(@event.EventId, result.EventId); | ||
|
||
var eventbyId = await eventRepository.GetEventById(@event.EventId); | ||
Assert.AreEqual(@event.EventId, eventbyId.EventId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters