コード例 #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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
 public EventController()
 {
     repository = new EventRepository();
 }