public async Task DeleteDeveloper_SupplyNoValueForDeveloperId_ReturnsBadRequestWithMessage()
        {
            var result = await _controller.DeleteDeveloper(null) as BadRequestErrorMessageResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Supply Id of developer", result.Message);
        }
Esempio n. 2
0
        public async Task TestDelete()
        {
            var developer = new Developer();

            developer.Description = "TestDescription";
            developer.Location    = "TestDescription";
            developer.LogoUrl     = "TestDescription";
            developer.Name        = "TestDescription";
            await developersController.PostDeveloper(developer);

            OkObjectResult resultDelete = (OkObjectResult)await developersController.DeleteDeveloper(developer.Id);

            Assert.That(resultDelete.StatusCode == 200);
        }
Esempio n. 3
0
        public async Task DeleteDeveloper_NegativeId_NotFoundResult()
        {
            // Arrange
            const int developerIdToDelete = -10;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());
            Developer expectedDeveloper = GetFakeList().Where(d => d.ID == developerIdToDelete).FirstOrDefault();

            // Act
            using (var context = new GameReviewsContext(options))
            {
                DevelopersController developersController = new DevelopersController(context);
                var actionResult = (await developersController.DeleteDeveloper(developerIdToDelete));
                var result       = actionResult.Result;

                // Assert
                Assert.IsType <NotFoundResult>(result);
            }
        }
Esempio n. 4
0
        public async Task DeleteDeveloper_ExistingId_TaskActionResultContainsDeletedDeveloper()
        {
            // Arrange
            const int developerIdToDelete = 3;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());
            Developer expectedDeveloper = GetFakeList().Where(d => d.ID == developerIdToDelete).FirstOrDefault();

            // Act
            using (var context = new GameReviewsContext(options))
            {
                DevelopersController developersController = new DevelopersController(context);
                var       actionResult    = (await developersController.DeleteDeveloper(developerIdToDelete));
                var       result          = actionResult.Result;
                Developer actualDeveloper = actionResult.Value;

                // Assert
                Assert.IsNotType <NotFoundResult>(result);
                Assert.True(context.Developers.Find(developerIdToDelete) == null);
                Assert.True(AreEqual(expectedDeveloper, actualDeveloper));
            }
        }