public void order_should_be_done_successfully( IDependency1 fakeDependency1, IDependency2 fakeDependency2, ICacheManager fakeCacheManager ) { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- Building(builder => { A.CallTo(() => fakeCacheManager.Get("1")).Returns(new Basket(1, 50)); builder.Register(context => fakeDependency1); builder.Register(context => fakeDependency2); builder.Register(context => fakeCacheManager); builder.RegisterType <OrderService>().As <IOrderService>(); }); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var sut = The <IOrderService>(); OrderResult result = sut.DoOrder(1); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.BasketId.Should().Be(1); result.Total.Should().Be(50); A.CallTo(() => fakeDependency1.Salute()).MustHaveHappened(); }
public OrderResult DoOrder(int basketId) { var basket = (Basket)_cacheManager.Get(basketId.ToString()); _dependency1.Salute(); return(new OrderResult { Total = basket.Total, BasketId = basket.Id }); }