public void AddCharacter_HasCharacterIDButNoCharacter_NotFoundException() { var game = GameUtility.Create(dbContext, 0, 0); var imageFile = Substitute.For <IFormFile>(); Assert.ThrowsAsync <NotFoundException>(() => testObj.AddCharacter(game.ID, 1, "Char1", imageFile)); }
public void AddCharacter_NameTaken_ConflictException() { var game = GameUtility.Create(dbContext, 1, 0); var imageFile = Substitute.For <IFormFile>(); Assert.ThrowsAsync <ConflictException>(() => testObj.AddCharacter(game.ID, null, game.Characters[0].Name, imageFile)); }
public async Task AddStage_Valid_Stage() { var game = GameUtility.Create(dbContext, 0, 0); var stage = await testObj.AddStage(game.ID, null, "Stage1"); Assert.IsNotNull(stage); }
public async Task AddStage_OldStage_ValuesUpdated() { const string name = "NewName"; var game = GameUtility.Create(dbContext, 0, 1); var stage = await testObj.AddStage(game.ID, game.Stages[0].ID, name); Assert.AreEqual(name, stage.Name); }
public async Task AddCharacter_OldCharacterNoImage_ValuesUpdated() { const string name = "NewName"; var game = GameUtility.Create(dbContext, 1, 0); var character = await testObj.AddCharacter(game.ID, game.Characters[0].ID, name, null); Assert.AreEqual(name, character.Name); }
public async Task AddCharacter_OldCharacterNewImage_NewImageUploaded() { var game = GameUtility.Create(dbContext, 1, 0); var imageFile = Substitute.For <IFormFile>(); await testObj.AddCharacter(game.ID, game.Characters[0].ID, "Char1", imageFile); await cdnService.Received(1).ReplaceImageAsync(Arg.Any <string>(), imageFile, ClimbImageRules.CharacterPic); }
public async Task AddCharacter_OldCharacterNoImage_ImageKeyNotUpdated() { var game = GameUtility.Create(dbContext, 1, 0); var imageKey = game.Characters[0].ImageKey; var character = await testObj.AddCharacter(game.ID, game.Characters[0].ID, "Char1", null); Assert.AreEqual(imageKey, character.ImageKey); }
public async Task AddCharacter_NewCharacter_UploadImage() { var game = GameUtility.Create(dbContext, 1, 0); var imageFile = Substitute.For <IFormFile>(); await testObj.AddCharacter(game.ID, null, "Char1", imageFile); await cdnService.Received(1).UploadImageAsync(imageFile, ClimbImageRules.CharacterPic); }
public async Task AddCharacter_Valid_Character() { var game = GameUtility.Create(dbContext, 0, 0); var imageFile = Substitute.For <IFormFile>(); var character = await testObj.AddCharacter(game.ID, null, "Char1", imageFile); Assert.IsNotNull(character); }
public async Task Get_HasGame_Ok() { var game = GameUtility.Create(dbContext, 2, 2); var result = await testObj.Get(game.ID); var resultObj = result.GetObject <GameDto>(); ControllerUtility.AssertStatusCode(result, HttpStatusCode.OK); Assert.AreEqual(game.ID, resultObj.ID); }
public async Task AddCharacter_OldCharacterNewImage_ImageKeySaved() { var game = GameUtility.Create(dbContext, 1, 0); var imageFile = Substitute.For <IFormFile>(); const string imageKey = "key"; cdnService.ReplaceImageAsync(Arg.Any <string>(), imageFile, ClimbImageRules.CharacterPic).Returns(imageKey); var character = await testObj.AddCharacter(game.ID, game.Characters[0].ID, "Char1", imageFile); Assert.AreEqual(imageKey, character.ImageKey); }
public void Update_InvalidMaxMatchPoints_BadRequestException(int maxPoints) { var logoFile = Substitute.For <IFormFile>(); var createRequest = new UpdateRequest("GameName", 1, maxPoints, true, logoFile); Assert.ThrowsAsync <BadRequestException>(() => testObj.Update(createRequest)); var game = GameUtility.Create(dbContext, 0, 0); var updateRequest = new UpdateRequest("GameName", 1, maxPoints, true, logoFile) { GameID = game.ID, }; Assert.ThrowsAsync <BadRequestException>(() => testObj.Update(updateRequest)); }
public void Update_NameTaken_Conflict() { var logoFile = Substitute.For <IFormFile>(); var gameOld = GameUtility.Create(dbContext, 1, 1); var createRequest = new UpdateRequest(gameOld.Name, 1, 2, true, logoFile); Assert.ThrowsAsync <ConflictException>(() => testObj.Update(createRequest)); var game = GameUtility.Create(dbContext, 0, 0, name: "GameOther"); var updateRequest = new UpdateRequest(gameOld.Name, 1, 2, true, null) { GameID = game.ID, }; Assert.ThrowsAsync <ConflictException>(() => testObj.Update(updateRequest)); }
public void AddStage_HasStageIDButNoStage_NotFoundException() { var game = GameUtility.Create(dbContext, 0, 0); Assert.ThrowsAsync <NotFoundException>(() => testObj.AddStage(game.ID, 1, "Stage1")); }
public void AddStage_NameTaken_ConflictException() { var game = GameUtility.Create(dbContext, 0, 1); Assert.ThrowsAsync <ConflictException>(() => testObj.AddStage(game.ID, null, game.Stages[0].Name)); }
public void AddCharacter_NewCharacterNoImageKey_NullArgumentException() { var game = GameUtility.Create(dbContext, 0, 0); Assert.ThrowsAsync <ArgumentNullException>(() => testObj.AddCharacter(game.ID, null, "Char1", null)); }