<Rule Id="xUnit2009" Action="None" />
<Rule Id="xUnit2012" Action="None" />
<Rule Id="xUnit2013" Action="None" />
- <Rule Id="xUnit2015" Action="None" />
<Rule Id="xUnit2017" Action="None" />
<Rule Id="xUnit2018" Action="None" />
</Rules>
var builder = ImmutableArray.CreateBuilder<int>(initialCapacity: 10);
builder.Add(1);
builder.Add(1);
- Assert.Throws(typeof(ArgumentException), () => builder.Capacity = 1);
+ Assert.Throws<ArgumentException>(() => builder.Capacity = 1);
}
[Fact]
eventDescriptor.RemoveEventHandler(component, eventHandler);
// component.Event should now have no handler => raising it should throw a NullReferenceException
- Assert.Throws(typeof(NullReferenceException), () => component.RaiseEvent());
+ Assert.Throws<NullReferenceException>(() => component.RaiseEvent());
}
[Fact]
private const int DEFAULT_VALUE = 0;
private const int BAD_VALUE = -1;
- #region Test Cases
-
[ConditionalFact(nameof(HasOneSerialPort))]
public void SetLength_Open_Close()
{
Debug.WriteLine("Verifying SetLength property throws exception After Open() then Close()");
- Assert.Throws(typeof(NotSupportedException), () => serialStream.SetLength(DEFAULT_VALUE));
+ Assert.Throws<NotSupportedException>(() => serialStream.SetLength(DEFAULT_VALUE));
}
}
Debug.WriteLine("Verifying SetLength property throws exception After Open() then BaseStream.Close()");
- Assert.Throws(typeof(NotSupportedException), () => serialStream.SetLength(DEFAULT_VALUE));
+ Assert.Throws<NotSupportedException>(() => serialStream.SetLength(DEFAULT_VALUE));
}
}
com.Open();
Debug.WriteLine("Verifying SetLength method throws exception after a call to Open()");
- Assert.Throws(typeof(NotSupportedException), () => com.BaseStream.SetLength(DEFAULT_VALUE));
+ Assert.Throws<NotSupportedException>(() => com.BaseStream.SetLength(DEFAULT_VALUE));
}
}
Debug.WriteLine("Verifying SetLength method throws exception with a bad value after a call to Open()");
- Assert.Throws(typeof(NotSupportedException), () => com.BaseStream.SetLength(BAD_VALUE));
+ Assert.Throws<NotSupportedException>(() => com.BaseStream.SetLength(BAD_VALUE));
}
}
-
- #endregion
-
- #region Verification for Test Cases
-
- #endregion
}
}
\ No newline at end of file
[Fact]
public static void GetAssemblyNameTest_AssemblyNotFound()
{
- Assert.Throws(typeof(FileNotFoundException),
- () => AssemblyLoadContext.GetAssemblyName("Non.Existing.Assembly.dll"));
+ Assert.Throws<FileNotFoundException>(() => AssemblyLoadContext.GetAssemblyName("Non.Existing.Assembly.dll"));
}
[Fact]
public static void GetAssemblyNameTest_NullParameter()
{
- Assert.Throws(typeof(ArgumentNullException),
- () => AssemblyLoadContext.GetAssemblyName(null));
+ Assert.Throws<ArgumentNullException>(() => AssemblyLoadContext.GetAssemblyName(null));
}
[Fact]
var loadContext = new ResourceAssemblyLoadContext();
loadContext.LoadBy = LoadBy.Path;
- Assert.Throws(typeof(FileNotFoundException),
- () => loadContext.LoadFromAssemblyName(asmName));
+ Assert.Throws<FileNotFoundException>(() => loadContext.LoadFromAssemblyName(asmName));
}
[Fact]
var assemblyName = new AssemblyName(TestAssemblyName);
// By default, the assembly should not be found in DefaultContext at all
- Assert.Throws(typeof(FileNotFoundException), () => Assembly.Load(assemblyName));
+ Assert.Throws<FileNotFoundException>(() => Assembly.Load(assemblyName));
// Create a secondary load context and wireup its resolving event
SecondaryLoadContext slc = new SecondaryLoadContext();
public static void LoadNonExistentInDefaultContext()
{
// Now, try to load an assembly that does not exist
- Assert.Throws(typeof(FileNotFoundException),
- () => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName("System.Runtime.Loader.NonExistent.Assembly")));
+ Assert.Throws<FileNotFoundException>(() => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName("System.Runtime.Loader.NonExistent.Assembly")));
}
private void DefaultContextFallback()
string file = "TestFeeds/FailureFeeds/diff_atom_ns.xml";
using (XmlReader reader = XmlReader.Create(file))
{
- Assert.Throws(typeof(XmlException), () => { SyndicationItem.Load(reader); });
+ Assert.Throws<XmlException>(() => { SyndicationItem.Load(reader); });
}
}
string file = "TestFeeds/FailureFeeds/diff_rss_ns.xml";
using (XmlReader reader = XmlReader.Create(file))
{
- Assert.Throws(typeof(XmlException), () => { SyndicationItem.Load(reader); });
+ Assert.Throws<XmlException>(() => { SyndicationItem.Load(reader); });
}
}
string file = "TestFeeds/FailureFeeds/diff_rss_version.xml";
using (XmlReader reader = XmlReader.Create(file))
{
- Assert.Throws(typeof(XmlException), () => { SyndicationItem.Load(reader); });
+ Assert.Throws<XmlException>(() => { SyndicationItem.Load(reader); });
}
}
string file = "TestFeeds/FailureFeeds/no_rss_version.xml";
using (XmlReader reader = XmlReader.Create(file))
{
- Assert.Throws(typeof(XmlException), () => { SyndicationItem.Load(reader); });
+ Assert.Throws<XmlException>(() => { SyndicationItem.Load(reader); });
}
}