public void Initialize() { vm = new VendingMachine(); session = new TransactionSession(); session.Deposit(2.00M); vm.Initialize(); }
public void FinishTransaction() { TransactionSession session = new TransactionSession(); session.Deposit(5.0M); Assert.AreEqual("Quarters: 20\nDimes: 0\nNickles: 0\nTotal change: $5.00", session.FinishTransaction()); }
public Message DoLogin(SettingsUsers pUser, out AppSession appSession) { appSession = new AppSession(); try { if (Connection.State != ConnectionState.Open) { Connection.Open(); } var transaction = new TransactionSession(); SecurityServicesSoapClient client = new SecurityServicesSoapClient(SecurityServicesSoapClient.EndpointConfiguration.SecurityServicesSoap); var result = client.AuthenticateUserAsync(pUser.user_id, pUser.Password, "P003", "", ""); var response = result.Result.Body.AuthenticateUserResult; if (response.StatusCode == "40999") { var user = userRepository.GetLoginInfo(pUser.user_id, new Encription().Encrypt(pUser.Password), pUser.StationIp, pUser.SessionId); if (user != null) { if (user.Active == "Y") { var screenAccessPermissions = userRepository.GetRoleWisePermission(user.roleid, "", user.user_id); var screens = userRepository.GetScreens(user.user_id); appSession = new AppSession { User = user, ScreenAccessPermissions = screenAccessPermissions, Screens = screens, TransactionSession = transaction }; MessageHelper.Success(Message, "Login Successfull."); } else { MessageHelper.Error(Message, "Your are not yet activated. Please contact administrator."); } } else { MessageHelper.Error(Message, "User name and password doesn't match. Please try with another."); } } else { MessageHelper.Error(Message, "User name and password doesn't match. Please try with another."); } } catch (Exception ex) { Logging.WriteToErrLog(appSession.User.StationIp, appSession.User.user_id, "ISettingsUsersService-DoLogin", ex.Message + "|" + ex.StackTrace.TrimStart()); MessageHelper.Error(Message, "System Error!!"); } finally { Connection.Close(); } return(Message); }
public void Deduct() { TransactionSession session = new TransactionSession(); session.Deposit(5.0M); session.Deduct(1.0M); Assert.AreEqual(4.0M, session.Balance); }
public void Deposit() { TransactionSession session = new TransactionSession(); Assert.AreEqual(false, session.Deposit(4.0M)); Assert.AreEqual(true, session.Deposit(5.0M)); Assert.AreEqual(5.0M, session.Balance); }
public static async Task <TransactionSession> GetSessionAsync(Trasnaction trasnaction) { string requestUrl = Configuration.STORE_URL + "/gwprocess/v3/api.php"; using (HttpClient client = new HttpClient()) { Dictionary <string, string> parameters = Helper.GetSessionRequestParameter(trasnaction); HttpContent content = new FormUrlEncodedContent(parameters); HttpResponseMessage response = await client.PostAsync(requestUrl, content); response.EnsureSuccessStatusCode(); string responseString = await response.Content.ReadAsStringAsync(); TransactionSession session = JsonConvert.DeserializeObject <TransactionSession>(responseString); return(session); } }
public void TransactionSession() { TransactionSession session = new TransactionSession(); Assert.AreEqual(0.0M, session.Balance); }
/// <summary> /// Creates a session. /// </summary> /// <param name="runSettings">The run settings.</param> /// <returns>The session.</returns> private async Task <ITransactionSession <TStepId, TData> > CreateSession(IRunSettings <TStepId, TData> runSettings) #endif { TransactionSession <TStepId, TData> session = new TransactionSession <TStepId, TData> { RunSettings = runSettings, TransactionContext = this.context }; session.StepEnumeratorInstance = new StepEnumerator <TStepId, TData>(session) { Data = runSettings.Data }; switch (runSettings.Mode) { case RunMode.Run: break; case RunMode.RecoverAndUndoAndRun: case RunMode.RecoverAndContinue: ITransactionData <TData> recoveredData = null; try { #if NET35 || NOASYNC recoveredData = this.context.SessionStorage.RecoverTransaction(); #else recoveredData = await this.context.SessionStorage.RecoverTransaction(); #endif } catch (Exception e) { this.context.Logger.ErrorFormat(e, "An error occurred during recovering the transaction '{0}'.", this.context.Info.Name); #if NET35 || NOASYNC SessionEndPreparationOperation.PrepareEndSession(new SessionEndContext <TStepId, TData>() #else await SessionEndPreparationOperation.PrepareEndSession(new SessionEndContext <TStepId, TData>() #endif { Session = session, RunPostActions = false, Result = ResultType.Failed } .AddError(e)); return(session); } if (recoveredData == null) { this.context.Logger.InfoFormat("Transaction '{0}': no session to recover.", this.context.Info.Name); #if NET35 || NOASYNC SessionEndPreparationOperation.PrepareEndSession(new SessionEndContext <TStepId, TData>() #else await SessionEndPreparationOperation.PrepareEndSession(new SessionEndContext <TStepId, TData>() #endif { Session = session, Result = ResultType.NoTransactionToRecover, RunPostActions = false }); return(session); } else { session.Recover(recoveredData); } break; default: throw new ArgumentException(string.Format("Transaction '{0}': unknown run mode '{1}'.", this.context.Info.Name, runSettings.Mode)); } session.StepEnumeratorInstance.FillStep(); return(session); }
public AppSession() { Screens = new List <Screen>(); TransactionSession = new TransactionSession(); }
public Form_ViewBill(TransactionSession transactionSession) { m_TransactionSession = transactionSession; InitializeComponent(); m_Controller = new FormController_ViewBill(transactionSession, this); }