public async Task GetAll_ReturnsNotFound_OnNoItemsExist()
        {
            _fakeSubscriberCollection = null;
            _mockSubscriberService.Setup(a => a.GetAll()).Returns(Task.FromResult(_fakeSubscriberCollection.AsEnumerable()));

            var controller = new SubscriberController(_mockSubscriberService.Object, _logger.Object);
            var result     = await controller.Get();

            Assert.IsInstanceOf <NotFoundResult>(result.Result);
        }
        public async Task GetAll_ReturnsBadRequest_OnUnhandledException()
        {
            _fakeSubscriberCollection = null;
            _mockSubscriberService.Setup(a => a.GetAll()).Throws(new Exception("An error occurred"));

            var controller   = new SubscriberController(_mockSubscriberService.Object, _logger.Object);
            var actionResult = await controller.Get();

            var badRequestResult = actionResult.Result as BadRequestObjectResult;

            Assert.IsInstanceOf(typeof(BadRequestObjectResult), badRequestResult);
            Assert.IsNotNull(badRequestResult);
            Assert.IsNotNull(badRequestResult.Value);
            Assert.AreEqual((int)HttpStatusCode.BadRequest, badRequestResult.StatusCode);
        }
        public async Task GetAll_ReturnsOkResult()
        {
            _mockSubscriberService.Setup(a => a.GetAll()).Returns(Task.FromResult(_fakeSubscriberCollection.AsEnumerable()));

            var expectedValue = 1;
            var controller    = new SubscriberController(_mockSubscriberService.Object, _logger.Object);
            var result        = await controller.Get();

            var okResult = result.Result as OkObjectResult;

            Assert.IsInstanceOf <OkObjectResult>(result.Result);
            Assert.IsNotNull(okResult.Value);
            Assert.IsInstanceOf <IEnumerable <Subscriber> >(okResult.Value);
            var returnValue = okResult.Value as IEnumerable <Subscriber>;

            Assert.AreEqual(_fakeSubscriberCollection.Count, returnValue.Count());
            Assert.AreEqual(expectedValue, returnValue.FirstOrDefault().Id);
        }