示例#1
0
        public void SayHello_ReturnsHello()
        {
            Greeter greeter = new Greeter("Rob");
            string greeting = greeter.SayHello("Jon");

            Assert.AreEqual("Hello Jon from Rob", greeting);
        }
示例#2
0
        public void SayHello_ReturnsHelloWithRecipientNameButNoSpeakerName()
        {
            Greeter greeter = new Greeter(null);
            string greeting = greeter.SayHello("Jon");

            Assert.AreEqual("Hello Jon", greeting);
        }
示例#3
0
        public void SpeakerProperty_IsSetFromConstructor()
        {
            Greeter greeter = new Greeter("Rob");

            Assert.AreEqual("Rob", greeter.Speaker);
            Assert.AreNotEqual("rob", greeter.Speaker);
        }
示例#4
0
	public void Main (string[] args)
    {
		
        var greeter = new Greeter();
		var name = args.Length > 0 ? args[0] : "Dude";
		greeter.Greet(name);
		ReadLine();
    }
        public void Should_greet_by_name_when_name_is_given()
        {
            Greeter greeter = new Greeter();

            greeter.SayHello("Mike").ShouldEqual("Hello, Mike!");

            IGreeter igreeter = new Greeter();

            igreeter.SayHello("Mike").ShouldEqual("Hello, Mike!");
        }
示例#6
0
        public void SpeakerProperty_IsWritable()
        {
            Greeter greeter = new Greeter("Rob");
            greeter.Speaker = "Tom";

            Assert.AreEqual("Tom", greeter.Speaker);

            string greeting = greeter.SayHello("Jon");
            Assert.AreEqual("Hello Jon from Tom", greeting);
        }
        public void Should_get_different_default_value_depending_on_variable_declaration()
        {
            Greeter greeter = new Greeter();

            greeter.SayHello().ShouldEqual("Hello, you!");

            IGreeter igreeter = new Greeter();

            igreeter.SayHello().ShouldEqual("Hello, Jane!");

            // WHAT!?
        }
示例#8
0
 public void SetUp()
 {
     _greeter = new Greeter();
     _queryHandlerFactoryMock = new Mock <IQueryHandlerFactory>();
     _queryHandlerFactoryMock.Setup(x => x.Create <HelloQuery>()).Returns(new HelloQueryHandler(_greeter));
 }
示例#9
0
        static void Main(string[] args)
        {
            var greeter = new Greeter();

            Console.WriteLine(greeter.Greet());
        }
示例#10
0
        private void button1_Click(object sender, EventArgs e)
        {
            Greeter obj = new Greeter();

            MessageBox.Show(obj.GetGreetingWords(txtName.Text));
        }
示例#11
0
        public void Test()
        {
            var greeter = new Greeter();

            greeter.ShouldNotBeNull();
        }
示例#12
0
 public async Task Execute()
 {
     var result = await Greeter.SayHelloAsync(new HelloRequest { Name = "you" });
 }
 public static void Main(string[] args) {
     var greeter = new Greeter("Hello, World!");
     Console.WriteLine(greeter.SayHello());
 }
        static void Main(string[] args)
        {
            args    = new[] { "" };
            args[0] = "listen";

            switch (args[0].ToLower())
            {
            case "listen":
            {
                ////using (RpcServer.CreateRpc(IID, new Impersonation(new MyService.ServerStub(new Implementation())))
                //using (RpcServer.CreateRpc(IID, new Impersonation(new Greeter.ServerStub(new Implementation_Greeter())))
                //    //.AddAuthentication(CSharpTest.Net.RpcLibrary.RpcAuthentication.RPC_C_AUTHN_NONE)
                //    //.AddAuthNegotiate()
                //    .AddProtocol("ncacn_ip_tcp", "50051")
                //    //.AddProtocol("ncacn_np", @"\pipe\Greeter")
                //    ////.AddProtocol("ncalrpc", "MyService")
                //    //.AddProtocol("ncalrpc", "Greeter")
                //    .StartListening())
                //{
                //    Console.WriteLine("Waiting for connections...");
                //    Console.ReadLine();
                //}


                Guid iid = Marshal.GenerateGuidForType(typeof(IGreeter));
                using (RpcServer.CreateRpc(iid, new Greeter.ServerStub(new Anonymous_Greeter()))
                       //.AddAuthNegotiate()
                       .AddAuthentication(CSharpTest.Net.RpcLibrary.RpcAuthentication.RPC_C_AUTHN_NONE)
                       .AddAuthNegotiate()
                       .AddProtocol("ncacn_ip_tcp", "50051")
                       //.AddProtocol("ncalrpc", "Greeter")
                       .StartListening())
                {
                    Console.WriteLine("Waiting for connections...");
                    string name = "123";         // Console.ReadLine();


                    using (Greeter client = new Greeter(RpcClient
                                                        .ConnectRpc(iid, "ncacn_ip_tcp", @"localhost", "50051")
                                                        .Authenticate(RpcAuthenticationType.Self)
                                                        //.Authenticate(RpcAuthenticationType.None)
                                                        ))
                    {
                        HelloReply response = client.SayHello(HelloRequest.CreateBuilder().SetName(name).Build());
                        Console.WriteLine("OK: " + response.Message);
                    }
                    Console.ReadLine();
                }

                //Guid iid = Marshal.GenerateGuidForType(typeof(IBookService));
                //using (RpcServer.CreateRpc(iid, new BookService.ServerStub(new Anonymous_BookService()))
                //    .AddProtocol("ncacn_ip_tcp", "50051")
                //    .AddProtocol("ncalrpc", "BookService")
                //    .StartListening())
                //{
                //    Console.WriteLine("Waiting for connections...");
                //    Console.ReadLine();
                //}


                break;
            }

            case "send-lrpc":
            {
                using (MyService client = new MyService(
                           RpcClient.ConnectRpc(IID, "ncalrpc", null, "MyService")
                           .Authenticate(RpcAuthenticationType.Self)))
                {
                    MyResponse response = client.Send(
                        MyRequest.CreateBuilder().SetMessage("Hello via LRPC!").Build());
                }
                break;
            }

            case "send-tcp":
            {
                using (MyService client = new MyService(
                           RpcClient.ConnectRpc(IID, "ncacn_ip_tcp", @"localhost", "8080")
                           .Authenticate(RpcAuthenticationType.Self)))
                {
                    MyResponse response = client.Send(
                        MyRequest.CreateBuilder().SetMessage("Hello via Tcp/Ip!").Build());
                }
                break;
            }

            case "send-np":
            {
                using (MyService client = new MyService(
                           RpcClient.ConnectRpc(IID, "ncacn_np", @"\\localhost", @"\pipe\MyService")
                           .Authenticate(RpcAuthenticationType.Self)))
                {
                    MyResponse response = client.Send(
                        MyRequest.CreateBuilder().SetMessage("Hello via Named Pipe!").Build());
                }
                break;
            }

            case "send-anon":
            {
                using (MyService client = new MyService(
                           RpcClient.ConnectRpc(IID, "ncacn_np", @"\\localhost", @"\pipe\MyService")
                           .Authenticate(RpcAuthenticationType.Anonymous)))
                {
                    try
                    {
                        MyResponse response = client.Send(
                            MyRequest.CreateBuilder().SetMessage("Hello from Anonymous!").Build());
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine(e);
                    }
                }
                break;
            }
            }
        }
 public Greeter SetNext(Greeter nextGreeter)
 {
     next = nextGreeter;
     return(this);
 }
    public void DefaultGreet()
    {
        var greet = Greeter.Greet(null);

        Assert.Equal("Hello, my friend", greet);
    }
示例#17
0
 public string HelloWithCustomerName(string customerName)
 {
     return(Greeter.GenericHelloWithCustomerName(customerName) + MyNameIs());
 }
示例#18
0
 public string HelloWithCustomerNameAndPronoun(string customerName,
                                               string pronoun = "There")
 {
     return(Greeter.GenericHelloWithCustomerNameAndPronoun(customerName,
                                                           pronoun: pronoun) + MyNameIs());
 }
示例#19
0
 public string Hello()
 {
     return(Greeter.GenericHello() + MyNameIs());
 }
        public void TestGreetMethod()
        {
            Greeter greeter = new Greeter();

            Assert.Equal("Hello there. Welcome to CSharp", greeter.greet());
        }
示例#21
0
 static void Main(string[] args)
 {
     Console.WriteLine(Greeter.Greet("World"));
     Console.WriteLine(Greeter.Greet(null)); // with null it will throw an exception to check whether the stack traces are ok.
 }
示例#22
0
 public GreeterUser(string greeting, Greeter greeter)
 {
     this.greeting = greeting;
     this.greeter  = greeter;
 }
    public void Greet()
    {
        var greet = Greeter.Greet("Mercedes");

        Assert.Equal("Hello, Mercedes", greet);
    }
        public void TestGreetEmpty()
        {
            Greeter greeter = new Greeter();

            greeter.Greet(string.Empty);
        }
示例#25
0
 public void Stating_something()
 {
     Assert.AreEqual("Hello world.", Greeter.Hello());
 }
 public GreeterShould()
 {
     _greeter = new Greeter();
 }
 public void ShouldReturnHelloName()
 {
     var greeter = new Greeter();
     // TODO Check that "Hello Peter" and greeter.Greet("Peter") are equal.
 }
示例#28
0
 public static async Tasks.Task Execute()
 {
     var greeter = new Greeter();
     await greeter.RunAsync();
 }
示例#29
0
        public ActionResult Index()
        {
            var greeter = new Greeter();

            return(View((object)greeter.Greet()));
        }
示例#30
0
 public void CanGreet()
 {
     var greeter=new Greeter();
     string greet = greeter.Greet();
     Assert.AreEqual("Hello World", greet);
 }
示例#31
0
 public void SaysHello()
 {
     var greeter = new Greeter();
     var greet = greeter.Greet();
     Assert.That(greet, Contains.Substring("hello"));
 }
示例#32
0
 public void Greet_HelloMessage_Receives()
 {
     Assert.Equal("Hello Jhon", Greeter.Greet("Jhon"));
 }
示例#33
0
 public HelloQueryHandler(Greeter greeter)
 {
     _greeter = greeter;
 }
示例#34
0
        static void Main(string[] args)
        {
            var greeter = new Greeter(new ConsoleOutput());

            greeter.SayHello("world!");
        }
    public void Shout()
    {
        var greet = Greeter.Greet("MARITZA");

        Assert.Equal("HELLO, MARITZA", greet);
    }
示例#36
0
        public void SayHello_ThrowsExceptionWithNullRecipient()
        {
            Greeter greeter = new Greeter("Rob");

            Assert.Throws<ArgumentNullException>(() => greeter.SayHello(null));
        }
示例#37
0
 static void Main()
 {
     var greeter = new Greeter();
 }
 public void ShouldReturnHelloForNull()
 {
     var greeter = new Greeter();
     // TODO Check that "Hello" and greeter.Greet(null) are equal.
 }
        public string Greet(string who)
        {
            Greeter greeter = new Greeter();

            return(greeter.Greet(who));
        }
        public void TestGreetNull()
        {
            Greeter greeter = new Greeter();

            greeter.Greet(null);
        }
 public void ShouldIgnoreWhitespace()
 {
     var greeter = new Greeter();
     // TODO Check that "Hello Peter" and greeter.Greet(" Peter ") are equal.
 }
示例#42
0
	public void TestGreeterMethod() {
		Greeter greeterToTest = new Greeter("Hello test");
		string greeting = greeterToTest.SayHello();

		Assert.That(greeting, Is.EqualTo("Hello test"));
	}
示例#43
0
 public void DoSomething()
 {
     var greeter = new Greeter(new Writer());
     greeter.Greet();
 }