コード例 #1
0
        public void BuildComplexUrl_Create()
        {
            string expected = String.Format("http://testprefix/foo/1/bar/List(foo,2,3)/baz/(deeper:List(found,it,{0}))/biz", complexStringEscapedPath);

            GreetingBuilder greetingBuilder = new GreetingBuilder()
            {
                id      = 555,
                tone    = new Tone(Tone.Symbol.INSULTING),
                message = "build URl for this CREATE"
            };
            Greeting greeting = greetingBuilder.Build();

            CreateRequestBuilder <int, Greeting> requestBuilder = new CreateRequestBuilder <int, Greeting>("foo/{one}/bar/{list}/baz/{complex}/biz");

            requestBuilder.SetPathKey("one", 1);
            requestBuilder.SetPathKey("list", new List <object>()
            {
                "foo", 2, 3
            });
            requestBuilder.SetPathKey("complex", new Dictionary <string, object>()
            {
                { "deeper", new List <object>()
                  {
                      "found", "it", complexString
                  } }
            });
            CreateRequest <int, Greeting> request = requestBuilder.Build();

            RequestUrlBuilder <CreateResponse <int, Greeting> > urlBuilder = new RequestUrlBuilder <CreateResponse <int, Greeting> >(request, "http://testprefix");
            Uri url = urlBuilder.Build();

            Assert.AreEqual(expected, url.AbsoluteUri);
        }
コード例 #2
0
        public void CreateGreeting_Sync()
        {
            RestClient client = new RestClient(urlPrefix);

            GreetingBuilder greetingBuilder = new GreetingBuilder();

            greetingBuilder.id      = 0; // Dummy value
            greetingBuilder.message = "Create me!";
            greetingBuilder.tone    = new Tone(Tone.Symbol.FRIENDLY);
            Greeting input = greetingBuilder.Build();

            CreateRequestBuilder <int, Greeting> requestBuilder = new CreateRequestBuilder <int, Greeting>("/basicCollection");

            requestBuilder.input = input;
            CreateRequest <int, Greeting> request = requestBuilder.Build();

            CreateResponse <int, Greeting> response = client.RestRequestSync(request);

            Assert.AreEqual(RestConstants.httpStatusCreated, response.status);
            Assert.AreEqual(123, response.key);
            CollectionAssert.AreEqual(new List <string>()
            {
                "/basicCollection/123"
            }, response.headers[RestConstants.kHeaderLocation].ToList());
        }
コード例 #3
0
ファイル: assertions.cs プロジェクト: mpreeves/snippets
    public void state_based_assertion()
    {
        GreetingBuilder sut = new GreetingBuilder();

        sut.Build();

        Assert.AreEqual("Hello, World", g.Message);
    }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            GreetingBuilder builder = new GreetingBuilder();

            builder.Name = textBox1.Text;
            var greeting = builder.GetGreeting();

            MessageBox.Show(greeting);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            GreetingBuilder builder = new GreetingBuilder();

            Console.WriteLine("Enter your name");
            builder.Name = Console.ReadLine();
            var greeting = builder.GetGreeting();

            Console.WriteLine(greeting);
        }
コード例 #6
0
    public void should_build_a_default_message()
    {
        // Arrange
        GreetingBuilder gb = new GreetingBuilder();

        // Act
        string message = gb.Build();

        // Assert
        Assert.AreEqual("Hello, World", message);
    }
コード例 #7
0
        public void TestMethod1()
        {
            //Greet greeting = new Greet();
            //greeting.TimeOfDay = "Noche";
            //greeting.To = "Eduardo";

            Greet greeting = GreetingBuilder
                             .CreateNew()
                             .TimeOfDay("Noche")
                             .To("Eduardo")
                             .Build();

            Assert.AreEqual("Buenas Noche Eduardo", greeting.Message);
        }
コード例 #8
0
        public void BuildGreeting()
        {
            GreetingBuilder b = new GreetingBuilder();

            b.id      = 456;
            b.message = "This is the Greeting Builder test!";
            b.tone    = new Tone(Tone.Symbol.FRIENDLY);
            Greeting g = b.Build();

            Assert.IsTrue(g.hasId);
            Assert.IsTrue(g.hasMessage);
            Assert.IsTrue(g.hasTone);
            Assert.AreEqual(456, g.id);
            Assert.AreEqual("This is the Greeting Builder test!", g.message);
            Assert.AreEqual(Tone.Symbol.FRIENDLY, g.tone.symbol);
        }
コード例 #9
0
        public static void SetUpTestGlobals(TestContext testContext)
        {
            GreetingBuilder greetingBuilder = new GreetingBuilder();

            greetingBuilder.id      = 123;
            greetingBuilder.message = "encode me!";
            greetingBuilder.tone    = new Tone(Tone.Symbol.FRIENDLY);
            greeting = greetingBuilder.Build();

            tone = new Tone(Tone.Symbol.FRIENDLY);

            bytes = new Bytes(new byte[] { 0, 1, 2, 3,
                                           48, 49, 50, 51,
                                           65, 66, 67, 68,
                                           161, 162, 163, 164 });
        }
コード例 #10
0
        public void CreateGreeting_Async()
        {
            RestClient client = new RestClient(urlPrefix);

            GreetingBuilder greetingBuilder = new GreetingBuilder();

            greetingBuilder.id      = 0; // Dummy value
            greetingBuilder.message = "Create me!";
            greetingBuilder.tone    = new Tone(Tone.Symbol.FRIENDLY);
            Greeting input = greetingBuilder.Build();

            CreateRequestBuilder <int, Greeting> requestBuilder = new CreateRequestBuilder <int, Greeting>("/basicCollection");

            requestBuilder.input = input;
            CreateRequest <int, Greeting> request = requestBuilder.Build();

            AutoResetEvent blocker = new AutoResetEvent(false);

            CreateResponse <int, Greeting> createResponse = null;
            ClientErrorResponse            errorResponse  = null;

            RestliCallback <CreateResponse <int, Greeting> > .SuccessHandler successHandler = delegate(CreateResponse <int, Greeting> response)
            {
                createResponse = response;
                blocker.Set();
            };
            RestliCallback <CreateResponse <int, Greeting> > .ErrorHandler errorHandler = delegate(ClientErrorResponse response)
            {
                errorResponse = response;
                blocker.Set();
            };
            RestliCallback <CreateResponse <int, Greeting> > callback = new RestliCallback <CreateResponse <int, Greeting> >(successHandler, errorHandler);

            client.RestRequestAsync(request, callback);

            blocker.WaitOne(asyncTimeoutMillis);

            Assert.IsNull(errorResponse);
            Assert.AreEqual(RestConstants.httpStatusCreated, createResponse.status);
            Assert.AreEqual(123, createResponse.key);
            CollectionAssert.AreEqual(new List <string>()
            {
                "/basicCollection/123"
            }, createResponse.headers[RestConstants.kHeaderLocation].ToList());
        }
コード例 #11
0
        public void SerializeAndDeserializeRecordWithEnum()
        {
            GreetingBuilder greetingBuilder = new GreetingBuilder();

            greetingBuilder.id      = 123;
            greetingBuilder.tone    = new Tone(Tone.Symbol.SINCERE);
            greetingBuilder.message = "Hello, Serialize test!";
            Greeting g = greetingBuilder.Build();

            string serialized = DataUtil.MapToString(g.Data());

            Dictionary <string, object> dataMap = DataUtil.StringToMap(serialized);
            Greeting reclaimed = new Greeting(dataMap);

            Assert.AreEqual(g.id, reclaimed.id);
            Assert.AreEqual(g.message, reclaimed.message);
            Assert.AreEqual(g.tone.symbol, reclaimed.tone.symbol);
        }
コード例 #12
0
ファイル: assertions.cs プロジェクト: mpreeves/snippets
    public void return_based_assertion()
    {
        string message = GreetingBuilder.Build();

        Assert.AreEqual("Hello, World", message);
    }
コード例 #13
0
 private void SpeakGreeting()
 {
     Speak(GreetingBuilder.GetCurrentGreetingFor(Settings.Default.UserName));
 }
コード例 #14
0
        public dynamic Get()
        {
            var greetingBuilder = new GreetingBuilder();

            return(new { Text = greetingBuilder.Build() });
        }