protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { TransferDetailService serv = new TransferDetailService(SqlDataSource1, Session["New"].ToString()); } }
public void TransferDetailServiceTest() { string Username = "******"; string PassWord = "******"; var mockAuthenticationManager = new Mock<IAuthenticationManager>(); mockAuthenticationManager.Setup(am => am.SignOut()); mockAuthenticationManager.Setup(am => am.SignIn()); IdentityHelper.AuthenticationManager = mockAuthenticationManager.Object; HttpContext.Current = FakeHttpContext(); AppDomain.CurrentDomain.SetData( "DataDirectory", @"C:\Users\Priyank Kapadia\Documents\Visual Studio 2015\Projects\BnkApplication\BnkApplication\App_Data\"); bool RememberME = true; LoginService servicetest = new LoginService(Username, PassWord, RememberME); servicetest.Login(); // Role Authentication the user who is not admin should not be able to view all details // faking the object as in the UI System.Web.UI.WebControls.SqlDataSource sql = new System.Web.UI.WebControls.SqlDataSource(); sql.SelectCommand = "SELECT * FROM [Table]"; TransferDetailService testserv = new TransferDetailService(sql,Username); Assert.AreEqual("SELECT * FROM [Table] where PAYER_NAME ='" + Username + "'", sql.SelectCommand); }