public async void ShouldGetIndexPage()
        {
            var mock = new Mock<IFundManagerModelRepository>();
            var fundManagerModels = new FundManagerModel[0].AsEnumerable();
            mock.Setup(m => m.GetAll()).Returns(Task.FromResult(fundManagerModels));
            var controller = new FundManagerController(mock.Object);

            var result = await controller.Index();

            Assert.That(result, Is.TypeOf<ViewResult>());
            mock.Verify();
            Assert.That(((ViewResult)result).Model, Is.EqualTo(fundManagerModels));
        }
        public async void ShouldGetDetailsPage()
        {
            var guid = Guid.NewGuid();
            var mock = new Mock<IFundManagerModelRepository>();
            var fundManagerModel = new FundManagerModel();
            mock.Setup(m => m.Get(guid)).Returns(Task.FromResult(fundManagerModel));
            var controller = new FundManagerController(mock.Object);

            var result = await controller.Details(guid);

            Assert.That(result, Is.TypeOf<ViewResult>());
            mock.Verify();
            Assert.That(((ViewResult)result).Model, Is.EqualTo(fundManagerModel));
        }
        public async Task<ActionResult> Add(FundManagerModel model)
        {
            if (!ModelState.IsValid)
                return View();

            try
            {
                var response = await _repository.Create(model);

                if (response != Guid.Empty)
                {
                    ViewBag.SuccessMessage = Application.SuccessfullyCreated;    
                    return RedirectToAction("Details/" + response);
                }
                else
                {
                    return RedirectToAction("GenericError", new ErrorModel { ErrorHeader = Application.AddManagerError, ErrorMessage = Application.AddManagerErrorMessage });
                }
            }
            catch (Exception)
            {
                return RedirectToAction("GenericError", new ErrorModel { ErrorHeader = Application.AddManagerError, ErrorMessage = Application.AddManagerErrorMessage });
            }
        }
        public async void ShouldGet()
        {
            var mockServiceClient = new Mock<IHttpClientWrapper>();
            var mockToFundManagerModelMapper = new Mock<IMapper<FundManager, FundManagerModel>>();
            var fundManager = new FundManager();
            var guid = Guid.NewGuid();
            mockServiceClient
                .Setup(m => m.GetAndReadFromContentGetAsync<FundManager>("api/FundManager/" + guid))
                .Returns(Task.FromResult(fundManager));
            var fundManagerModel = new FundManagerModel();
            mockToFundManagerModelMapper
                .Setup(m => m.Map(It.IsAny<FundManager>()))
                .Returns(fundManagerModel);
            var repository = new FundManagerModelRepository(
                mockServiceClient.Object,
                mockToFundManagerModelMapper.Object);

            var result = await repository.Get(guid);

            mockToFundManagerModelMapper.Verify();
            mockServiceClient.Verify();
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.EqualTo(fundManagerModel));
        }
        public async Task<ActionResult> Edit(FundManagerModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                    return View();

                await _repository.Edit(model);
                ViewBag.SuccessMessage = Application.SuccessfullyEdited;    
            }
            catch (Exception ex)
            {
                return RedirectToAction("GenericError", new ErrorModel(ex.Message));
            }

            return View();
        }
        /// <summary>
        /// Edits the details of a fund manager using submitted form data
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task Edit(FundManagerModel model)
        {
            var fundManager = _fromModelMapper.Map(model);

            await _client.EditManagerAsync("api/FundManager/" + fundManager.Id, fundManager);
        }
        /// <summary>
        /// Creates a fund manager using submitted form data
        /// </summary>
        /// <param name="model"></param>
        /// <returns>The newly created Fund Manager's ID</returns>
        public async Task<Guid> Create(FundManagerModel model)
        {
            var fundManager = _fromModelMapper.Map(model);

            return await _client.CreateManagerAsync<Guid>("api/FundManager/", fundManager);
        }