Ejemplo n.º 1
0
        public void ReverseWord_When_StringEmpty_Returns_Empty()
        {
            string input = string.Empty;

            //Act
            string output = MyMethods.ReverseWord(input);

            //Assert
            Assert.AreEqual("empty", output);
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     Console.WriteLine("Добрый день! Чтобы вывести индекс массы тела, вам нужно будет по очереди ввести свою массу и свой рост.");
     Console.WriteLine("Укажите свой рост в метрах, пожалуйста.");
     height = MyMethods.NumsCheck(Console.ReadLine());
     Console.WriteLine("Укажите свой вес в кг, пожалуйста.");
     mass        = MyMethods.NumsCheck(Console.ReadLine());
     BodyMassIdx = mass / (height * height);
     Console.WriteLine("Ваш индекс равен " + $"{BodyMassIdx:F}");
     Console.ReadKey();
 }
Ejemplo n.º 3
0
        public void testFibbonaci()
        {
            //Arrange - setup
            int input = 5;

            //Act - work need to be done
            int output = MyMethods.Fib(input);

            //Assert
            Assert.AreEqual(5, output);
        }
Ejemplo n.º 4
0
        public void GetProductsByNameTest()
        {
            List <MyProduct> products = MyMethods.GetProductsByName("");

            Assert.AreEqual(5, products.Count);
            Assert.AreEqual("Hammer", products[0].Name);
            Assert.AreEqual("T-shirt", products[1].Name);
            Assert.AreEqual("Screwdriver", products[2].Name);
            Assert.AreEqual("Shoes", products[3].Name);
            Assert.AreEqual("Trousers", products[4].Name);
        }
Ejemplo n.º 5
0
        public void TestFactorialLoop_Input5_Returns5()
        {
            //arrange
            int input    = 5;
            int expected = 120;

            //act
            int output = MyMethods.FactorialLoop(input);

            //assert
            Assert.AreEqual(expected, output);
        }
Ejemplo n.º 6
0
        public void TestFactorialWhenInput1_Returns1()
        {
            //arrange
            int input    = 1;
            int expected = 1;

            //act
            int output = MyMethods.Factorial(input);

            //assert
            Assert.AreEqual(expected, output);
        }
Ejemplo n.º 7
0
        public void MyMethod_When_String_ReturnReverse()
        {
            //Arrange
            string input    = "Good";
            string expected = "doog";

            //Act
            string actual = MyMethods.ReverseWord(input);

            //Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
 static void Main(string[] args)
 {
     Console.WriteLine("Введите своё имя");
     Name = Console.ReadLine();
     Console.WriteLine("Введите свою фамилию");
     LastName = Console.ReadLine();
     Console.WriteLine("Введите название вашего города проживания");
     CityName = Console.ReadLine();
     Console.Clear();
     text = ("Фамилия: " + LastName + " " + "Имя: " + Name + " " + "Город проживания: " + CityName);
     MyMethods.SetTextPosition(text, 30, 15);
     Console.ReadKey();
 }
Ejemplo n.º 9
0
        public void pennyShading()
        {
            //Arrange - setup
            double input = 1.000134;

            double expected = 34;
            //Act - work need to be done

            double output = MyMethods.PennyShade(input);

            //Assert
            Assert.AreEqual(expected, output);
        }
Ejemplo n.º 10
0
 static void GetData()
 {
     Console.WriteLine("Укажите ваше имя, пожалуйста.");
     Name = Console.ReadLine();
     Console.WriteLine("Укажате вашу фамилию, пожалуйста.");
     LastName = Console.ReadLine();
     Console.WriteLine("Укажите ваше отчество, пожалуйста.");
     MiddleName = Console.ReadLine();
     Console.WriteLine("Укажите ваш возраст, пожалуйста.");
     age = MyMethods.NumsCheck(Console.ReadLine());
     Console.WriteLine("Укажите ваш вес, пожалуйста.");
     mass = MyMethods.NumsCheck(Console.ReadLine());
 }
Ejemplo n.º 11
0
        public static void Main()
        {
            MyMethods a = new MyMethods(Hello);
            MyMethods b = new MyMethods(Goodbye);

            MyMethods add, sub;

            add = a + b;

            sub = add - b;
            sub("World!");

            Console.Read();
        }
Ejemplo n.º 12
0
        public static void Main()
        {
            MyMethods a = new MyMethods(Hello);
            MyMethods b = new MyMethods(Goodbye);

            MyMethods add, sub;

            add = a + b;

            sub = add - b;
            sub("World!");

            Console.Read();
        }
Ejemplo n.º 13
0
 static void Main(string[] args)
 {
     Console.WriteLine("Добрый день! Сегодня мы попробуем посчитать расстояние между двумя координатами. Для этого вам потребуется последовательно ввести значение x,y для обоих координат");
     Console.WriteLine("Введите значение координаты x1");
     x1 = MyMethods.NumsCheck(Console.ReadLine());
     Console.WriteLine("Введите значение координаты y1");
     y1 = MyMethods.NumsCheck(Console.ReadLine());
     Console.WriteLine("Введите значение координаты x2");
     x2 = MyMethods.NumsCheck(Console.ReadLine());
     Console.WriteLine("Введите значение координаты y2");
     y2      = MyMethods.NumsCheck(Console.ReadLine());
     dlength = GetDotsLegth(x1, y1, x2, y2);
     Console.WriteLine("Расстояние между координатами равно " + $"{dlength:F}");
     Console.ReadKey();
 }
Ejemplo n.º 14
0
    private void InstantiateItems(float offset)
    {
        var position = transform.position;

        if (_gameController.IsJumpActivated || _gameController.IsDoubleScoreActivated)
        {
            Instantiate(bonuses.Find(x => x.GetComponent <Coins>()),
                        new Vector3(position.x, position.y + offset, 0), transform.rotation);
        }
        else
        {
            Instantiate(MyMethods <Bonuses> .GetRandomItem(bonuses, _player.transform),
                        new Vector3(position.x, position.y + offset, 0), transform.rotation);
        }
    }
        static void Main(string[] args)
        {
            MyMethods myMethod = new MyMethods();

            string something   = "something";
            string nothingHere = null;

            myMethod.DoSomeStuff(something, nothingHere);

            //I need to call MyVariable here
            //Or be able to access it's values assigned in the MyMethod Class.

            Console.Write(myMethod.MyVarClass.MyVariable);
            Console.ReadKey();
        }
Ejemplo n.º 16
0
        public void testRecFib_When5_Returns120()
        {
            //arrange - setup
            int input    = 5;
            int expected = 5;

            //act - work need to be done


            int output = MyMethods.FibRecurssion(input);


            //assert
            Assert.AreEqual(expected, output);
        }
Ejemplo n.º 17
0
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            if (TXTxbmc.Text == "")
            {
                Response.Write("<script>alert('系部名称不能为空!')</script>");
                return;
            }
            MyMethods mm    = new MyMethods();
            string    strid = mm.DateId();
            string    sql   = "insert into 系部 values ('" + strid + "','" + TXTxbmc.Text + "')";

            new MyData(Application["connstr"].ToString()).eInsertUpdateDelete(sql);
            TXTxbmc.Text = "";
            mm.DG_bind(Dg_xb, "select * from 系部", "", "", Application["connstr"].ToString());
            Response.Write("<script>alert('添加成功!')</script>");
        }
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            if (TXTzjmc.Text == "")
            {
                Response.Write("<script>alert('章节名称不能为空!')</script>");
                return;
            }
            string strid = new MyMethods().DateId();
            string sql   = "insert into 章节 values ('" + strid + "','" + TXTzjmc.Text + "','" + TXTsmxx.Text + "')";
            MyData md    = new MyData(Application["connstr"].ToString());

            md.eInsertUpdateDelete(sql);
            Clear_Input();
            DG_bind();

            Response.Write("<script>alert('添加成功!')</script>");
        }
Ejemplo n.º 19
0
        private void PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
        {
            DataGrid curr_dg = (DataGrid)source;

            curr_dg.CurrentPageIndex = e.NewPageIndex;
            MyMethods mm = new MyMethods();

            if (curr_dg.ID == "Dg_xb")
            {
                mm.DG_bind(Dg_xb, "select * from 系部", "", "", Application["connstr"].ToString());
            }
            else
            {
                string strsql = "select * from 班级 where 系部编号='" + Convert.ToString(Dg_xb.DataKeys[Dg_xb.SelectedIndex]) + "'";
                mm.DG_bind(Dg_bj, strsql, "", "", Application["connstr"].ToString());
            }
        }
Ejemplo n.º 20
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     // 在此处放置用户代码以初始化页面
     if (!IsPostBack)
     {
         MyMethods mm = new MyMethods();
         if (Session["Teacher_ID"] == null)
         {
             mm.AlertAndRedirect("您尚未登录!", "/test/login.aspx");
             return;
         }
         lbl_Title.Text = "系部班级管理";
         BtnSave.Attributes.Add("OnClick", "JavaScript:return confirm('您真要保存吗?')");
         BtnSaveBj.Attributes.Add("OnClick", "JavaScript:return confirm('您真要保存吗?')");
         mm.DG_bind(Dg_xb, "select * from 系部", "", "", Application["connstr"].ToString());
     }
 }
Ejemplo n.º 21
0
        private void BtnSaveBj_Click(object sender, System.EventArgs e)
        {
            if (TXTbjmc.Text == "")
            {
                Response.Write("<script>alert('班级名称不能为空!')</script>");
                return;
            }
            MyMethods mm    = new MyMethods();
            string    strid = mm.DateId();
            string    sql   = "insert into 班级(id,班级名称,系部编号) values ('" + strid + "','" + TXTbjmc.Text + "','" + Dg_xb.DataKeys[Dg_xb.SelectedIndex] + "')";

            new MyData(Application["connstr"].ToString()).eInsertUpdateDelete(sql);
            TXTbjmc.Text = "";
            string strsql = "select * from 班级 where 系部编号='" + Convert.ToString(Dg_xb.DataKeys[Dg_xb.SelectedIndex]) + "'";

            mm.DG_bind(Dg_bj, strsql, "", "", Application["connstr"].ToString());
            Response.Write("<script>alert('添加成功!')</script>");
        }
 private void Page_Load(object sender, System.EventArgs e)
 {
     // 在此处放置用户代码以初始化页面
     if (!IsPostBack)
     {
         MyMethods mm = new MyMethods();
         if (Session["Teacher_ID"] == null)
         {                 //验证教师是否登录
             mm.AlertAndRedirect("您尚未登录!", "/test/login.aspx");
             return;
         }
         if (Session["tixing"] == null)              //设置默认显示的题型
         {
             Session["tixing"] = "单选题";
         }
         if (Session["curr_page"] == null)
         {
             Session["curr_page"] = "0";                  //记录当前DataGrid的当前页,使的从题库录入页面中编辑后返回该页时仍然能够回到当前页
         }
         if (Session["sort_field"] == null)
         {
             Session["sort_field"] = "题干";              //设置DataGrid默认排序字段
         }
         if (Session["sort_direction"] == null)
         {
             Session["sort_direction"] = "ASC";                  //设置DataGrid默认排序方向
         }
         if (Session["ddlselectedvalue"] == null)
         {
             Session["ddlselectedvalue"] = "";                  //如果用户使用了检索功能,该Session用于记录用户的检索条件,以便从题库录入页面中编辑后返回该页时仍然能够显示刚才检索结果
         }
         if (Session["ddlselectedtext"] == null)
         {
             Session["ddlselectedtext"] = "";                  //与上面的Session一样记录检索条件的,但是以中文形式显示在页面第二行的ListBox控件中的文字
         }
         lbl_Title.Text          = "题库列表";
         DDLtixing.SelectedValue = Convert.ToString(Session["tixing"]);
         set_datagrid_visible(Convert.ToString(Session["tixing"]));;                                  //该方法设置各DataGrid可见属性,只有参数传入的题型所在的DataGrid才可见
         DataGrid curr_dg = (DataGrid)this.FindControl(find_DG(Convert.ToString(Session["tixing"]))); //获取当前题型所对应的DataGrid,find_DG方法返回当前参数所代表的题型所对应的DataGrid的ID
         curr_dg.CurrentPageIndex = Convert.ToInt16(Session["curr_page"]);                            //将该DataGrid的当前页码设置为Session["curr_page"]中存储的页码
         DG_bind();                                                                                   //调用自定义函数,执行对DataGrid的绑定显示操作
     }
 }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            Uri        url         = new Uri("http://localhost:8080/webservice/incr?val=5");
            string     methodeName = url.Segments[url.Segments.Length - 1].ToLower();
            MyMethods  myMthd      = new MyMethods();
            Type       type        = typeof(MyMethods);
            MethodInfo method      = type.GetMethod(methodeName);

            if (method != null)
            {
                string[] parametres = { HttpUtility.ParseQueryString(url.Query).Get("val") };
                string   reponse    = (string)method.Invoke(myMthd, parametres);
                Console.WriteLine(reponse);
            }
            else
            {
                Console.WriteLine("Le lien est incorecte");
            }
        }
Ejemplo n.º 24
0
        static void Main()
        {
            /*for (int i = 0; i < 15; i++) {
             *  Console.WriteLine(MyMethods.FibRecurssion(i));
             * }
             * Console.Read();*/
            ArrayList arr = new ArrayList();

            for (int i = 0; i < 15; i++)
            {
                arr.Add(i);
            }
            arr.RemoveAt(4);
            try
            {
                object o = arr[arr.Count - 1];
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
                Console.Read();
                // Set IndexOutOfRangeException to the new exception's InnerException.
                throw new ArgumentOutOfRangeException("index parameter is out of range.", e);
            }

            Person person = new Person();


            //Console.WriteLine(person.Age);
            //Console.Read();
            double total   = 0;
            double output  = MyMethods.PennyShade(12.000134);
            double output1 = MyMethods.PennyShade(12.000134);
            double output2 = MyMethods.PennyShade(12.000134);

            total += output;
            total += output1;
            total += output2;

            Console.WriteLine(total);
            Console.Read();
        }
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            string msg = "";

            if (TXTxm.Text == "")
            {
                msg += "姓名不能为空!";
            }
            if (TXTxh.Text == "")
            {
                msg += "学号不能为空!";
            }
            if (DDLbj.SelectedValue == "")
            {
                msg += "班级不能为空!";
            }
            if (TXTmm.Text == "")
            {
                msg += "密码不能为空!";
            }
            if (TXTmm.Text != TXTmmqr.Text)
            {
                msg += "两次密码输入不一致!";
            }
            if (msg != "")
            {
                Response.Write("<script>alert('" + msg + "')</script>");
                return;
            }
            string strid = new MyMethods().DateId();
            string sql   = "insert into 学生(学号,姓名,班级编号,密码) values ('" + TXTxh.Text + "','" + TXTxm.Text + "','" + DDLbj.SelectedValue + "','" + TXTmm.Text + "')";

            if (new MyData(Application["connstr"].ToString()).eInsertUpdateDelete(sql) == 0)
            {
                Response.Write("<script>alert('输入的学号与数据库中某一记录重复,请重输!')</script>");
                return;
            }
            Clear_Input();
            DG_bind();
            Response.Write("<script>alert('添加成功!')</script>");
        }
Ejemplo n.º 26
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            bool    goodNum1 = false;
            bool    goodNum2 = false;
            decimal num1     = 0;
            decimal num2     = 0;

            // Attempt to get valid input (two decimals)
            goodNum1 = decimal.TryParse(txtNum1.Text, out num1);
            goodNum2 = decimal.TryParse(txtNum2.Text, out num2);

            if (goodNum1 && goodNum2)
            {
                // TODO # - Add numbers using method from personal library
                txtSum.Text = MyMethods.AddTwo(num1, num2).ToString();
            }
            else
            {
                MessageBox.Show("Invalid data. Enter numbers only.");
            }
        }
        static void Main(string[] args)
        {
            Dlg d1     = new Dlg(MyMethods.Sum);
            int result = d1.Invoke(50, "Armenia");

            Console.WriteLine("Result is " + result);
            Dlg d2  = MyMethods.Sum;
            int rst = d2(121, "Erevan");

            Console.WriteLine("Res is " + rst);
            d2 += MyMethods.Multy;
            MyMethods md = new MyMethods();// kamel karelie "d2+= new MyMethods().Sub;"

            d2 += md.Sub;
            int r = d2(119, "Sona");

            Console.WriteLine(r);
            Delegate[] dl = d2.GetInvocationList();
            foreach (Dlg g in dl)
            {
                Console.WriteLine(g.Method.Name + "\t" + g.Target);
            }
        }
Ejemplo n.º 28
0
 private void btnAbout_Click(object sender, EventArgs e)
 {
     // TODO # - Call a method from personal lib that displays programmer info
     MyMethods.AboutEugene();
 }
Ejemplo n.º 29
0
        private void ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            DataGrid  curr_dg = (DataGrid)source;
            MyMethods mm      = new MyMethods();

            if (curr_dg.ID == "Dg_xb")
            {
                if (e.CommandName == "Select")
                {
                    Panel_bj.Visible = true;
                    string strsql = "select * from 班级 where 系部编号='" + Convert.ToString(Dg_xb.DataKeys[e.Item.ItemIndex]) + "'";
                    mm.DG_bind(Dg_bj, strsql, "", "", Application["connstr"].ToString());
                }
                else
                {
                    if (e.CommandName == "Edit")
                    {
                        Dg_xb.EditItemIndex = e.Item.ItemIndex;
                        Panel_bj.Visible    = false;
                    }
                    if (e.CommandName == "Update")
                    {
                        TextBox tb1;
                        tb1 = (TextBox)e.Item.Cells[0].Controls[0];
                        if (tb1.Text == "")
                        {
                            Response.Write("<script>alert('章节名称不能为空!')</script>");
                            return;
                        }

                        string sql = "update 系部 set 系部名称='" + tb1.Text + "' where 系部编号='" + Dg_xb.DataKeys[e.Item.ItemIndex] + "'";
                        new MyData(Application["connstr"].ToString()).eInsertUpdateDelete(sql);
                        Dg_xb.EditItemIndex = -1;
                        Panel_bj.Visible    = false;
                    }

                    if (e.CommandName == "Delete")
                    {
                        string          sql = "select * from 班级 where 系部编号='" + Dg_xb.DataKeys[e.Item.ItemIndex] + "'";
                        MyData          md  = new MyData(Application["connstr"].ToString());
                        OleDbDataReader dr  = md.eSelect(sql);
                        if (dr.Read())
                        {
                            dr.Close();
                            md.CloseConn();
                            Response.Write("<script>alert('由于该系部下有班级信息,必须删除其所有下属班级信息,才允许删除系部信息!')</script>");
                        }
                        else
                        {
                            dr.Close();
                            md.CloseConn();
                            sql = "delete from 系部 where 系部编号='" + Dg_xb.DataKeys[e.Item.ItemIndex] + "'";
                            new MyData(Application["connstr"].ToString()).eInsertUpdateDelete(sql);
                            Panel_bj.Visible = false;
                        }
                    }
                    if (e.CommandName == "Cancel")
                    {
                        Dg_xb.EditItemIndex = -1;
                        Panel_bj.Visible    = false;
                    }
                    mm.DG_bind(Dg_xb, "select * from 系部", "", "", Application["connstr"].ToString());
                }
            }
            else
            {
                if (e.CommandName == "Edit")
                {
                    Dg_bj.EditItemIndex = e.Item.ItemIndex;
                }
                if (e.CommandName == "Update")
                {
                    TextBox tb1, tb2;
                    tb1 = (TextBox)e.Item.Cells[0].Controls[0];
                    tb2 = (TextBox)e.Item.Cells[1].Controls[0];
                    string msg = "";
                    if (tb1.Text == "")
                    {
                        msg += "班级名称不能为空!";
                        return;
                    }
                    if (tb2.Text != "")
                    {
                        try
                        {
                            Convert.ToDateTime(tb2.Text);
                        }
                        catch (Exception)
                        {
                            msg += "输入的允许考试日期不是正确的日期类型正确写法如:2007-2-9!";
                            return;
                        }
                    }
                    if (msg != "")
                    {
                        Response.Write("<script>alert('" + msg + "')</script>");
                        return;
                    }
                    string sql;
                    if (tb2.Text == "")
                    {
                        sql = "update 班级 set 班级名称='" + tb1.Text + "' where id='" + Dg_bj.DataKeys[e.Item.ItemIndex] + "'";
                    }
                    else
                    {
                        sql = "update 班级 set 班级名称='" + tb1.Text + "',允许考试日期=#" + tb2.Text + "# where id='" + Dg_bj.DataKeys[e.Item.ItemIndex] + "'";
                    }
                    new MyData(Application["connstr"].ToString()).eInsertUpdateDelete(sql);
                    Dg_bj.EditItemIndex = -1;
                }

                if (e.CommandName == "Delete")
                {
                    MyData          md = new MyData(Application["connstr"].ToString());
                    OleDbDataReader dr = md.eSelect("select * from 学生 where 班级编号='" + Dg_bj.DataKeys[e.Item.ItemIndex] + "'");
                    if (dr.Read())
                    {
                        dr.Close();
                        Response.Write("<script>alert('由于该班级下有学生信息,必须删除其所有下属学生信息,才允许删除班级信息!')</script>");
                    }
                    else
                    {
                        dr.Close();
                        md.CloseConn();
                        new MyData(Application["connstr"].ToString()).eInsertUpdateDelete("delete from 班级 where id='" + Dg_bj.DataKeys[e.Item.ItemIndex] + "'");
                    }
                }
                if (e.CommandName == "Cancel")
                {
                    Dg_bj.EditItemIndex = -1;
                }
                string strsql = "select * from 班级 where 系部编号='" + Convert.ToString(Dg_xb.DataKeys[Dg_xb.SelectedIndex]) + "'";
                mm.DG_bind(Dg_bj, strsql, "", "", Application["connstr"].ToString());
            }
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Library!\n");

            MyMethods.Pause();
        }
Ejemplo n.º 31
0
        public void GetProductVendorByProductNameTest()
        {
            String name = MyMethods.GetProductVendorByProductName("Product5");

            Assert.AreEqual("Vendor3", name);
        }