public async Task GetReturnsNotFoundAfterAllRetryAttemptsFailTest()
        {
            var account = Model.Create <Account>();
            var user    = ClaimsIdentityFactory.BuildPrincipal(account);

            var profileQuery   = Substitute.For <IProfileQuery>();
            var profileCommand = Substitute.For <IProfileCommand>();
            var accountCommand = Substitute.For <IAccountCommand>();
            var httpContext    = Substitute.For <HttpContext>();

            httpContext.User = user;

            var routerData        = new RouteData();
            var actionDescriptor  = new ControllerActionDescriptor();
            var actionContext     = new ActionContext(httpContext, routerData, actionDescriptor);
            var controllerContext = new ControllerContext(actionContext);

            using (var tokenSource = new CancellationTokenSource())
            {
                using (var target = new AccountProfileController(profileQuery, profileCommand, accountCommand))
                {
                    target.ControllerContext = controllerContext;

                    var actual = await target.Get(tokenSource.Token).ConfigureAwait(false);

                    actual.Should().BeOfType <ErrorMessageResult>().Which.StatusCode.Should().Be((int)HttpStatusCode.NotFound);

                    await profileQuery.Received(4).GetProfile(account.Id, tokenSource.Token).ConfigureAwait(false);
                }
            }
        }
        public async Task GetAttemptsToGetProfileMultipleTimesTest()
        {
            var account = Model.Create <Account>();
            var profile = Model.Create <Profile>();
            var user    = ClaimsIdentityFactory.BuildPrincipal(account);

            var profileQuery   = Substitute.For <IProfileQuery>();
            var profileCommand = Substitute.For <IProfileCommand>();
            var accountCommand = Substitute.For <IAccountCommand>();
            var httpContext    = Substitute.For <HttpContext>();

            httpContext.User = user;

            var routerData        = new RouteData();
            var actionDescriptor  = new ControllerActionDescriptor();
            var actionContext     = new ActionContext(httpContext, routerData, actionDescriptor);
            var controllerContext = new ControllerContext(actionContext);

            using (var tokenSource = new CancellationTokenSource())
            {
                profileQuery.GetProfile(account.Id, tokenSource.Token).Returns(null, null, null, profile);

                using (var target = new AccountProfileController(profileQuery, profileCommand, accountCommand))
                {
                    target.ControllerContext = controllerContext;

                    var actual = await target.Get(tokenSource.Token).ConfigureAwait(false);

                    actual.Should().BeOfType <OkObjectResult>();

                    var result = actual.As <OkObjectResult>();

                    result.Value.Should().BeEquivalentTo(profile);

                    await profileQuery.Received(4).GetProfile(account.Id, tokenSource.Token).ConfigureAwait(false);
                }
            }
        }