public void EditForInvalidOfferId_WhenItsCalled_ShouldReturnBadRequest()
        {
            // Arrange
            AddRole("HR");
            int      id    = -1;
            JobOffer offer = new JobOffer {
                Id = id
            };

            // Act
            var result = controller.Edit(offer).Result;

            // Assert
            Assert.IsInstanceOf <BadRequestResult>(result);
        }
Esempio n. 2
0
        public async Task When_Edit_ReturnsEditView_in_JobOfferController()
        {
            var options = new DbContextOptionsBuilder <WebApplication1Context>().UseInMemoryDatabase(databaseName: "Test5").Options;

            using (var context = new WebApplication1Context(options))
            {
                context.JobOffer.Add(new JobOffer()
                {
                    Id = 1, JobTitle = "job1"
                });
                context.SaveChanges();
                var controller = new JobOffersController(context);
                var result     = await controller.Edit(1);

                var viewResult = Assert.IsType <ViewResult>(result);
                Assert.Equal(1, ((JobOffer)viewResult.Model).Id);
                Assert.Equal("job1", ((JobOffer)viewResult.Model).JobTitle);
            }
        }