Beispiel #1
0
        public void IsStringInUpperCase_NoUpperCaseString_FalseReturned(string name)
        {
            bool expected = false;
            // act
            bool actual = GreetingClass.IsStringInUpperCase(name);

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void Greet_EmptyString_HelloMyFriendReturned()
        {
            // arrange
            string expected = "Hello, my friend.";
            // act
            string actual = GreetingClass.Greet("");

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void IsStringInUpperCase_EmptyString_FalseReturned()
        {
            // arrange
            bool expected = false;
            // act
            bool actual = GreetingClass.IsStringInUpperCase("");

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
    protected override void ProcessRecord()
    {
        base.ProcessRecord();
        WriteVerbose("Creating and returning the Greeting Object");
        var greeting = new GreetingClass {
            Greeting = Greeting, ToWhom = ToWhom
        };

        WriteObject(greeting);
    }
Beispiel #5
0
        public void IsStringInUpperCase_UpperCaseString_TrueReturned()
        {
            // arrange
            string name     = "JERRY";
            bool   expected = true;
            // act
            bool actual = GreetingClass.IsStringInUpperCase(name);

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #6
0
        public void Greet_ArrayOfMoreThanTwoNames_HelloToAllNamesReturned()
        {
            // arrange
            string[] names    = { "Amy", "Brian", "Charlotte" };
            string   expected = "Hello, Amy, Brian, and Charlotte.";
            // act
            string actual = GreetingClass.Greet(names);

            // assert
            Assert.IsTrue(expected.Equals(actual));
        }
Beispiel #7
0
        public void Greet_ArrayOfTwoNames_HelloToBothNamesReturned()
        {
            // arrange
            string[] names    = { "Jill", "Jane" };
            string   expected = "Hello, Jill and Jane.";
            // act
            string actual = GreetingClass.Greet(names);

            // assert
            Assert.IsTrue(expected.Equals(actual));
        }
Beispiel #8
0
        public void Greet_UpperCaseName_UpperCaseResponseReturned()
        {
            // arrange
            string name     = "JERRY";
            string expected = "HELLO JERRY!";
            // act
            string actual = GreetingClass.Greet(name);

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
        public void Greet_Null_HelloMyFriendReturned()
        {
            // arrange
            string expected = "Hello, my friend.";
            string name     = null;
            // act
            string actual = GreetingClass.Greet(name);

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #10
0
        public void Greet_Bob_HelloBobReturned()
        {
            // arrange
            string name     = "Bob";
            string expected = "Hello, Bob.";
            // act
            string actual = GreetingClass.Greet(name);

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #11
0
        // GET: Deletegate
        public ActionResult Index()
        {
            DeletegateClass.Show();
            GreetingClass.Greeting("波波", PeopleType.chinese);                            //普通调用

            GreetingHandler handel = new GreetingHandler(GreetingClass.GreetingChinese); //委托实列化 方法作为参数传入

            // GreetingHandler h = GreetingClass.GreetingChinese;
            GreetingClass.Greeting("波波", handel);
            //用action 代替委托方法 可省去声明委托一步(没有返回参数)
            //Action<string> action = GreetingClass.GreetingChinese;
            //GreetingClass.Greeting("波波",action);//委托调用
            Action             act1  = () => { };                 //没有参数,就是一个小括号,没有方法体 就是一个大括号(可以有16个参数)
            Action <string>    act2  = a => Console.WriteLine(a); //只有一个参数 可以去掉小括号
            Func <int>         func1 = () => DateTime.Now.Day;    //如果方法体只有一行 ,可以去掉大括号、分号、return
            Func <int, string> func2 = i => i.ToString();         //可以有16个参数

            Type type = typeof(Cat);                              //找到类型
            var  obj  = Activator.CreateInstance(type);
            Cat  cat  = (Cat)obj;

            cat.Miao();
            cat.CatMiaoHandlerMethod  = Dog.Wang;
            cat.CatMiaoHandlerMethod += Mouse.Run;
            cat.CatMiaoHandlerMethod += Baby.Kry;
            //cat.CatMiaoHandlerMethod();
            cat.Miao();
            // cat.CatMiaoHandlerMethodEvent = new CatMiaoHandler(Dog.Wang);//事件不能被初始化
            cat.CatMiaoHandlerMethodEvent += Dog.Wang;
            cat.CatMiaoHandlerMethodEvent += Mouse.Run;
            cat.CatMiaoHandlerMethodEvent += Baby.Kry;
            cat.Miao();
            //cat.CatMiaoHandlerMethodEvent();//不能被外部调用
            //linq 调用
            LinqTest liqntest = new LinqTest();

            liqntest.Methods();
            liqntest.Sort();

            DelegateExtend extend = new DelegateExtend();

            extend.Test();
            DBHelperSQL sqlhelper = new DBHelperSQL();

            sqlhelper.insert("Insert into jmp_app (a_user_id,a_name,a_platform_id,a_paymode_id,a_apptype_id,a_key,a_notifyurl)values (1,'1222222',1,1,1,23,11111)");


            return(View());
        }
 public ActionResult Index(string userName)
 {
     ViewBag.Message = GreetingClass.GreetingMethod(userName);
     return(View("About"));
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Label.Content = GreetingClass.GreetingMethod(Box.Text);
     Box.Text      = string.Empty;
 }