public async Task Delete_given_repository_returns_false_returns_NotFound()
        {
            var repository = new Mock <IEventStockRepository>();

            var controller = new EventStockController(repository.Object);

            var delete = await controller.Delete(42);

            Assert.IsType <NotFoundResult>(delete);
        }
        public async Task Delete_given_id_deletes_eventStock()
        {
            var repository = new Mock <IEventStockRepository>();

            var controller = new EventStockController(repository.Object);

            await controller.Delete(42);

            repository.Verify(s => s.DeleteAsync(42));
        }
        public async Task Delete_given_valid_returns_NoContent()
        {
            var repository = new Mock <IEventStockRepository>();

            repository.Setup(s => s.DeleteAsync(42)).ReturnsAsync(true);
            var controller = new EventStockController(repository.Object);

            var delete = await controller.Delete(42);

            Assert.IsType <NoContentResult>(delete);
        }
        public async Task Get_given_non_existing_returns_NotFound()
        {
            var repo       = new Mock <IEventStockRepository>();
            var controller = new EventStockController(repo.Object);

            var get = await controller.Get(42);

            var res = get.Result;

            Assert.IsType <NotFoundResult>(res);
        }
        public async Task Post_given_valid_dto_returns_CreatedAtAction()
        {
            var dto  = new EventStockDTO();
            var repo = new Mock <IEventStockRepository>();

            repo.Setup(s => s.CreateAsync(It.IsAny <EventStockDTO>())).ReturnsAsync(1);
            var controller = new EventStockController(repo.Object);

            var post = await controller.Post(dto);

            Assert.IsType <CreatedAtActionResult>(post.Result);
        }
        public async Task Get_existing_id_returns_dto()
        {
            var dto  = new EventStockDTO();
            var repo = new Mock <IEventStockRepository>();

            repo.Setup(s => s.FindAsync(42)).ReturnsAsync(dto);
            var controller = new EventStockController(repo.Object);

            var get = await controller.Get(42);

            Assert.Equal(dto, get.Value);
        }
        public async Task Put_given_repository_returns_false_returns_NotFound()
        {
            var repository = new Mock <IEventStockRepository>();

            var controller = new EventStockController(repository.Object);

            var dto = new EventStockDTO();

            var put = await controller.Put(42, dto);

            Assert.IsType <NotFoundResult>(put);
        }
        public async Task Put_returns_NoContent()
        {
            var dto        = new EventStockDTO();
            var repository = new Mock <IEventStockRepository>();

            repository.Setup(s => s.UpdateAsync(dto)).ReturnsAsync(true);
            var controller = new EventStockController(repository.Object);

            var put = await controller.Put(42, dto);

            Assert.IsType <NoContentResult>(put);
        }
        public async Task Put_given_dto_updates_eventStock()
        {
            var repository = new Mock <IEventStockRepository>();

            var controller = new EventStockController(repository.Object);

            var dto = new EventStockDTO();

            await controller.Put(42, dto);

            repository.Verify(s => s.UpdateAsync(dto));
        }
        public async Task GetEventStocks_returns_all()
        {
            IList <EventStockDTO> dtos = new List <EventStockDTO>()
            {
                new EventStockDTO()
            };
            var repo = new Mock <IEventStockRepository>();

            repo.Setup(s => s.ReadAsync()).ReturnsAsync(dtos);
            var controller = new EventStockController(repo.Object);

            var get = await controller.Get();
        }