public void IndexTests() { //Arrange string Result = string.Empty; string ReseultWithParam = string.Empty; string stringName = "Jeff"; //Act Result = controller.Index(""); ReseultWithParam = controller.Index(stringName); //Assert Assert.AreEqual("Hello MVC!", Result); Assert.AreEqual($"Hello {stringName}", ReseultWithParam); }
public void Index() { // Arrange var controller = new HelloController(); // Act var result = controller.Index() as ViewResult; // Assert Assert.AreEqual("Hello MVC from Workflow", result.ViewBag.Greeting); }
public void Result() { // Arrange HelloController controller = new HelloController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.AreEqual("Access Denied", result.ViewBag.Result); }
public void Index() { // Arrange HelloController controller = new HelloController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); // add middleware for static files app.UseSession(); // app.UseMyCustomMiddleware(); app.Map("/mycontroller", app1 => { app1.Run(async context => { string name = context.Request.Query["name"]; HelloController controller = app1.ApplicationServices.GetService <HelloController>(); string result = controller.Index(name); await context.Response.WriteAsync(result); // TODO: encoding!! }); }); app.Map("/session", sessionApp => { sessionApp.Run(async context => { await SessionSample.SessionAsync(context); }); }); app.Map("/requestsample", app1 => { app1.Run(async(context) => { string result = string.Empty; switch (context.Request.Path.Value.ToLower()) { case "/header": result = RequestAndResponseSample.GetHeaderInformation(context.Request); break; case "/add": result = RequestAndResponseSample.QueryString(context.Request); break; case "/content": result = RequestAndResponseSample.Content(context.Request); break; case "/encoded": result = RequestAndResponseSample.ContentEncoded(context.Request); break; case "/form": result = RequestAndResponseSample.GetForm(context.Request); break; case "/writecookie": result = RequestAndResponseSample.WriteCookie(context.Response); break; case "/readcookie": result = RequestAndResponseSample.ReadCookie(context.Request); break; case "/json": result = RequestAndResponseSample.GetJson(context.Response); break; default: result = RequestAndResponseSample.GetRequestInformation(context.Request); break; } await context.Response.WriteAsync(result); }); }); app.Run(async(context) => { HttpRequest request = context.Request; await context.Response.WriteAsync("<h1>Hello World!</h1>"); }); }