예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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));
        }
예제 #13
0
        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));
        }
예제 #14
0
        public void AddStage_HasStageIDButNoStage_NotFoundException()
        {
            var game = GameUtility.Create(dbContext, 0, 0);

            Assert.ThrowsAsync <NotFoundException>(() => testObj.AddStage(game.ID, 1, "Stage1"));
        }
예제 #15
0
        public void AddStage_NameTaken_ConflictException()
        {
            var game = GameUtility.Create(dbContext, 0, 1);

            Assert.ThrowsAsync <ConflictException>(() => testObj.AddStage(game.ID, null, game.Stages[0].Name));
        }
예제 #16
0
        public void AddCharacter_NewCharacterNoImageKey_NullArgumentException()
        {
            var game = GameUtility.Create(dbContext, 0, 0);

            Assert.ThrowsAsync <ArgumentNullException>(() => testObj.AddCharacter(game.ID, null, "Char1", null));
        }