Example #1
0
        public async Task WhenGettingUsernameAvailability_ItShouldYieldNotFoundIfUsernameUnavailable()
        {
            var query = new IsUsernameAvailableQuery(Username);

            this.isUsernameAvailable.Setup(v => v.HandleAsync(query)).Returns(Task.FromResult(false));

            var result = await this.controller.GetUsernameAvailabilityAsync(UsernameValue);

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Example #2
0
        public async Task <IHttpActionResult> GetUsernameAvailabilityAsync(string username)
        {
            username.AssertUrlParameterProvided("username");

            ValidUsername usernameObject;

            if (!ValidUsername.TryParse(username, out usernameObject))
            {
                return(this.NotFound());
            }

            var query             = new IsUsernameAvailableQuery(usernameObject);
            var usernameAvailable = await this.isUsernameAvailable.HandleAsync(query);

            if (usernameAvailable)
            {
                return(this.Ok());
            }

            return(this.NotFound());
        }