Exemplo n.º 1
0
        public async Task TestInsert()
        {
            var developer = new Developer();

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

            Assert.That(result.StatusCode == 201);
        }
Exemplo n.º 2
0
        public async Task PostDeveloper_CorrectDeveloperWithCorrectValuesAndZeroIdSetted_CreatedAtActionResultWithGeneratedId()
        {
            // Arrange
            const int idToSet = 0;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Developer developerToCreate = new Developer()
            {
                Name    = "NewDevelope",
                Website = "NewWebsite",
                ID      = idToSet
            };

            // Act
            using (var context = new GameReviewsContext(options))
            {
                DevelopersController developersController = new DevelopersController(context);
                var result = (await developersController.PostDeveloper(developerToCreate)).Result;

                // Assert
                Assert.True(developerToCreate.ID != idToSet);
                Assert.IsType <CreatedAtActionResult>(result);
            }
        }
Exemplo n.º 3
0
        public async Task PostDeveloper_CorrectDeveloperWithCorrectValuesAndIdNotSet_CreatedAtActionResult()
        {
            // Arrange
            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Developer developerToCreate = new Developer()
            {
                Name    = "NewDevelope",
                Website = "NewWebsite"
            };

            // Act
            using (var context = new GameReviewsContext(options))
            {
                DevelopersController developersController = new DevelopersController(context);
                var result = (await developersController.PostDeveloper(developerToCreate)).Result;

                // Assert
                Assert.True(context.Developers.Contains(developerToCreate));
                Assert.IsType <CreatedAtActionResult>(result);
            }
        }
Exemplo n.º 4
0
        public async Task PostDeveloper_CorrectDeveloperWithCorrectValuesAndNegativeIdSetted_BadRequestResult()
        {
            // Arrange
            const int idToSet = -1;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Developer developerToCreate = new Developer()
            {
                Name    = "NewDevelope",
                Website = "NewWebsite",
                ID      = idToSet
            };

            // Act
            using (var context = new GameReviewsContext(options))
            {
                DevelopersController developersController = new DevelopersController(context);
                var result = (await developersController.PostDeveloper(developerToCreate)).Result;

                // Assert
                Assert.IsType <BadRequestResult>(result);
            }
        }