Skip to content

Commit

Permalink
Merge pull request #12 from GranDen-Corp/dev
Browse files Browse the repository at this point in the history
version 0.0.6
  • Loading branch information
windperson authored Jul 7, 2020
2 parents e03ef8d + 5915f04 commit d6b48af
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<Version Condition=" '$(Version)'=='' ">0.0.5</Version>
<PackageReleaseNotes>0.0.5 :
&#xD;&#xA;Fix some EF Core query bug
<Version Condition=" '$(Version)'=='' ">0.0.6</Version>
<PackageReleaseNotes>0.0.6 :
&#xD;&#xA;Fix GeoPoint reverse point query bug
&#xD;&#xA;
</PackageReleaseNotes>
</PropertyGroup>
Expand Down
12 changes: 8 additions & 4 deletions src/GranDen.Game.ApiLib.Bingo/Repositories/BingoPointRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public BingoPointRepo(BingoGameDbContext bingoGameDbContext, IBingoGameInfoRepo
public IEnumerable<BingoPoint> GetMappedBingoPoint(string bingoGameName, string bingoPlayerId, string geoPointId)
{
var geoPoint = _bingoGameDbContext.MappingGeoPoints.AsNoTracking()
.Include(m => m.PointProjections).ThenInclude(p => p.BingoPoint)
.Include(m => m.PointProjections).ThenInclude(p => p.BingoPlayerInfo)
.Include(m => m.PointProjections).ThenInclude(p => p.BingoPoint).ThenInclude(b => b.BelongingGame)
.Include(m => m.PointProjections).ThenInclude(p => p.BingoPoint).ThenInclude(b => b.BelongingPlayer)
.FirstOrDefault(m =>
m.GeoPointId == geoPointId || m.GeoPointRedirected && m.RedirectedGeoPointId == geoPointId);

Expand All @@ -39,18 +41,20 @@ public IEnumerable<BingoPoint> GetMappedBingoPoint(string bingoGameName, string
}

var pointProjections =
geoPoint.PointProjections.Where(p => p.BingoPlayerInfo.PlayerId == bingoPlayerId ).ToList();
geoPoint.PointProjections.Where(p => p.BingoPlayerInfo.PlayerId == bingoPlayerId).ToList();

if (pointProjections.Count == 0)
{
throw new Exception($"Point Projection not exist.");
}

var ret = pointProjections.Where(p => p.BingoPoint.BelongingGame.GameName == bingoGameName).Select( p => p.BingoPoint).ToList();
var ret = pointProjections.Where(p => p.BingoPoint.BelongingGame.GameName == bingoGameName)
.Select(p => p.BingoPoint).ToList();

if (ret.Count == 0)
{
throw new Exception($"Bingo mark point(s) at Geo Point Id '{geoPointId}' that belongs to player '{bingoPlayerId}' on Bingo Game '{bingoGameName}' not exist.");
throw new Exception(
$"Bingo mark point(s) at Geo Point Id '{geoPointId}' that belongs to player '{bingoPlayerId}' on Bingo Game '{bingoGameName}' not exist.");
}

return ret;
Expand Down
27 changes: 27 additions & 0 deletions test/GranDen.Game.ApiLib.Bingo.Test/BingoPlayerApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ public void PlayerShouldBeAbleToJoinNonExpiredGame()
Assert.Equal(bingoGameName, joinedGame.GameName);
}

[Fact]
public void CanGetCorrectMarked2DPoint()
{
//Arrange
const string testPlayerId = "test_player_1";
const string testGeoPointId = "geoPoint_07";

var bingoGameService = _serviceProvider.GetService<IBingoGameService<string>>();

Assert.True(bingoGameService.JoinGame(PresetBingoGameName, testPlayerId));
Assert.True(bingoGameService.MarkBingoPoint(PresetBingoGameName, testPlayerId, new BingoPointDto {X = 1, Y = 2}));

//Act
var bingoPointRepo = _serviceProvider.GetService<IBingoPointRepo>();
var candidateBingoPoints = bingoPointRepo.GetMappedBingoPoint(PresetBingoGameName, testPlayerId, testGeoPointId);

//Assert
var bingoPoints = candidateBingoPoints.ToList();
Assert.Single(bingoPoints);
var thePoint = bingoPoints.First();
Assert.Equal(PresetBingoGameName, thePoint.BelongingGame.GameName);
Assert.Equal(testPlayerId, thePoint.BelongingPlayer.PlayerId);
Assert.Equal(1, thePoint.MarkPoint.X);
Assert.Equal(2, thePoint.MarkPoint.Y);
Assert.True(thePoint.MarkPoint.Marked);
}

[Fact]
public void PlayerCanAddBingoPointStatusDuringValidGamePeriod()
{
Expand Down

0 comments on commit d6b48af

Please sign in to comment.