public void Test_Failed_UsernameTaken()
        {
            //Arrange
            var request = new AddUserRequest() { EmailAddress = "*****@*****.**", UserName = "******"};
            var expectedResponse = new BaseResponse() { Success = false, FailureDescription = AddUserRequestHandler.UsernameTaken };

            var existingUser = new User(request.UserName, "new email address");
            Session.Save(existingUser);

            CommitTransactionAndOpenNew();

            //Act
            var sut = new AddUserRequestHandler(() => Session);
            BaseResponse actualResponseBase = sut.HandleRequest(request);

            //Assert
            actualResponseBase.ShouldEqual(expectedResponse);
        }
Esempio n. 2
0
        private BaseResponse Execute(AddUserRequest request)
        {
            BaseResponse response = null;

            try
            {
                unitOfWork.DoInTransaction(() =>
                {
                    response = requestHandler.HandleRequest(request);
                });
            }
            catch (Exception ex)
            {
                //Log.Error("Exception thrown while executing webservice request", ex);
                //response = ResponseStatusTranslator.CreateErrorResponse(HttpStatusCode.InternalServerError.ToString(),
                //    "There was an internal server error. Please try again later.");
            }

            return response;
        }
        public void Test_Success()
        {
            //Arrange
            var request = new AddUserRequest() {EmailAddress = "*****@*****.**", UserName = "******"};
            var expectedResponse = new BaseResponse() {Success = true};

            //Act
            var sut = new AddUserRequestHandler(() => Session);
            BaseResponse actualResponseBase = sut.HandleRequest(request);

            //Assert
            actualResponseBase.ShouldEqual(expectedResponse);

            var expectedUser = new User(request.UserName, request.EmailAddress);

            CommitTransactionAndOpenNew();

            User userInDb = Session
                .QueryOver<User>()
                .SingleOrDefault()
                ;

            userInDb.ShouldEqual(expectedUser);
        }
Esempio n. 4
0
        public static bool ShouldEqual(this AddUserRequest actual, AddUserRequest expected)
        {
            Assert.That(actual.UserName, Is.EqualTo(expected.UserName));
            Assert.That(actual.EmailAddress, Is.EqualTo(expected.EmailAddress));

            return true;
        }
Esempio n. 5
0
 public virtual bool CheckIfUserExists(AddUserRequest request)
 {
     throw new NotImplementedException();
 }