public void GenerateInvitationCodeTest() { //Arrange var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(un => un.InvitationCodeRepository.Get(null, null, "")); mockUnitOfWork.Setup(un => un.InvitationCodeRepository.Insert(It.IsAny <InvitationCode>())); mockUnitOfWork.Setup(un => un.Save()); IInvitationCodeLogic invitationCodeLogic = new InvitationCodeLogic(mockUnitOfWork.Object); var code = invitationCodeLogic.GenerateCode(new User() { IsAdmin = true }); Assert.Equal(code.Code.Length, 8); mockUnitOfWork.VerifyAll(); }
public void GenerateInvitationCodeThrowExceptionTest() { //Arrange var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(un => un.InvitationCodeRepository.Get(null, null, "")); IInvitationCodeLogic invitationCodeLogic = new InvitationCodeLogic(mockUnitOfWork.Object); try { var code = invitationCodeLogic.GenerateCode(new User() { IsAdmin = false }); Assert.True(false); } catch (Exception e) { //for debug purposes var errorMessage = e.Message; Assert.True(true); } }