本文整理汇总了C#中System.ArgumentNullException类的典型用法代码示例。如果您正苦于以下问题:C# ArgumentNullException类的具体用法?C# ArgumentNullException怎么用?C# ArgumentNullException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArgumentNullException类属于System命名空间,在下文中一共展示了ArgumentNullException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Verify_ExceptionThrownAndMessageContainsExpectedStrng_DoesnThrowExpection
public void Verify_ExceptionThrownAndMessageContainsExpectedStrng_DoesnThrowExpection()
{
var constraint = CreateConstraint(typeof(ArgumentNullException), "argument1");
var actualException = new ArgumentNullException("argument1");
constraint.Verify(actualException);
}
示例2: ActivateOptionsTestLogFolderSet
public void ActivateOptionsTestLogFolderSet()
{
string tempPath = Path.Combine(System.IO.Path.GetTempPath() + "foobar");
if (Directory.Exists(tempPath))
{
Directory.Delete(tempPath, true);
}
LogExceptionToFileFilter filter = new LogExceptionToFileFilter();
filter.ExceptionLogFolder = tempPath;
filter.ActivateOptions();
var exception = new ArgumentNullException();
ILoggerRepository logRepository = Substitute.For<ILoggerRepository>();
var evt = new LoggingEvent(typeof(LogExceptionToFileFilterTests), logRepository, "test logger", Level.Debug, "test message", exception);
var filterResult = filter.Decide(evt);
Assert.AreEqual(FilterDecision.Neutral, filterResult);
Assert.IsTrue(evt.Properties.Contains("log4net:syslog-exception-log"), "has an exception log param");
Assert.IsTrue(Directory.Exists(tempPath));
Assert.IsTrue(File.Exists(evt.Properties["log4net:syslog-exception-log"].ToString()), "exception file exists");
Directory.Delete(tempPath, true);
}
示例3: TestBackupRestoreCallbackExceptionHandling
public void TestBackupRestoreCallbackExceptionHandling()
{
var ex = new ArgumentNullException();
var test = new DatabaseFileTestHelper("database", "backup", true);
Assert.Inconclusive("ESENT bug means instance isn't torn down correctly");
test.TestRestoreCallbackExceptionHandling(ex);
}
示例4: Verify_ExceptionThrownMessageDoesntContainExpectedString_ThrowsException
public void Verify_ExceptionThrownMessageDoesntContainExpectedString_ThrowsException()
{
var constraint = CreateConstraint(typeof(ArgumentNullException), "argument1");
var actualException = new ArgumentNullException("argument52");
NUnit.Framework.Assert.Throws<AssertFailedException>(() => constraint.Verify(actualException));
}
示例5: Authenticate
public HttpResponseMessage Authenticate([FromBody] SystemUser user)
{
if (user == null)
{
var ex = new ArgumentNullException("user");
return Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
}
if ((user = SystemUser.Authenticate(user.Username, user.Password)) != null)
{
var authUser = new SystemUser
{
Id = user.Id,
Username = user.Username,
};
authUser.GenerateAuthToken();
ApplicationContext.AddAuthenticatedUser(authUser);
return Request.CreateResponse(HttpStatusCode.OK, authUser);
}
else
{
return Request.CreateResponse(HttpStatusCode.Forbidden);
}
}
示例6: AcquireTokenHandlerBase
protected AcquireTokenHandlerBase(Authenticator authenticator, TokenCache tokenCache, string resource, ClientKey clientKey, TokenSubjectType subjectType, bool callSync)
{
this.Authenticator = authenticator;
this.CallState = CreateCallState(this.Authenticator.CorrelationId, callSync);
Logger.Information(this.CallState,
string.Format("=== Token Acquisition started:\n\tAuthority: {0}\n\tResource: {1}\n\tClientId: {2}\n\tCacheType: {3}\n\tAuthentication Target: {4}\n\t",
authenticator.Authority, resource, clientKey.ClientId,
(tokenCache != null) ? tokenCache.GetType().FullName + string.Format(" ({0} items)", tokenCache.Count) : "null",
subjectType));
this.tokenCache = tokenCache;
if (string.IsNullOrWhiteSpace(resource))
{
var ex = new ArgumentNullException("resource");
Logger.Error(this.CallState, ex);
throw ex;
}
this.Resource = (resource != NullResource) ? resource : null;
this.ClientKey = clientKey;
this.TokenSubjectType = subjectType;
this.LoadFromCache = (tokenCache != null);
this.StoreToCache = (tokenCache != null);
this.SupportADFS = false;
}
开发者ID:ankurchoubeymsft,项目名称:azure-activedirectory-library-for-dotnet,代码行数:27,代码来源:AcquireTokenHandlerBase.cs
示例7: Constructor_StoresException
public void Constructor_StoresException()
{
var exception = new ArgumentNullException("foo");
var poison = new Poison<int>(42, exception);
Assert.Equal(new ExceptionDetails(exception), poison.Exception, GenericEqualityComparer<ExceptionDetails>.ByAllMembers());
}
示例8: ExceptionMessages_are_concatenated_by_GetSafeMessage
public void ExceptionMessages_are_concatenated_by_GetSafeMessage()
{
var inner = new InvalidOperationException();
var outer = new ArgumentNullException("Eine Message", inner);
Assert.Equal(outer.Message + " ---> " + inner.Message, outer.GetSafeMessage());
}
示例9: ConstructorTestFailedNoLanguage
public void ConstructorTestFailedNoLanguage()
{
ArgumentNullException expected = new ArgumentNullException("language", "Provided language must not be null or empty.");
ArgumentNullException actual = Assert.Throws<ArgumentNullException>(() => new SeriesDetails(this.testExtractionPath, string.Empty));
Assert.Equal(expected.Message, actual.Message);
}
示例10: Arrange
internal void Arrange()
{
try
{
this.AppointmentGroups.ToDictionary(ag => ag.GroupId);
}
catch (ArgumentNullException ane)
{
ArgumentNullException ex = new ArgumentNullException(EX_ANEMSG, ane);
throw ex;
}
catch (ArgumentException ae)
{
ArgumentException ex = new ArgumentException(EX_AEMSG, "AppointmentGroups", ae);
throw ex;
}
foreach (var group in this.AppointmentGroups)
{
var movedItem = group.Where(a => a.GroupId != group.GroupId).FirstOrDefault();
if (movedItem != default(Appointment))
{
group.Remove(movedItem);
this.AppointmentGroups.Where(g => g.GroupId == movedItem.GroupId).First().Add(movedItem);
}
}
}
示例11: BuildExceptionStringMessageTest
public void BuildExceptionStringMessageTest()
{
var ex = new ArgumentNullException("", "fakeMessage") { Source = "fakeSource" };
var expected = "<strong>myMessage</strong><br /><br /><strong>fakeMessage</strong><br /><br />";
Assert.AreEqual(expected, ExceptionsHelper.BuildExceptionString(ex, "myMessage"));
}
示例12: ConstructorWithParamNameWorks
public void ConstructorWithParamNameWorks() {
var ex = new ArgumentNullException("someParam");
Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentNullException");
Assert.AreEqual(ex.ParamName, "someParam", "ParamName");
Assert.IsTrue(ex.InnerException == null, "InnerException");
Assert.AreEqual(ex.Message, "Value cannot be null.\nParameter name: someParam");
}
示例13: ConstructorWithParamNameAndMessageWorks
public void ConstructorWithParamNameAndMessageWorks() {
var ex = new ArgumentNullException("someParam", "The message");
Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentNullException");
Assert.AreEqual(ex.ParamName, "someParam", "ParamName");
Assert.IsTrue(ex.InnerException == null, "InnerException");
Assert.AreEqual(ex.Message, "The message");
}
示例14: LoadAssembly
public static Assembly LoadAssembly(string assemblyPath)
{
Assembly assembly = null;
try
{
if (WzdUtils.FAddIn == null)
{
ArgumentNullException exception = new ArgumentNullException("WzdUtils.FAddIn");
WzdUtils.Application_ThreadException(null, new ThreadExceptionEventArgs(exception));
}
else
{
string path = WzdUtils.GetServerPath(WzdUtils.FAddIn, true);
path = path.Remove(path.LastIndexOf('\\')) + assemblyPath;
String fullDllName = path;
buffer = System.IO.File.ReadAllBytes(fullDllName);
assembly = Assembly.Load(buffer);
}
}
catch (Exception ex)
{
WzdUtils.Application_ThreadException(null, new ThreadExceptionEventArgs(ex));
}
return assembly;
}
示例15: DefaultConstructorWorks
public void DefaultConstructorWorks() {
var ex = new ArgumentNullException();
Assert.IsTrue((object)ex is ArgumentNullException, "is ArgumentNullException");
Assert.IsTrue(ex.ParamName == null, "ParamName");
Assert.IsTrue(ex.InnerException == null, "InnerException");
Assert.AreEqual(ex.Message, "Value cannot be null.");
}