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); }
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()); }
public void state_based_assertion() { GreetingBuilder sut = new GreetingBuilder(); sut.Build(); Assert.AreEqual("Hello, World", g.Message); }
private void button1_Click(object sender, EventArgs e) { GreetingBuilder builder = new GreetingBuilder(); builder.Name = textBox1.Text; var greeting = builder.GetGreeting(); MessageBox.Show(greeting); }
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); }
public void should_build_a_default_message() { // Arrange GreetingBuilder gb = new GreetingBuilder(); // Act string message = gb.Build(); // Assert Assert.AreEqual("Hello, World", message); }
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); }
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); }
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 }); }
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()); }
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); }
public void return_based_assertion() { string message = GreetingBuilder.Build(); Assert.AreEqual("Hello, World", message); }
private void SpeakGreeting() { Speak(GreetingBuilder.GetCurrentGreetingFor(Settings.Default.UserName)); }
public dynamic Get() { var greetingBuilder = new GreetingBuilder(); return(new { Text = greetingBuilder.Build() }); }