-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
206 additions
and
4 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
87 changes: 87 additions & 0 deletions
87
...ime.Application.Tests.Unit/Estimations/Queries/GetEstimationsOverviewQueryHandlerTests.cs
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,87 @@ | ||
// ****************************************************************************** | ||
// © 2020 Sebastiaan Dammann | damsteen.nl | ||
// | ||
// File: : GetEstimationsOverviewQueryHandlerTests.cs | ||
// Project : PokerTime.Application.Tests.Unit | ||
// ****************************************************************************** | ||
|
||
namespace PokerTime.Application.Tests.Unit.Estimations.Queries { | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Application.Common; | ||
using Application.Estimations.Queries; | ||
using Domain.Entities; | ||
using NUnit.Framework; | ||
using Support; | ||
|
||
[TestFixture] | ||
public sealed class GetEstimationsOverviewQueryHandlerTests : QueryTestBase { | ||
[Test] | ||
public void GetEstimationsOverviewQueryHandlerTests_ThrowsNotFoundException_WhenNotFound() { | ||
// Given | ||
const string sessionId = "surely-not-found"; | ||
var query = new GetEstimationsOverviewQuery(sessionId); | ||
var handler = new GetEstimationsOverviewQueryHandler(this.Context, this.Mapper); | ||
|
||
// When | ||
TestDelegate action = () => handler.Handle(query, CancellationToken.None).GetAwaiter().GetResult(); | ||
|
||
// Then | ||
Assert.That(action, Throws.InstanceOf<NotFoundException>()); | ||
} | ||
|
||
[Test] | ||
public async Task GetEstimationsOverviewQueryHandlerTests_ReturnsUserStoryEstimations() { | ||
// Given | ||
var session = new Session { | ||
Title = "Yet another test", | ||
Participants = | ||
{ | ||
new Participant { Name = "John", Color = Color.BlueViolet }, | ||
new Participant { Name = "Jane", Color = Color.Aqua }, | ||
}, | ||
HashedPassphrase = "abef", | ||
CurrentStage = SessionStage.Discussion | ||
}; | ||
string sessionId = session.UrlId.StringId; | ||
this.Context.Sessions.Add(session); | ||
await this.Context.SaveChangesAsync(CancellationToken.None); | ||
|
||
this.Context.UserStories.Add(new UserStory { | ||
Title = "First", | ||
Estimations = | ||
{ | ||
new Estimation {Participant = session.Participants.First(), Symbol = this.Context.Symbols.First()}, | ||
new Estimation {Participant = session.Participants.Last(), Symbol = this.Context.Symbols.Skip(1).First()} | ||
}, | ||
Session = session | ||
}); | ||
|
||
this.Context.UserStories.Add(new UserStory { | ||
Title = "First", | ||
Estimations = | ||
{ | ||
new Estimation | ||
{Participant = session.Participants.First(), Symbol = this.Context.Symbols.Skip(1).First()}, | ||
new Estimation {Participant = session.Participants.Last(), Symbol = this.Context.Symbols.First()} | ||
}, | ||
Session = session | ||
}); | ||
await this.Context.SaveChangesAsync(CancellationToken.None); | ||
|
||
var query = new GetEstimationsOverviewQuery(sessionId); | ||
var handler = new GetEstimationsOverviewQueryHandler(this.Context, this.Mapper); | ||
|
||
// When | ||
GetEstimationsOverviewQueryResponse result = await handler.Handle(query, CancellationToken.None); | ||
|
||
// Then | ||
Assert.That(result, Is.Not.Null); | ||
|
||
Assert.That(result.UserStoryEstimations, Has.Count.EqualTo(2)); | ||
} | ||
|
||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
...s/PokerTime.Application.Tests.Unit/Estimations/Queries/GetEstimationsQueryHandlerTests.cs
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,114 @@ | ||
// ****************************************************************************** | ||
// © 2020 Sebastiaan Dammann | damsteen.nl | ||
// | ||
// File: : GetEstimationsQueryHandlerTests.cs | ||
// Project : PokerTime.Application.Tests.Unit | ||
// ****************************************************************************** | ||
|
||
namespace PokerTime.Application.Tests.Unit.Estimations.Queries { | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Application.Common; | ||
using Application.Estimations.Queries; | ||
using Domain.Entities; | ||
using NUnit.Framework; | ||
using Support; | ||
|
||
[TestFixture] | ||
public sealed class GetEstimationsQueryHandlerTests : QueryTestBase { | ||
[Test] | ||
public void GetEstimationsQueryHandlerTests_ThrowsNotFoundException_WhenSessionNotFound() { | ||
// Given | ||
const string sessionId = "surely-not-found"; | ||
var query = new GetEstimationsQuery(sessionId, 3); | ||
var handler = new GetEstimationsQueryHandler(this.Context, this.Mapper); | ||
|
||
// When | ||
TestDelegate action = () => handler.Handle(query, CancellationToken.None).GetAwaiter().GetResult(); | ||
|
||
// Then | ||
Assert.That(action, Throws.InstanceOf<NotFoundException>()); | ||
} | ||
|
||
[Test] | ||
public async Task GetEstimationsQueryHandlerTests_ThrowsNotFoundException_WhenUserStoryNotFound() { | ||
// Given | ||
var session = new Session { | ||
Title = "Yet another test", | ||
Participants = | ||
{ | ||
new Participant { Name = "John", Color = Color.BlueViolet }, | ||
new Participant { Name = "Jane", Color = Color.Aqua }, | ||
}, | ||
HashedPassphrase = "abef", | ||
CurrentStage = SessionStage.Discussion | ||
}; | ||
string sessionId = session.UrlId.StringId; | ||
this.Context.Sessions.Add(session); | ||
await this.Context.SaveChangesAsync(CancellationToken.None); | ||
|
||
var query = new GetEstimationsQuery(sessionId, -1); | ||
var handler = new GetEstimationsQueryHandler(this.Context, this.Mapper); | ||
|
||
// When | ||
TestDelegate action = () => handler.Handle(query, CancellationToken.None).GetAwaiter().GetResult(); | ||
|
||
// Then | ||
Assert.That(action, Throws.InstanceOf<NotFoundException>()); | ||
} | ||
|
||
[Test] | ||
public async Task GetEstimationsQueryHandlerTests_ReturnsUserStoryEstimations() { | ||
// Given | ||
var session = new Session { | ||
Title = "Yet another test", | ||
Participants = | ||
{ | ||
new Participant { Name = "John", Color = Color.BlueViolet }, | ||
new Participant { Name = "Jane", Color = Color.Aqua }, | ||
}, | ||
HashedPassphrase = "abef", | ||
CurrentStage = SessionStage.Discussion | ||
}; | ||
string sessionId = session.UrlId.StringId; | ||
this.Context.Sessions.Add(session); | ||
await this.Context.SaveChangesAsync(CancellationToken.None); | ||
|
||
this.Context.UserStories.Add(new UserStory { | ||
Title = "First", | ||
Estimations = | ||
{ | ||
new Estimation {Participant = session.Participants.First(), Symbol = this.Context.Symbols.First()}, | ||
new Estimation {Participant = session.Participants.Last(), Symbol = this.Context.Symbols.Skip(1).First()} | ||
}, | ||
Session = session | ||
}); | ||
|
||
UserStory lastUserStory = this.Context.UserStories.Add(new UserStory { | ||
Title = "First", | ||
Estimations = | ||
{ | ||
new Estimation | ||
{Participant = session.Participants.First(), Symbol = this.Context.Symbols.Skip(1).First()}, | ||
new Estimation {Participant = session.Participants.Last(), Symbol = this.Context.Symbols.First()} | ||
}, | ||
Session = session | ||
}).Entity; | ||
await this.Context.SaveChangesAsync(CancellationToken.None); | ||
|
||
var query = new GetEstimationsQuery(sessionId, lastUserStory.Id); | ||
var handler = new GetEstimationsQueryHandler(this.Context, this.Mapper); | ||
|
||
// When | ||
GetEstimationsQueryResponse result = await handler.Handle(query, CancellationToken.None); | ||
|
||
// Then | ||
Assert.That(result, Is.Not.Null); | ||
|
||
Assert.That(result.Estimations, Has.Count.EqualTo(2)); | ||
} | ||
|
||
} | ||
} |
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