public void GenericTypeIsACompositionOfTypes()
        {
            var helloCat = new SayHello <Cat> ();

            //Assert.AreEqual (typeof(FILL_ME_IN), helloCat.GetType ());
            Assert.AreEqual(typeof(SayHello <Cat>), helloCat.GetType());
        }
Example #2
0
        public async Task Handle(SayHello command, IMessageHandlerContext ctx)
        {
            Processed++;
            var user = await _uow.For <User>().Get(command.User);

            user.SayHello(command.Message);
        }
Example #3
0
 private void OnLeaveHandler(Person p)
 {
     Console.WriteLine($"[{p.Name} ушёл с работы]");
     greetAll -= p.Greeting;
     byeAll   -= p.Farewell;
     byeAll?.Invoke(p);
 }
Example #4
0
 private void OnCameHandler(Person p, DateTime time)
 {
     Console.WriteLine($"[{p.Name} пришёл на работу]");
     greetAll?.Invoke(p, time);
     greetAll += p.Greeting;
     byeAll   += p.Farewell;
 }
        public void GenericTypeCanGetTheGenericArgumentName()
        {
            var helloCat = new SayHello <Cat> ();

            //Assert.AreEqual (FILL_ME_IN, helloCat.HelloMessage ());
            Assert.AreEqual("Hola Cat", helloCat.HelloMessage());
        }
Example #6
0
        static void Main(string[] args)
        {
            //Named Delegate
            SayHello obj = HelloFunction;

            obj.Invoke("Gagan");
            //Anonymous Delegate
            Add f1 = delegate(int a, int b)
            {
                return(a + b);
            };

            f1.Invoke(4, 3);
            //Composable Delegate
            obj += HiFunction;    //When Line 26 is commented then first Hello Gagan is printed then Hi Gagan is printed
            obj.Invoke("Gagan");
            //Func Delegate -
            Func <int, int> Square = (input) => { return(input * input); };

            Console.WriteLine(string.Format("This is output of Func Delegate:" + Square(4)));
            //Action Delegate - No return Type
            Action <double, double> Power = (input1, input2) => { Console.WriteLine("Action Delegate:" + Math.Pow(input1, input2)); };

            Power(2, 3);
            //Predicate Delegate - Bool return type
            Predicate <int> IsGreateThenZero = (input) => { return(input > 0 ? true : false); };

            Console.WriteLine(IsGreateThenZero(5));
            //Comparison Delegate
        }
Example #7
0
 private void OnLeaveHandler(Person p)
 {
     Console.WriteLine($"{p.Name} ушел");
     greetAll -= p.Greet;
     byeAll   -= p.SayBye;
     byeAll?.Invoke(p);
 }
Example #8
0
        static void Main()
        {
            SayHello hello = new SayHello();

            hello.speak();
            hello.goodbye();
        }
Example #9
0
        public void IsGenericTypeInformation()
        {
            var helloCat = new SayHello <Cat> ();

            Assert.AreEqual(true, helloCat.GetType().IsGenericType);
            Assert.AreEqual(true, typeof(SayHello <>).IsGenericTypeDefinition);
        }
Example #10
0
 private void OnGoneEventHandler(Person person)
 {
     Console.WriteLine($"\n[{person.Name} ушел домой]");
     greetAll -= person.Hello;
     byeAll   -= person.Goodbye;
     byeAll?.Invoke(person);
 }
Example #11
0
        static void Main(string[] args)
        {
            /// BITWISE STUFF
            //byte a = 25;
            //byte b = 7;

            //byte res = (byte)~a;

            //Console.WriteLine($"{Convert.ToString(a, 2).PadLeft(8, '0')} ~");
            ////Console.WriteLine($"{Convert.ToString(b, 2).PadLeft(8, '0')}");
            //Console.WriteLine("-----------------");
            //Console.WriteLine($"{Convert.ToString(res, 2).PadLeft(8, '0')}");

            var colorSelection = (byte)(Colors.Black | Colors.Green | Colors.Violet);

            Console.WriteLine($"{Convert.ToString(colorSelection, 2).PadLeft(8, '0')}");
            /// BITWISE STUFF

            /// CLOSURES in C#
            SayHello myFunc = var1 => $"Hello {var1}";

            Console.WriteLine(myFunc("John"));

            var inc = GetAFuncLocal();

            Console.WriteLine(inc(5));
            Console.WriteLine(inc(6));
            Console.WriteLine(inc(6));

            Console.ReadKey();
        }
Example #12
0
 public static void TestSayHello(SayHello func)
 {
     UnitTest.Answers = new List <string>
     {
         func("World"), func("Dolly"), func("there")
     };
 }
        public IActionResult SayHello()
        {
            var sayHello = new SayHello();


            return(View(sayHello));
        }
Example #14
0
        public void It_can_say_hello()
        {
            var sayHello = new SayHello("World");
            var reply    = _mediator.Request(sayHello);

            Assert.AreEqual("Hello, World!", reply.Hello);
        }
Example #15
0
    public void SuccessfulTest1()
    {
        string actual   = SayHello.WriteInput("Ivan");
        string expected = "Hello, Ivan!";

        Assert.AreEqual(expected, actual);
    }
Example #16
0
    public void FailTest1()
    {
        string actual   = SayHello.WriteInput("Ivan!");
        string expected = "Peter is not Ivan!";

        Assert.AreEqual(expected, actual);
    }
Example #17
0
    public void SuccessfulTest2()
    {
        string actual   = SayHello.WriteInput("Peter");
        string expected = "Hello, Peter!";

        Assert.AreEqual(expected, actual);
    }
Example #18
0
 private void Leave(Person men)
 {
     Console.WriteLine($"[{men.Name} ушел домой]");
     hello -= men.SayHello;
     bye   -= men.SayBye;
     bye?.Invoke(men.Name);
 }
 public void It_can_say_hello_asynchronously()
 {
     var sayHello = new SayHello("World");
     var reply = _mediator.RequestAsync(sayHello);
     reply.Wait(waitDuration);
     Assert.AreEqual("Hello, World!", reply.Result.Hello);
 }
Example #20
0
 private void OnCameEventHandler(Person person, DateTime time)
 {
     Console.WriteLine($"\n[На работу пришел {person.Name}]");
     greetAll?.Invoke(person, time);
     greetAll += person.Hello;
     byeAll   += person.Goodbye;
 }
Example #21
0
        static void Main(string[] args)
        {
            string msg = SayHello.GetMessage();

            Console.WriteLine(msg);
            Console.ReadKey();
        }
Example #22
0
 private void Came(Person men, DateTime time)
 {
     Console.WriteLine($"[ На работу пришел {men.Name}]");
     hello?.Invoke(men.Name, time);
     hello += men.SayHello;
     bye   += men.SayBye;
 }
Example #23
0
 private void OnLeaveHanler(Person p)
 {
     Console.WriteLine($"Person {p.Name} go at home");
     greetAll   -= p.SayHello;
     goodbyeAll -= p.SayGoodBye;
     goodbyeAll?.Invoke(p.Name);
 }
Example #24
0
        private void OnCameHandler(Person p, DateTime time)
        {
            Console.WriteLine($"Person {p.Name} came to work");
            greetAll?.Invoke(p.Name, DateTime.Now);

            greetAll   += p.SayHello;
            goodbyeAll += p.SayGoodBye;
        }
 static string TestGreeting()
 {
     if (SayHello.PrintHello("Peter") != "Hello, Peter!")
     {
         return("Failure!");
     }
     return("Success!");
 }
 public void Async_requests_allow_the_thread_to_continue()
 {
     var request = new SayHello("World");
     var task = _mediator.RequestAsync(request);
     Assert.IsFalse(task.IsCompleted);
     task.Wait(_waitDuration);
     Assert.AreEqual("Hello, World!", task.Result.Hello);
 }
Example #27
0
 private void OnLeaveHandler(Person p)
 {
     Console.ForegroundColor = ConsoleColor.White;
     Console.WriteLine($"--Сотрудник {p.Name} ушёл");
     helloList -= p.SayHello;
     byeList   -= p.SayBye;
     byeList?.Invoke(p);
 }
Example #28
0
        public void It_can_say_hello_asynchronously()
        {
            var sayHello = new SayHello("World");
            var reply    = _mediator.RequestAsync(sayHello);

            reply.Wait(waitDuration);
            Assert.AreEqual("Hello, World!", reply.Result.Hello);
        }
        public void GenericTypeCanBeUsedWithAnyTypeEvenPrimitives()
        {
            var helloInt = new SayHello <int> ();

            //Assert.AreEqual (FILL_ME_IN, helloInt.HelloMessage ());
            Assert.AreEqual("Hola " + typeof(int).ToString().Split('.').GetValue(1),
                            helloInt.HelloMessage());
        }
Example #30
0
        public void GetGenericTypeFromUsage()
        {
            var helloCat     = new SayHello <Cat> ();
            var expectedType = typeof(SayHello <>);

            Assert.AreEqual(expectedType, helloCat.GetType().GetGenericTypeDefinition());
            Assert.AreEqual(true, typeof(SayHello <>).IsGenericTypeDefinition);
        }
Example #31
0
 private void OnCameHandler(Person p, DateTime time)
 {
     Console.WriteLine($"{p.Name} пришел");
     // вызываем все методы приветствия, какие есть
     greetAll?.Invoke(p, time);
     greetAll += p.Greet;
     byeAll   += p.SayBye;
 }
Example #32
0
        private static void Intercept_constructor_method()
        {
            var sut = CreateSut("MockLibrary.SayHello..ctor");

            sut.Start();
            var mock = new SayHello("World");

            sut.Stop();
        }
 public void It_can_say_hello()
 {
     var sayHello = new SayHello("World");
     var reply = _mediator.Request(sayHello);
     Assert.AreEqual("Hello, World!", reply.Hello);
 }
Example #34
0
        public void ShouldOutputVerboseTrace()
        {
            // Arrange
            string testCategory = "Test";
            string expectedData = "From SayHello";
            string expectedTrace = string.Format("{0}: {1}", testCategory, expectedData);
            var listener = new TestTraceListener();
            var tracker = new TestTrackingParticipant();
            var profile = new TrackingProfile()
            {
                Name = "TestTrackingProfile",
                Queries = 
                {
                    new CustomTrackingQuery()
                    {
                        Name="Test",
                        ActivityName = "*"
                    }
                }
            };

            tracker.TrackingProfile = profile;

            Trace.Listeners.Add(listener);

            var target = new SayHello()
            {
                UserName = "******"
            };

            var workflow = new WorkflowInvoker(target);
            workflow.Extensions.Add(tracker);

            // Act
            workflow.Invoke();

            // Assert System.Diagnostics.Trace
            Assert.AreEqual(1, listener.Traces.Count);
            Assert.AreEqual(expectedTrace, listener.Traces[0]);

            // Assert Tracking Records
            Assert.AreEqual(1, tracker.Records.Count);
            var customRecord = tracker.Records[0] as CustomTrackingRecord;
            Assert.AreEqual(expectedData, customRecord.Data["Text"]);
            Assert.AreEqual(testCategory, customRecord.Data["Category"]);
        }