I'm new to unit testing and XUnit. I'm trying to write two test cases. One test is creating an item and the other test is deleting the item.
public class MyTests
{
string id = string.Empty;
[Fact]
public void TestCreate()
{
id = MethodToCreateItem();
Assert.NotNull(id);
}
[Fact]
public void TestDelete()
{
bool success = MethodToDeleteItem(id);
Assert.True(success);
}
}
The TestCreate()
runs fine. The id
is set and the test is successful. However, the test TestDelete()
doesn't work. When it gets to that test the value of id
is empty.
How can I make it so that the second test has access to the value of id
after the first test has ran?