Esempio n. 1
0
        public async Task RemoveEvent_ShouldReturn_NotFound_And_NullContent()
        {
            //Arrange
            var mockRepository = new Mock<IRepository>();
            var controller = new EventController(mockRepository.Object);
            controller.Request = new HttpRequestMessage();
            controller.Request.SetConfiguration(new HttpConfiguration());

            //Act
            var response = await controller.RemoveEvent("10");

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
            Assert.IsNull(response.Content);
        }
Esempio n. 2
0
        public async Task RemoveEvent_ShouldReturn_BadRequest_and_NotNullContent()
        {
            //Arrange
            var mockRepository = new Mock<IRepository>();
            var controller = new EventController(mockRepository.Object);
            controller.Request = new HttpRequestMessage();
            controller.Request.SetConfiguration(new HttpConfiguration());

            //Act
            controller.ModelState.AddModelError("", "");
            var response = await controller.RemoveEvent(GetDemoEvent().Id);

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
Esempio n. 3
0
        public async Task RemoveEvent_ShouldReturnOk()
        {
            //Arrange
            var context = new TestAppContext();
            var item = GetDemoEvent();
            context.Events.Add(item);

            //var mockRepository = new Mock<IRepository>(context);
            var repository = new EventRepository(context);
            var controller = new EventController(repository);
            controller.Request = new HttpRequestMessage();
            controller.Request.SetConfiguration(new HttpConfiguration());
            
            //Act
            var response = await controller.RemoveEvent(item.Id);
            
            //Assert
            Assert.IsNotNull(response);
            Assert.IsNull(response.Content);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }