Advertisement
ivaylokenov

Untitled

Nov 18th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. [Theory]
  2. [InlineData("Test Article", "Test Article Content")]
  3. public void PostCreateShouldBeRoutedCorrectly(string title, string content)
  4.     => MyRouting                                                   // Start a route test.
  5.         .Configuration()                                           // Use the globally registered configuration.
  6.         .ShouldMap(request => request                              // Provide the request data.
  7.             .WithMethod(HttpMethod.Post)                           // Set the method of the request.
  8.             .WithLocation("/Articles/Create")                      // Set the URL of the Post request.
  9.             .WithFormFields(new                                    // Add form field data to the request.
  10.             {
  11.                 Title = title,
  12.                 Content = content
  13.             })
  14.             .WithUser()                                            // Specify that the route needs an authenticated user.
  15.             .WithAntiForgeryToken())                               // Add an Anti-Forgery token, if needed.
  16.         .To<ArticlesController>(c => c.Create(new ArticleFormModel // Map the route to the specific route values.
  17.         {
  18.             Title = title,
  19.             Content = content
  20.         }));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement