public void FluentControllerBuilder_FluentActionWithDoAndNoReturnThrows() { Assert.Throws <FluentActionValidationException>(() => BuilderTestUtils.BuildAction( new FluentAction("/route/url", HttpMethod.Get) .Do(() => Console.WriteLine("foo")))); }
public void FluentControllerBuilder_FluentActionUsing2FormFilesReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .UsingFormFiles("files") .To(async files => { await Task.Delay(1); return($"Got {files.Count()} n.o. files!"); }), typeof(ControllerWith2FormFilesReturnsStringAsync)); }
public void FluentControllerBuilder_FluentActionUsing2FormFilesReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .UsingFormFiles("files") .To(files => $"Got {files.Count()} n.o. files!"), typeof(ControllerWith2FormFilesReturnsString)); }
public void FluentControllerBuilder_FluentActionUsingFormFileReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .UsingFormFile("file") .To(async file => { await Task.Delay(1); return($"Got file with name {file.FileName}!"); }), typeof(ControllerWithFormFileReturnsStringAsync)); }
public void FluentControllerBuilder_FluentActionUsingFormFileReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .UsingFormFile("file") .To(file => $"Got file with name {file.FileName}!"), typeof(ControllerWithFormFileReturnsString)); }
public void FluentControllerBuilder_FluentActionWithAntiForgeryTokenReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .ValidateAntiForgeryToken() .To(async() => { await Task.Delay(1); return($"Hello World!"); }), typeof(ControllerWithAntiForgeryTokenReturnsStringAsync)); }
public void FluentControllerBuilder_FluentActionNoUsingsNoToReturnsPartialView() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .ToPartialView("~/Path/To/PartialViewWithoutModel.cshtml"), typeof(ControllerWithNoUsingsNoToReturnsPartialView), null); }
public void FluentControllerBuilder_FluentActionForReadMeExample1() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/", HttpMethod.Get) .To(() => "Hello World!"), typeof(ControllerForReadMeExample1), null); }
public void FluentControllerBuilder_FluentActionWithModelStateReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .UsingModelState() .To(modelState => $"Hello World!"), typeof(ControllerWithModelStateReturnsString)); }
public void FluentControllerBuilder_FluentActionWithoutUsingsAndReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(() => "Hello"), typeof(ParameterlessControllerReturnsString), null); }
public void FluentControllerBuilder_FluentActionWithAntiForgeryTokenReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .ValidateAntiForgeryToken() .To(() => $"Hello World!"), typeof(ControllerWithAntiForgeryTokenReturnsString)); }
public void FluentControllerBuilder_FluentActionNoUsingsNoToReturnsViewComponentUsingType() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .ToViewComponent(typeof(ViewComponentWithoutModel)), typeof(ControllerWithNoUsingsNoToReturnsViewComponentUsingType), null); }
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_FluentActionWithoutUsingsAndReturnsEnum() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .To(() => ExampleEnumWithoutUsings.ExampleEnumValue2), typeof(ParameterlessControllerReturnsEnum), 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_FluentActionWithModelStateReturnsStringAsync() { BuilderTestUtils.BuildActionAndCompareToStaticAction( new FluentAction("/route/url", HttpMethod.Post) .UsingModelState() .To(async modelState => { await Task.Delay(1); return($"Hello World!"); }), typeof(ControllerWithModelStateReturnsStringAsync)); }
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_FluentActionOrderTestDoThrows() { Assert.Throws <FluentActionValidationException>(() => { BuilderTestUtils.BuildAction( new FluentAction("/route/url", HttpMethod.Get) .Do(() => { /* woop woop */ }), TestLogger); }); }
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_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_FluentActionWith1EmptyCustomAttributeReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .WithCustomAttribute <MyCustomAttribute>() .To(() => "hello"), typeof(ControllerWith1EmptyCustomAttributeReturnsString), null); }
public void FluentControllerBuilder_FluentActionWithGroupBy() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .GroupBy("CustomGroupName") .To(() => "Hello"), typeof(ControllerWithGroupNameOnlyApiExplorerSettingsAttribute), new object[0]); }
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_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_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_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_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_FluentActionWith1AllowAnonymousReturnsString() { BuilderTestUtils.BuildActionAndCompareToStaticActionWithResult( new FluentAction("/route/url", HttpMethod.Get) .AllowAnonymous() .To(() => "hello"), typeof(ControllerWith1AllowAnonymousReturnsString), null); }
public void FluentControllerBuilder_FluentActionOrderTestDoAThrows() { Assert.Throws <FluentActionValidationException>(() => { BuilderTestUtils.BuildAction( new FluentAction("/route/url", HttpMethod.Get) .DoAsync(async() => { await Task.Delay(1); }), TestLogger); }); }