Skip to content

Instantly share code, notes, and snippets.

@osmyn
Last active November 8, 2018 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osmyn/ddf9e2b14153a1c136edfa3dd531bf55 to your computer and use it in GitHub Desktop.
Save osmyn/ddf9e2b14153a1c136edfa3dd531bf55 to your computer and use it in GitHub Desktop.
//ASYNC
[TestMethod]
public void GetTypesByName_WhenNoNameProvided_ThrowsArgumentException()
{
//Arrange
var builder = new TypeServiceBuilder();
var service = builder.Build();
//Act
Func<Task> call = async () => await service.GetTypesByName(null);
//Assert
call.Should().Throw<ArgumentException>();
}
//REGULAR
[TestMethod]
public void AddTransaction_OnError_AccountUnlocks()
{
//Arrange
var builder = new RepositoryBuilder();
var context = builder.DefaultAccountDbContext();
var transaction = GetTestableTransaction(context);
context.Setup(x => x.SaveChanges())
.Throws(new UnitTestException("Unit test exception"));
var service = builder
.WithAccountDbContext(context.Object)
.Build();
//Act
Action action = () => service.AddTransaction(transaction);
//Assert
action.Should().Throw<UnitTestException>();
transaction.Account.Locked.Should().BeFalse();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment