@@ -39,7 +39,7 @@ func.yaml created.
3939> cd dotnetfn
4040> ` ` `
4141
42- The ` fn init` command creates an simple function with a bit of boilerplate to get you
42+ The ` fn init` command creates a simple function with a bit of boilerplate to get you
4343started. The ` --runtime` option is used to indicate that the function
4444we' re going to develop will be written in C# and will work on dotnet core 3.1,
4545the default version as of this writing.
@@ -332,8 +332,8 @@ namespace Function.Tests {
332332` ` `
333333
334334You can run the tests by building your function with ` fn build` . This
335- will cause Dotnet to add both Source and Test project to ` Function.sln` .
336- The code will be build and tests will be run on creating a new function.
335+ will cause Dotnet to add both Source and Test projects to ` Function.sln` .
336+ The code will be built and tests will be run on creating a new function.
337337
338338! [](images/userinput.png)
339339> ` fn build`
@@ -350,45 +350,66 @@ Replace the definition of `HelloFunction` with the following:
350350
351351```csharp
352352using Fnproject.Fn.Fdk;
353+ using System;
353354
354355using System.Runtime.CompilerServices;
355- [assembly:InternalsVisibleTo("Function.Tests")]
356- namespace Function {
357- class Input {
358- public string name;
359- }
360-
361- class Greeter {
362- public string greet(Input input) {
363- return string.Format("Hello {0}!",
364- input.name.Length == 0 ? "World" : input.name.Trim());
365- }
366-
367- static void Main(string[] args) { Fdk.Handle(args[0]); }
368- }
356+ [assembly:InternalsVisibleTo("Function.Tests")] namespace Function {
357+ class Input {
358+ public string name {
359+ get;
360+ set;
361+ }
362+ }
363+
364+ class Greeter {
365+ public string greet(Input input) {
366+ return string.Format("Hello {0}!", string.IsNullOrEmpty(input.name)
367+ ? "World"
368+ : input.name.Trim());
369+ }
370+
371+ static void Main(string[] args) { Fdk.Handle(args[0]); }
372+ }
369373}
370374```
371375
372- Since we modified the `Program.cs` and changes the function format, we need to modify the `ProgramTest.cs` class.
376+ Since we modified the `Program.cs` and changed the function format, we need to modify the `ProgramTest.cs` class.
373377
374378```csharp
375379using Function;
376380using NUnit.Framework;
377381
378382namespace Function.Tests {
379- public class GreeterTest {
380- [Test]
381- public void TestGreetEmpty() {
382- Greeter greeter = new Greeter();
383- Input input = new Input();
383+ public class GreeterTest {
384+ [Test]
385+ public void TestGreetEmpty() {
386+ Greeter greeter = new Greeter();
387+ Input input = new Input();
388+ string response = greeter.greet(input);
389+ Assert.AreEqual("Hello World!", response);
390+ }
391+
392+ [Test]
393+ public void TestGreetValid() {
394+ Greeter greeter = new Greeter();
395+ Input input = new Input();
384396 input.name = "Dotnet";
385- string response = greeter.greet(input);
386- Assert.AreEqual("Hello Dotnet!", response);
387- }
388- }
397+ string response = greeter.greet(input);
398+ Assert.AreEqual("Hello Dotnet!", response);
399+ }
400+ }
389401}
390402```
391403
404+ 
405+ >```sh
406+ > echo ' {" name" :" Dotnet" }' | fn invoke dotnet-app dotnetfn
407+ >```
408+
409+ ```sh
410+ Hello Dotnet!
411+ ```
412+
392413## Invoke with Curl
393414
394415The other way to invoke your function is via HTTP. With the changes to the code,
0 commit comments