public static async Task CatchException <T>(this IAsyncRequest <T> command, TestContextFixture testContextFixture, Type exception) { try { await testContextFixture.SendAsync(command); } catch (Exception p) { p.ShouldBeOfType(exception); } }
public async Task GetStock(TestContextFixture testContextFixture, Stock stock, GetStock.Query getStock) { //arrange testContextFixture.SaveAll(stock); getStock.CurrencyCode = stock.CurrencyCode; getStock.IsinCode = stock.IsinCode; //act var result = await testContextFixture.SendAsync(getStock); //assert result.Name.ShouldBe(stock.Name); }
public void ConcurrentUserNameChanged_ShouldThrow(TestContextFixture testContextFixture, User user, UpdateUser.Command updateUser) { //arrange testContextFixture.Save(user); user.FirstName = "Piet"; testContextFixture.DoClean(db => db.Database.ExecuteSqlCommand("UPDATE dbo.Users set firstname='Karel'") ); //act & assert Should.Throw <DbUpdateConcurrencyException>(() => testContextFixture.SendAsync(updateUser) ); }