public void FluentControllerBuilder_FluentActionWithoutUsingsAndReturnsEnumAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(async() => { await Task.Delay(1); return(ExampleEnumWithoutUsings.ExampleEnumValue2); }), typeof(ParameterlessControllerReturnsEnumAsync), null); }
public void FluentControllerBuilder_FluentActionNoUsingsNoToReturnsPartialView() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .ToPartialView("~/Path/To/PartialViewWithoutModel.cshtml"), typeof(ControllerWithNoUsingsNoToReturnsPartialView), null); }
public void FluentControllerBuilder_FluentActionNoUsingsNoToReturnsViewComponentUsingType() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .ToViewComponent(typeof(ViewComponentWithoutModel)), typeof(ControllerWithNoUsingsNoToReturnsViewComponentUsingType), null); }
public void FluentControllerBuilder_FluentActionForReadMeExample1() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/", HttpMethod.Get) .To(() => "Hello World!"), typeof(ControllerForReadMeExample1), null); }
public void FluentControllerBuilder_FluentActionWithoutUsingsAndReturnsGuidAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(async() => { await Task.Delay(1); return(new Guid("2a6d4959-817c-4514-90f3-52b518e9ddb0")); }), typeof(ParameterlessControllerReturnsGuidAsync), null); }
public void FluentControllerBuilder_FluentActionWithoutUsingsAndReturnsEnum() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(() => ExampleEnumWithoutUsings.ExampleEnumValue2), typeof(ParameterlessControllerReturnsEnum), null); }
public void FluentControllerBuilder_FluentActionWithoutUsingsAndReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(() => "Hello"), typeof(ParameterlessControllerReturnsString), null); }
public void FluentControllerBuilder_FluentActionWith1PropertyCustomAttributeReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .WithCustomAttribute <MyCustomAttribute>(new Type[0], new object[0], new string[] { "Property" }, new object[] { "prop" }) .To(() => "hello"), typeof(ControllerWith1PropertyCustomAttributeReturnsString), null); }
public void FluentControllerBuilder_FluentActionWith1ConstructorCustomAttributeReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .WithCustomAttribute <MyCustomAttribute>(new Type[] { typeof(int) }, new object[] { 10 }) .To(() => "hello"), typeof(ControllerWith1ConstructorCustomAttributeReturnsString), null); }
public void FluentControllerBuilder_FluentActionWith1EmptyCustomAttributeReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .WithCustomAttribute <MyCustomAttribute>() .To(() => "hello"), typeof(ControllerWith1EmptyCustomAttributeReturnsString), null); }
public void FluentControllerBuilder_FluentActionWith1AllowAnonymousReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .AllowAnonymous() .To(() => "hello"), typeof(ControllerWith1AllowAnonymousReturnsString), null); }
public void FluentControllerBuilder_FluentActionNoUsings1ToReturnsViewComponent() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(() => "Hello World!") .ToViewComponent("ViewComponentWithStringModel"), typeof(ControllerWithNoUsingsXToReturnsViewComponent), null); }
public void FluentControllerBuilder_FluentAction1BodyNoToReturnsPartialView() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingBody <string>() .ToPartialView("~/Path/To/PartialViewWithStringModel.cshtml"), typeof(ControllerPassing1BodyReturnsPartialView), new object[] { "Text" }); }
public void FluentControllerBuilder_FluentActionUsingFormValueWithUsedDefaultValueReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingFormValue <string>("name", "Hanzel") .To(name => $"Hello {name}!"), typeof(ControllerWithFormValueAndDefaultValueReturnsString), new object[] { Type.Missing }); }
public void FluentControllerBuilder_FluentActionUsingBodyWithUnusedDefaultValueReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingBody <string>("Hanzel") .To(name => $"Hello {name}!"), typeof(ControllerWithBodyAndDefaultValueReturnsString), new object[] { "Charlie" }); }
public void FluentControllerBuilder_FluentActionUsingServiceReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingService <IStringTestService>() .To(async stringTestService => await stringTestService.GetTestStringAsync() + "FromAFluentAction"), typeof(ControllerWithStringServiceAsync), new object[] { new StringTestService() }); }
public void FluentControllerBuilder_FluentActionUsingModelBinderWithUsedDefaultValueReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingModelBinder <string>(typeof(NoOpBinder), null, "Hanzel") .To(async name => { await Task.Delay(1); return($"Hello {name}!"); }), typeof(ControllerWithModelBinderAndDefaultValueReturnsStringAsync), new object[] { Type.Missing }); }
public void FluentControllerBuilder_FluentActionUsingModelBinderWithNamePropertyReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingModelBinder <string>(typeof(NoOpBinder), "NoOpName2") .To(async name => { await Task.Delay(1); return($"Hello {name}!"); }), typeof(ControllerWithModelBinderAndNamePropertyReturnsStringAsync), new object[] { "Charlie" }); }
public void FluentControllerBuilder_FluentActionUsingModelBinderReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingModelBinder <string>(typeof(NoOpBinder)) .To(name => $"Hello {name}!"), typeof(ControllerWithModelBinderReturnsString), new object[] { "Charlie" }); }
public void FluentControllerBuilder_FluentActionNoUsings1ToReturnsViewAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(async() => { await Task.Delay(1); return("Hello World!"); }) .ToView("~/Path/To/ViewWithStringModel.cshtml"), typeof(ControllerWithNoUsingsXToReturnsViewAsync), null); }
public void FluentControllerBuilder_FluentActionUsingRouteParmeterReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/{name}", HttpMethod.Get) .UsingRouteParameter <string>("name") .To(async name => { await Task.Delay(1); return($"Hello {name}!"); }), typeof(ControllerWithRouteParameterReturnsStringAsync), new object[] { "Charlie" }); }
public void FluentControllerBuilder_FluentActionNoUsings1DoReturnsViewComponent() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .Do(() => { /* woop woop */ }) .ToViewComponent("ViewComponentWithoutModel"), typeof(ControllerWithNoUsingsXDoReturnsViewComponent), null); }
public void FluentControllerBuilder_FluentActionUsingServiceReturnsListOfUsersAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingService <IUserService>() .To(userService => userService.ListUsersAsync()), typeof(ControllerWithUserServiceAsync), new object[] { new UserService() }); }
public void FluentControllerBuilder_FluentActionWith1AuthorizeClassRolesReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .AuthorizeClass(roles: "Admin") .To(() => "hello"), typeof(ControllerWith1AuthorizeClassRolesReturnsString), null); }
public void FluentControllerBuilder_FluentActionNoUsings1DoReturnsPartialViewAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .DoAsync(async() => { await Task.Delay(1); }) .ToPartialView("~/Path/To/PartialViewWithoutModel.cshtml"), typeof(ControllerWithNoUsingsXDoReturnsPartialViewAsync), null); }
public void FluentControllerBuilder_FluentActionWith1AuthorizePolicyRolesAuthenticationSchemesReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .Authorize("CanSayHello", "Admin", "Scheme") .To(() => "hello"), typeof(ControllerWith1AuthorizePolicyRolesAuthenticationSchemesReturnsString), null); }
public void FluentControllerBuilder_FluentActionUsingFormValueWithUnusedDefaultValueReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingFormValue <string>("name", "Hanzel") .To(async name => { await Task.Delay(1); return($"Hello {name}!"); }), typeof(ControllerWithFormValueAndDefaultValueReturnsStringAsync), new object[] { "Charlie" }); }
public void FluentControllerBuilder_FluentActionWithGroupBy() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .GroupBy("CustomGroupName") .To(() => "Hello"), typeof(ControllerWithGroupNameOnlyApiExplorerSettingsAttribute), new object[0]); }
public void FluentControllerBuilder_FluentActionWithParentTypeReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .InheritingFrom <BaseController>() .To(() => $"hello"), typeof(ControllerWithParentTypeReturnsString), null); }
public void FluentControllerBuilder_FluentAction1BodyNoToReturnsViewComponent() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .UsingBody <string>() .ToViewComponent("ViewComponentWithStringModel"), typeof(ControllerPassing1BodyReturnsViewComponent), new object[] { "Text" }); }