public static IEnumerable <object[]> AddIbanNetNullTestCases() { IServiceCollection services = new ServiceCollection(); Action <IIbanNetOptionsBuilder> builder = _ => { }; return(new NullArgumentTestCases { // Instance DelegateTestCase.Create( ServiceCollectionExtensions.AddIbanNet, services), DelegateTestCase.Create( ServiceCollectionExtensions.AddIbanNet, services, true), DelegateTestCase.Create( ServiceCollectionExtensions.AddIbanNet, services, builder), DelegateTestCase.Create( ServiceCollectionExtensions.AddIbanNet, services, builder, true), }.Flatten()); }
public static IEnumerable <object[]> ResolvesSuccessfullyTestCases() { DependencyResolverAdapter instance = CreateAdapterStub(); yield return(DelegateTestCase.Create(instance.GetService, typeof(TestService)).WithoutName()); yield return(DelegateTestCase.Create(instance.GetRequiredService, typeof(TestService)).WithoutName()); yield return(DelegateTestCase.Create(instance.GetService <TestService>).WithoutName()); yield return(DelegateTestCase.Create(instance.GetRequiredService <TestService>).WithoutName()); }
public static IEnumerable <object[]> BuilderExtensionsWithoutBuilderInstance() { var instance = new MicrosoftDependencyInjectionIbanNetOptionsBuilder(new ServiceCollection()); return(new NullArgumentTestCases { // Instance DelegateTestCase.Create <Action <DependencyResolverAdapter, IbanValidatorOptions>, IIbanNetOptionsBuilder>( instance.Configure, (s, o) => { }), // Extensions DelegateTestCase.Create <IIbanNetOptionsBuilder, Func <IServiceProvider, TestValidationRule>, IIbanNetOptionsBuilder>( IbanNetOptionsBuilderExtensions.WithRule, instance, s => new TestValidationRule()), DelegateTestCase.Create <IIbanNetOptionsBuilder, Action <IServiceProvider, IbanValidatorOptions>, IIbanNetOptionsBuilder>( IbanNetOptionsBuilderExtensions.Configure, instance, (s, opts) => { }) }.Flatten()); }
public static IEnumerable <object[]> BuilderExtensionsWithoutBuilderInstance() { var instance = new AutofacIbanNetOptionsBuilder(new IbanNetModule(true)); return(new NullArgumentTestCases { // Instance DelegateTestCase.Create <Action <DependencyResolverAdapter, IbanValidatorOptions>, IIbanNetOptionsBuilder>( instance.Configure, (s, o) => { }), // Extensions DelegateTestCase.Create <IIbanNetOptionsBuilder, Func <IComponentContext, TestValidationRule>, IIbanNetOptionsBuilder>( IbanNetOptionsBuilderExtensions.WithRule, instance, s => new TestValidationRule()), DelegateTestCase.Create <IIbanNetOptionsBuilder, Action <IComponentContext, IbanValidatorOptions>, IIbanNetOptionsBuilder>( IbanNetOptionsBuilderExtensions.Configure, instance, (s, opts) => { }) }.Flatten()); }
public static IEnumerable <object[]> NullArgumentTestCases() { IIbanNetOptionsBuilder instance = GetBuilderStub(); return(new NullArgumentTestCases { DelegateTestCase.Create <IIbanNetOptionsBuilder, Action <IbanValidatorOptions>, IIbanNetOptionsBuilder>( IbanNetOptionsBuilderExtensions.Configure, instance, _ => { }), DelegateTestCase.Create( IbanNetOptionsBuilderExtensions.WithRule, instance, typeof(TestValidationRule)), DelegateTestCase.Create( IbanNetOptionsBuilderExtensions.UseRegistry, instance, Mock.Of <IIbanRegistry>()), DelegateTestCase.Create( IbanNetOptionsBuilderExtensions.UseRegistryProvider, instance, new IIbanRegistryProvider[0]), DelegateTestCase.Create( IbanNetOptionsBuilderExtensions.WithRule <TestValidationRule>, instance), DelegateTestCase.Create( IbanNetOptionsBuilderExtensions.UseStrictValidation, instance), DelegateTestCase.Create( IbanNetOptionsBuilderExtensions.UseLooseValidation, instance), DelegateTestCase.Create <IIbanNetOptionsBuilder, Func <TestValidationRule>, IIbanNetOptionsBuilder>( IbanNetOptionsBuilderExtensions.WithRule, instance, () => new TestValidationRule()) }.Flatten()); }
public static IEnumerable <object[]> NullArgumentTestCases() { var instance = new CorrelationManager( Mock.Of <ICorrelationContextFactory>(), Mock.Of <ICorrelationIdFactory>(), Mock.Of <ICorrelationContextAccessor>(), Mock.Of <ILogger <CorrelationManager> >() ); // ReSharper disable ConvertToLocalFunction Func <Task> correlatedTask = () => Task.CompletedTask; Func <Task <int> > returningCorrelatedTask = () => Task.FromResult(1); Action correlatedAction = () => { }; Func <int> returningCorrelatedAction = () => 1; // ReSharper restore ConvertToLocalFunction return(new[] { // Instance members DelegateTestCase.Create(instance.CorrelateAsync, (string)null, correlatedTask, (OnException)null), DelegateTestCase.Create(instance.CorrelateAsync, (string)null, returningCorrelatedTask, (OnException <int>)null), DelegateTestCase.Create(instance.Correlate, (string)null, correlatedAction, (OnException)null), DelegateTestCase.Create(instance.Correlate, (string)null, returningCorrelatedAction, (OnException <int>)null), // Extensions DelegateTestCase.Create(AsyncCorrelationManagerExtensions.CorrelateAsync, instance, correlatedTask), DelegateTestCase.Create(AsyncCorrelationManagerExtensions.CorrelateAsync, instance, returningCorrelatedTask), DelegateTestCase.Create(CorrelationManagerExtensions.Correlate, instance, correlatedAction), DelegateTestCase.Create(CorrelationManagerExtensions.Correlate, instance, returningCorrelatedAction), DelegateTestCase.Create(AsyncCorrelationManagerExtensions.CorrelateAsync, instance, correlatedTask, (OnException)null), DelegateTestCase.Create(AsyncCorrelationManagerExtensions.CorrelateAsync, instance, returningCorrelatedTask, (OnException <int>)null), DelegateTestCase.Create(CorrelationManagerExtensions.Correlate, instance, correlatedAction, (OnException)null), DelegateTestCase.Create(CorrelationManagerExtensions.Correlate, instance, returningCorrelatedAction, (OnException <int>)null), } .SelectMany(tc => tc.GetNullArgumentTestCases())); }
public static IEnumerable <object[]> TestCases() { var streamMock = new Mock <Stream> { CallBase = true }; streamMock.SetReturnsDefault(true); using var content = new StringContent(""); IResponds <IResponseResult> responds = Mock.Of <IResponds <IResponseResult> >(); DelegateTestCase[] testCases = { DelegateTestCase.Create <IResponds <IResponseResult>, Func <HttpResponseMessage>, IResponseResult>( IRespondsExtensions.Respond, responds, () => new HttpResponseMessage()), DelegateTestCase.Create <IResponds <IResponseResult>, Func <HttpRequestMessage, HttpResponseMessage>,IResponseResult>( IRespondsExtensions.Respond, responds, _ => new HttpResponseMessage()), DelegateTestCase.Create( IRespondsExtensions.RespondUsing <FakeResponseStrategy, IResponseResult>, responds), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, "test content"), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, "test content"), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, "test content", (string)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, "test content", (string)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, "test content", (MediaTypeHeaderValue)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, "test content", (MediaTypeHeaderValue)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, "test content", (Encoding)null, (string)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, "test content", (Encoding)null, (string)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, streamMock.Object), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, streamMock.Object, (string)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, streamMock.Object), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, streamMock.Object, (string)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, streamMock.Object, (MediaTypeHeaderValue)null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, streamMock.Object, (MediaTypeHeaderValue)null), DelegateTestCase.Create <IResponds <IResponseResult>, HttpStatusCode, Func <Stream>, MediaTypeHeaderValue, IResponseResult>( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, () => streamMock.Object, null), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, content), DelegateTestCase.Create( IRespondsExtensions.Respond, responds, HttpStatusCode.OK, content), DelegateTestCase.Create( IRespondsExtensions.TimesOut, responds), DelegateTestCase.Create( IRespondsExtensions.TimesOutAfter, responds, 1), DelegateTestCase.Create( IRespondsExtensions.TimesOutAfter, responds, TimeSpan.FromMilliseconds(1)), }; return(testCases.SelectMany(tc => tc.GetNullArgumentTestCases())); }
public static IEnumerable <object[]> TestCases() { var streamMock = new Mock <Stream> { CallBase = true }; streamMock.SetReturnsDefault(true); Uri uri = new Uri("http://0.0.0.0"); var instance = new RequestMatching(); DelegateTestCase[] testCases = { DelegateTestCase.Create( RequestMatchingExtensions.RequestUri, instance, uri.ToString()), DelegateTestCase.Create( RequestMatchingExtensions.RequestUri, instance, uri), DelegateTestCase.Create( RequestMatchingExtensions.QueryString, instance, "key", (string)null), DelegateTestCase.Create( RequestMatchingExtensions.QueryString, instance, "key", (IEnumerable <string>)null), DelegateTestCase.Create( RequestMatchingExtensions.QueryString, instance, "key", (string[])null), DelegateTestCase.Create( RequestMatchingExtensions.QueryString, instance, new Dictionary <string, IEnumerable <string> >()), #if !NETCOREAPP1_1 DelegateTestCase.Create( RequestMatchingExtensions.QueryString, instance, new NameValueCollection()), #endif DelegateTestCase.Create( RequestMatchingExtensions.QueryString, instance, "?test"), DelegateTestCase.Create( RequestMatchingExtensions.WithoutQueryString, instance), DelegateTestCase.Create( RequestMatchingExtensions.Method, instance, "GET"), DelegateTestCase.Create( RequestMatchingExtensions.Method, instance, HttpMethod.Get), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", (string)null, false), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", 1), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", true), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", DateTime.Now), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", DateTimeOffset.Now), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", Enumerable.Empty <string>()), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header"), DelegateTestCase.Create( RequestMatchingExtensions.Header, instance, "header", new string[0]), DelegateTestCase.Create( RequestMatchingExtensions.Headers, instance, "header: value"), DelegateTestCase.Create( RequestMatchingExtensions.Headers, instance, new Dictionary <string, string>()), DelegateTestCase.Create( RequestMatchingExtensions.Headers, instance, new Dictionary <string, IEnumerable <string> >()), DelegateTestCase.Create( RequestMatchingExtensions.ContentType, instance, "text/plain"), DelegateTestCase.Create( RequestMatchingExtensions.ContentType, instance, "text/plain", Encoding.UTF8), DelegateTestCase.Create( RequestMatchingExtensions.ContentType, instance, new MediaTypeHeaderValue("text/plain")), DelegateTestCase.Create( RequestMatchingExtensions.FormData, instance, "key", (string)null), DelegateTestCase.Create( RequestMatchingExtensions.FormData, instance, new Dictionary <string, string>()), #if !NETCOREAPP1_1 DelegateTestCase.Create( RequestMatchingExtensions.FormData, instance, new NameValueCollection()), #endif DelegateTestCase.Create( RequestMatchingExtensions.FormData, instance, new Dictionary <string, IEnumerable <string> >()), DelegateTestCase.Create( RequestMatchingExtensions.FormData, instance, "key=value"), DelegateTestCase.Create( RequestMatchingExtensions.Content, instance, "content"), DelegateTestCase.Create( RequestMatchingExtensions.Content, instance, "content", (Encoding)null), DelegateTestCase.Create( RequestMatchingExtensions.Content, instance, Encoding.UTF8.GetBytes("content")), DelegateTestCase.Create( RequestMatchingExtensions.Content, instance, streamMock.Object), DelegateTestCase.Create( RequestMatchingExtensions.WithoutContent, instance), DelegateTestCase.Create( RequestMatchingExtensions.PartialContent, instance, "partial content"), DelegateTestCase.Create( RequestMatchingExtensions.PartialContent, instance, "partial content", (Encoding)null), DelegateTestCase.Create( RequestMatchingExtensions.PartialContent, instance, Encoding.UTF8.GetBytes("partial content")), DelegateTestCase.Create( RequestMatchingExtensions.PartialContent, instance, streamMock.Object), DelegateTestCase.Create <RequestMatching, Action <RequestMatching>, RequestMatching>( RequestMatchingExtensions.Any, instance, _ => { }), DelegateTestCase.Create <RequestMatching, Expression <Func <HttpRequestMessage, bool> >, RequestMatching>( RequestMatchingExtensions.Where, instance, _ => true), DelegateTestCase.Create( RequestMatchingExtensions.Version, instance, "1.0"), DelegateTestCase.Create( RequestMatchingExtensions.Version, instance, System.Version.Parse("1.0")) }; return(testCases.SelectMany(tc => tc.GetNullArgumentTestCases())); }