Beispiel #1
0
 public IActionResult Get()
 {
     try
     {
         var email = User.FindFirst(ClaimTypes.Email).Value;
         return(Ok(_todoItemService.Get(email)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(StatusCode(500));
     }
 }
Beispiel #2
0
        public void Get_ById_ReturnsArgumentException()
        {
            // Arrange
            var repository = new TodoItemRepository(_dbContextFixture.TodoSampleDbContext);
            var unitOfWork = new Mock <IUnitOfWork>();

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new TodoItemProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            var todoItemService = new TodoItemService(repository, unitOfWork.Object, mapper);

            // Act Assert
            Assert.Throws <ArgumentException>(() => todoItemService.Get(2));
        }
Beispiel #3
0
        public void Get_ById_ReturnsTodoItem()
        {
            // Arrange
            var repository = new TodoItemRepository(_dbContextFixture.TodoSampleDbContext);
            var unitOfWork = new Mock <IUnitOfWork>();

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new TodoItemProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();


            var todoItemService = new TodoItemService(repository, unitOfWork.Object, mapper);

            // Act
            var result = todoItemService.Get(1);

            // Assert
            Assert.Equal(1, result.Id);
            Assert.Equal("First item", result.Name);
            Assert.False(result.IsCompleted);
        }
Beispiel #4
0
 public ActionResult <List <TodoItem> > Get()
 {
     return(_todoItemService.Get());
 }
Beispiel #5
0
 // GET: api/TodoItem/5
 public IHttpActionResult Get(int id)
 {
     return(Ok(_service.Get(id)));
 }
Beispiel #6
0
        public IActionResult Get()
        {
            var email = User.FindFirst(ClaimTypes.Email).Value;

            return(Ok(_todoItemService.Get(email)));
        }