コード例 #1
0
 public void Test200()
 {
     Should.Throw <ArgumentNullException>(() => JsRuntimeAssertExtensions.ShouldBeElementReferenceTo(null !, null !))
     .ParamName.ShouldBe("actualArgument");
     Should.Throw <ArgumentNullException>(() => JsRuntimeAssertExtensions.ShouldBeElementReferenceTo(string.Empty, null !))
     .ParamName.ShouldBe("expectedTargetElement");
 }
コード例 #2
0
        [PreventExecutionContextLeaks] // Workaround for https://github.com/nunit/nunit/issues/3283
        public static void Passed_synchronization_context_may_not_be_null([Values] PostOverload overload)
        {
            switch (overload)
            {
            case PostOverload.Action:
                Should.Throw <ArgumentNullException>(
                    () => AmbientTasks.Post(synchronizationContext: null !, (Action?)null))
                .ParamName.ShouldBe("synchronizationContext");
                break;

            case PostOverload.SendOrPostCallback:
                Should.Throw <ArgumentNullException>(
                    () => AmbientTasks.Post(synchronizationContext: null !, null, state: null))
                .ParamName.ShouldBe("synchronizationContext");
                break;

            case PostOverload.AsyncAction:
                Should.Throw <ArgumentNullException>(
                    () => AmbientTasks.Post(synchronizationContext: null !, (Func <Task>?)null))
                .ParamName.ShouldBe("synchronizationContext");
                break;

            default:
                throw new NotImplementedException();
            }
        }
コード例 #3
0
        public static void ParametersAreCheckedForNull()
        {
            // Arrange
            IServiceCollection?services = new ServiceCollection();
            Func <IServiceProvider, StatsDConfiguration>?configurationFactory = null;
            string?host = null;

            // Act and Assert
            Should.Throw <ArgumentNullException>(() => services.AddStatsD(configurationFactory !)).ParamName.ShouldBe("configurationFactory");
            Should.Throw <ArgumentNullException>(() => services.AddStatsD(host !)).ParamName.ShouldBe("host");

            // Arrange
            services = null;

            // Act and Assert
            Should.Throw <ArgumentNullException>(() => services !.AddStatsD(configurationFactory !)).ParamName.ShouldBe("services");
            Should.Throw <ArgumentNullException>(() => services !.AddStatsD(host !)).ParamName.ShouldBe("services");
        }
コード例 #4
0
 public void Should_Throw_If_Null()
 {
     Should.Throw <ArgumentNullException>(() => new Scoped <int>(null !)).ParamName.ShouldBe("scopeFactory");
 }
コード例 #5
0
 public void ConvertTo_NullDestinationType_ThrowsNullArgument()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           Sut.ConvertTo(null, CultureInfo.InvariantCulture, BooleanEnumeration.False, destinationType: null !))
     .ParamName.ShouldBe("destinationType");
 }
コード例 #6
0
 public void TimerShouldThrowExceptionOnCreatingWithNullOnTick()
 {
     Should.Throw <ArgumentNullException>(() => new PortableTimer(null !))
     .ParamName.ShouldBe("onTick");
 }
コード例 #7
0
 public void Test002()
 {
     Should.Throw <ArgumentNullException>(() => DiffBuilder.Compare(null !)).ParamName.ShouldBe(nameof(DiffBuilder.Control));
     Should.Throw <ArgumentNullException>(() => DiffBuilder.Compare("").WithTest(null !)).ParamName.ShouldBe(nameof(DiffBuilder.Test));
 }
コード例 #8
0
 public void ConvertToNullDestinationType_ThrowsArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           Sut.ConvertTo(null, CultureInfo.InvariantCulture, new DateTime(1970, 6, 3), null !))
     .ParamName.ShouldBe("destinationType");
 }
 public static void GetDisplayName_Throws_If_Value_Is_Null()
 {
     Assert.Throws <ArgumentNullException>(() => ClaimsPrincipalExtensions.GetDisplayName(null !)).ParamName.ShouldBe("value");
 }
 public static void GetAvatarUrl_Throws_If_Required_Parameters_Are_Null()
 {
     Assert.Throws <ArgumentNullException>(() => ClaimsPrincipalExtensions.GetAvatarUrl(null !, string.Empty)).ParamName.ShouldBe("value");
     Assert.Throws <ArgumentNullException>(() => ClaimsPrincipalExtensions.GetAvatarUrl(new ClaimsPrincipal(), null !)).ParamName.ShouldBe("fallbackImageUrl");
 }