public void GetAccountNotFoundTest() { var connection = EntityConnectionFactory.CreateTransient("name=Entities"); using (var context = new Entities(connection)) { CardReaderService cardReaderService = new CardReaderService(context); context.Cards.Add(new Card { Id = 1, UserId = 1, CardNumber = "12345", Pin = 1234, Status = (int)CardStatus.Active }); context.Users.Add(new User { Id = 1, UserName = "******", LoginAttempt = 0, IsLoggedIn = false }); context.AccountTypes.Add(new AccountType { Id = 1, Name = AccounType.Current.ToString() }); context.Accounts.Add(new Account { Id = 1, AccountNumber = "1234", CardId = 1, AccountTypeId = 1, AmountAvailable = 500 }); context.SaveChanges(); var account = cardReaderService.GetAccount(100); Assert.AreEqual(Message.AccountNotFound, account.UserMessage); } }
public ActionResult Index() { if (Session["LogIn"] == null) { return(RedirectToAction("Login", "Account")); } CardReaderService cardReaderService = new CardReaderService(); var cardViewModel = (CardViewModel)Session["LogIn"]; //Gets the account information var accountViewModel = cardReaderService.GetAccount(cardViewModel.Id); Session["Account"] = accountViewModel; return(View(accountViewModel)); }