Example #1
0
        public void AccountService_Register_CanNotRegister_Failure()
        {
            // Arrange
            IMember        existedMember = Substitute.For <IMember>();
            ErrorCodeType  expectedError = ErrorCodeType.MemberAlreadyExists;
            UserToRegister user          = GetUserToRegister();

            _memberService.GetByEmail(user.Email).Returns(existedMember);

            // Act
            Result registrationResult = _accountService.Register(user);

            // Assert
            Assert.IsNotNull(registrationResult, Common.ShowResponseTypeMismatchMessage(typeof(Result)));
            Assert.IsTrue(registrationResult.IsFailure, Common.ShowNotSatisfiedExpectationMessage(true, "registrationResult.IsFailure"));
            Assert.AreEqual(expectedError, registrationResult.ErrorCode, Common.ShowNotSatisfiedExpectationMessage(expectedError, registrationResult.ErrorCode));
            _userRegistration.ReceivedWithAnyArgs(0).Register(null);
        }