public void WhenSaleStrategyDoesNotExist_Fails() { _repoMock.Setup(r => r.GetSaleStrategy(SaleStrategyId)).ReturnsAsync((SaleStrategy)null); var handler = new ApplySaleStrategyHandler(_repoMock.Object, _accSvcMock.Object); var result = handler.HandleAsync(Cmd, _context).GetAwaiter().GetResult(); Assert.IsFalse(result.Successful); Assert.AreEqual("sale_strategy_not_found", result.ErrorCode); }
public void WhenSaleStrategyApplicationSucceeds_Succeeds() { var strategy = new AlwaysSucceedsStrategy(); _repoMock.Setup(r => r.GetSaleStrategy(SaleStrategyId)).ReturnsAsync(strategy); var handler = new ApplySaleStrategyHandler(_repoMock.Object, _accSvcMock.Object); var result = handler.HandleAsync(Cmd, _context).GetAwaiter().GetResult(); Assert.IsTrue(result.Successful); Assert.AreEqual(1, strategy.InvocationCount); }
public void WhenSaleStrategyApplicationFails_Fails() { var strategy = new AlwaysFailsStrategy(); _repoMock.Setup(r => r.GetSaleStrategy(SaleStrategyId)).ReturnsAsync(strategy); var handler = new ApplySaleStrategyHandler(_repoMock.Object, _accSvcMock.Object); var result = handler.HandleAsync(Cmd, _context).GetAwaiter().GetResult(); Assert.IsFalse(result.Successful); Assert.AreEqual("sale_strategy_application_failed", result.ErrorCode); Assert.AreEqual(1, strategy.InvocationCount); }