Example #1
0
        public async Task UpdateEventTest_ShouldReturn_NotFoundStatusCode_And_NullContent()
        {
            //arrange            
            var repository = new EventRepository(new TestAppContext());
            var controller = new EventController(repository);
            controller.Request = new HttpRequestMessage();
            controller.Request.SetConfiguration(new HttpConfiguration());
            
            //act
            var response = await controller.UpdateEvent(new Event { Id="agfgfgf"});

            //assert
            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
            Assert.IsNull(response.Content);
        }
Example #2
0
        public async Task GetEvent_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.GetEvent("2");

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
            Assert.IsNull(response.Content);
        }
Example #3
0
        public async Task GetEvent_ShouldReturn_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.GetEvent(GetDemoEvent().Id);

            //Assert
            Assert.IsNotNull(response);
            Assert.IsNull(response.Content);
        }
        public async Task ShowAllEvents_ShouldReturnOk_And_IsNotNull()
        {
            //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.ShowAllEvents(DateTime.Now, DateTime.Now.AddDays(1));

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

        }
Example #5
0
 public async Task UpdateEventTest_ShouldReturn_BadRequestStatusCode_and_NotNullContent()
 {
     //arrange
     var controller = new EventController(new EventRepository());
     controller.Request = new HttpRequestMessage();
     controller.Request.SetConfiguration(new HttpConfiguration());
     
     
     //act
     controller.ModelState.AddModelError("","");
     var response = await controller.UpdateEvent(GetDemoEvent());   
  
     //assert
     Assert.IsNotNull(response);            
     Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
     Assert.IsNotNull(response.Content);
 }
        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);
        }
Example #7
0
        public async Task UpdateEventTest_ShouldReturnSameProduct_and_OkStatusCode()
        {
            //arrange
            var context = new TestAppContext();
            context.Events.Add(GetDemoEvent());
            var repository = new EventRepository(context);            
            var controller = new EventController(repository);
            controller.Request = new HttpRequestMessage();
            controller.Request.SetConfiguration(new HttpConfiguration());
            var item = GetDemoEvent();

            //act
            var response = await controller.UpdateEvent(item);

            //assert
            Event resultEvent;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.IsTrue(response.TryGetContentValue<Event>(out resultEvent));
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual(item.Id, resultEvent.Id);
        }