public void LinkAccountNullAccountEx() { Assert.Throws <System.ArgumentNullException>(() => { ISessionFacade f = this.DumbAss; f.LinkAccount(new Mock <ISession>().Object, null); }); }
public void LinkAccountNullSessionEx() { Assert.Throws <System.ArgumentNullException>(() => { ISessionFacade f = this.DumbAss; f.LinkAccount(null, new Mock <intrinsic.security.model.IAccount>().Object); }); }
public void LinkAccountUpdatesDB() { ISessionFacade f = this.DumbAss; bool inserted = false; bool committed = false; Mock <IRepository <AccountSession> > mAcctSessRepo = new Mock <IRepository <AccountSession> >(); mAcctSessRepo.Setup(g => g.Insert(It.IsAny <AccountSession>())).Callback(() => { inserted = true; }); mAcctSessRepo.Setup(m => m.Get(It.IsAny <Expression <Func <AccountSession, bool> > >(), null, It.IsAny <string>())) .Returns(new List <AccountSession>()); Mock <DxContext> mDimension = new Mock <DxContext>(); mDimension.Setup(g => g.SaveChanges()).Callback(() => { committed = true; }); ((SessionFacade)f).Dimension = mDimension.Object; ((SessionFacade)f).AccountSessionRepo = mAcctSessRepo.Object; f.LinkAccount(new Session() { id = 1 }, new intrinsic.security.model.Account() { ID = 1 }); Assert.True(inserted && committed); }
public void LinkAccountAccountAlreadyLinkedEx() { Assert.Throws <System.InvalidOperationException>(() => { ISessionFacade f = this.DumbAss; //we need to override the db behavior to mock a resultset AccountSession mAcctSess = new AccountSession() { accountID = 1 , sessionID = 1 , id = 1 }; Mock <IRepository <AccountSession> > mAccountSessionRepo = new Mock <IRepository <AccountSession> >(); mAccountSessionRepo.Setup(m => m.Get(It.IsAny <Expression <Func <AccountSession, bool> > >(), null, It.IsAny <string>())) .Returns(new List <AccountSession>() { mAcctSess }); ((SessionFacade)f).AccountSessionRepo = mAccountSessionRepo.Object; f.LinkAccount(new Mock <ISession>().Object, new Mock <intrinsic.security.model.IAccount>().Object); }); }