public void ThrowsFileNotFoundException()
        {
            string fileName = Path.GetTempFileName();

            File.Delete(fileName);
            BSDataObject doesntMatter = BSRepository.DataObjectFromFile(fileName);
        }
            public override void Start()
            {
                CheckIfInputsAreProvided();
                BSDataObject objToSave;

                Inputs.TryPop(out objToSave);
                BSRepository.SaveDataObjectToFile(objToSave, fileToSavePath);
            }
コード例 #3
0
 public override void Start()
 {
     try
     {
         Output = BSRepository.DataObjectFromFile(sourceFilePath);
     }
     catch (FormatException exc)
     {
         throw new IncorrectInputFileException("Файл, заданий у якості джерела даних для елемента 'Вхідні дані' не відповідає потрібному формату.");
     }
 }
        public void General()
        {
            string    fileName      = Path.GetTempFileName();
            Random    rnd           = new Random();
            const int numbersAmount = 100;

            double[] expected = new double[numbersAmount];
            using (StreamWriter sw = new StreamWriter(fileName))
            {
                for (int i = 0; i < expected.Count(); ++i)
                {
                    expected[i] = rnd.Next(int.MinValue, int.MaxValue);
                    sw.WriteLine(expected[i]);
                }
            }
            BSDataObject result = BSRepository.DataObjectFromFile(fileName);

            File.Delete(fileName);
            CollectionAssert.AreEqual(expected, result.DataArray);
        }
コード例 #5
0
        public ActionResult Index(IFormCollection collection)
        {
            if (collection != null)
            {
                IBSRepository rep = new BSRepository();

                UserLogin login = rep.GetUserLoginInfo(collection["LoginName"].ToString());

                if (login != null && login.Password == collection["Password"].ToString())
                {
                    return(RedirectToAction("Index", "BankTransaction", new { loginName = login.LoginName }));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
コード例 #6
0
        public ActionResult CreateUserLogin(IFormCollection collection)
        {
            if (collection != null)
            {
                IBSRepository rep = new BSRepository();

                BankAccount acct = new BankAccount()
                {
                    LoginName     = collection["LoginName"].ToString(),
                    Password      = collection["Password"].ToString(),
                    AccountNumber = collection["AccountNumber"].ToString(),
                    Balance       = Convert.ToDouble(collection["Balance"]),
                    CreatedDate   = Convert.ToDateTime(collection["CreatedDate"])
                };

                //Check if LoginName exists in database
                UserLogin login = rep.GetUserLoginInfo(acct.LoginName);

                if (login != null)
                {
                    ViewBag.Message = "Login Name already exists in database. Please modify them.";

                    return(View(acct));
                }
                else
                {
                    rep.InsertNewBankAccount(acct, "Open New Account");

                    return(RedirectToAction("Index", "UserLogin", new { loginName = acct.LoginName }));
                }
            }
            else
            {
                return(View());
            }
        }
コード例 #7
0
ファイル: Comment.aspx.cs プロジェクト: AyferDURU/BlogSys
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                AddEdit = 0;
            }
            else
            {
                AddEdit = Convert.ToInt32(Request.QueryString["ID"]);
            }

            Repo = new BSRepository();
            usr = Session["User"] as BSUser;

            if (!Page.IsPostBack)
            {
                GetCommentPageDetail();
                if (AddEdit != 0)
                {
                    btnProcess.Text = "Düzenle";
                    BSComment _comm = Repo.GetAll<BSComment>().Where(x => x.ID == AddEdit).FirstOrDefault();
                    txtCName.Text = _comm.CommenterName;
                    txtDate.Text = string.Format("{0:dd/MM/yyyy hh:mm}", _comm.Date);
                    ddlPost.SelectedValue = _comm.Post.ID.ToString();
                    tbIcerik.InnerText = _comm.Content;
                }
            }
        }
 public void ThrowsArgumentNullExceptionForNullArgument()
 {
     BSDataObject doesntMatter = BSRepository.DataObjectFromFile(null);
 }