public void TestViewMyInit_ShouldCallCreateCheckoutViewModel(string id) { var mockedView = new Mock <ICheckoutView>(); mockedView.Setup(v => v.Model).Returns(new CheckoutViewModel()); var user = new User() { Id = id }; var mockedUserService = new Mock <IUserService>(); mockedUserService.Setup(u => u.GetById(It.IsAny <string>())).Returns(user); var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>(); mockedAuthenticationProvider.Setup(p => p.CurrentUserId).Returns(id); var mockedViewModelFactory = new Mock <IViewModelFactory>(); mockedViewModelFactory.Setup(f => f.CreateCheckoutViewModel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new CheckoutViewModel()); var mockedCart = new Mock <IShoppingCart>(); var checkoutPresenter = new CheckoutPresenter(mockedView.Object, mockedAuthenticationProvider.Object, mockedUserService.Object, mockedViewModelFactory.Object, mockedCart.Object); mockedView.Raise(v => v.MyInit += null, EventArgs.Empty); mockedViewModelFactory.Verify(f => f.CreateCheckoutViewModel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public OrderController(IGetUnshippedOrdersUseCase getUnshippedOrdersUseCase, GetUnshippedOrdersPresenter getUnshippedOrdersPresenter, IMarkOrderShippedUseCase markOrderShippedUseCase, MarkOrderShippedPresenter markOrderShippedPresenter, ICheckoutUseCase checkoutUseCase, CheckoutPresenter checkoutPresenter) { _getUnshippedOrdersUseCase = getUnshippedOrdersUseCase; _getUnshippedOrdersPresenter = getUnshippedOrdersPresenter; _markOrderShippedUseCase = markOrderShippedUseCase; _markOrderShippedPresenter = markOrderShippedPresenter; _checkoutUseCase = checkoutUseCase; _checkoutPresenter = checkoutPresenter; }
public void TestConstructor_PassEverythingCorrectly_ShouldInitializeCorrectly() { var mockedView = new Mock <ICheckoutView>(); var mockedUserService = new Mock <IUserService>(); var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>(); var mockedViewModelFactory = new Mock <IViewModelFactory>(); var mockedCart = new Mock <IShoppingCart>(); var checkoutPresenter = new CheckoutPresenter(mockedView.Object, mockedAuthenticationProvider.Object, mockedUserService.Object, mockedViewModelFactory.Object, mockedCart.Object); Assert.IsInstanceOf <CheckoutPresenter>(checkoutPresenter); }
public void InitializeWithValidSessionIdBindsCorrectViewProperties() { // Arrange Mock<ICheckoutView> mockView = new Mock<ICheckoutView>(); mockView.Setup(v => v.SessionID).Returns("123"); mockView.SetupSet(v => v.Products = It.Is<List<ProductItem>>(i => i.Count == 3)).Verifiable(); mockView.SetupSet(v => v.Total = It.Is<decimal>(t => t == 8.97m)).Verifiable(); mockView.SetupSet(v => v.SubTotal = It.Is<decimal>(t => t == 8.97m)).Verifiable(); mockView.SetupSet(v => v.Discount = It.Is<decimal>(t => t == 0m)).Verifiable(); Mock<INavigationService> mockNavigator = new Mock<INavigationService>(); CheckoutPresenter presenter = new CheckoutPresenter(mockView.Object, mockNavigator.Object, GetCheckoutServiceStub()); // Act presenter.Initialize(); // Assert mockView.Verify(); }
public void InitializeWithValidSessionIdBindsCorrectViewProperties() { // Arrange Mock <ICheckoutView> mockView = new Mock <ICheckoutView>(); mockView.Setup(v => v.SessionID).Returns("123"); mockView.SetupSet(v => v.Products = It.Is <List <ProductItem> >(i => i.Count == 3)).Verifiable(); mockView.SetupSet(v => v.Total = It.Is <decimal>(t => t == 8.97m)).Verifiable(); mockView.SetupSet(v => v.SubTotal = It.Is <decimal>(t => t == 8.97m)).Verifiable(); mockView.SetupSet(v => v.Discount = It.Is <decimal>(t => t == 0m)).Verifiable(); Mock <INavigationService> mockNavigator = new Mock <INavigationService>(); CheckoutPresenter presenter = new CheckoutPresenter(mockView.Object, mockNavigator.Object, GetCheckoutServiceStub()); // Act presenter.Initialize(); // Assert mockView.Verify(); }
public void TestViewMyCheckout_ShouldSetViewModelIsCheckoutSuccessfullToTrue(string name, string address, string phoneNumber) { var mockedView = new Mock <ICheckoutView>(); mockedView.Setup(v => v.Model).Returns(new CheckoutViewModel()); var mockedUserService = new Mock <IUserService>(); var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>(); var mockedViewModelFactory = new Mock <IViewModelFactory>(); var mockedCart = new Mock <IShoppingCart>(); var checkoutPresenter = new CheckoutPresenter(mockedView.Object, mockedAuthenticationProvider.Object, mockedUserService.Object, mockedViewModelFactory.Object, mockedCart.Object); var args = new CheckoutEventArgs(name, address, phoneNumber); mockedView.Raise(v => v.MyCheckout += null, args); Assert.IsTrue(mockedView.Object.Model.IsCheckoutSuccessful); }
public void TestViewMyCheckout_ShouldCallCartFinishOrder(string name, string address, string phoneNumber) { var mockedView = new Mock <ICheckoutView>(); mockedView.Setup(v => v.Model).Returns(new CheckoutViewModel()); var mockedUserService = new Mock <IUserService>(); var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>(); var mockedViewModelFactory = new Mock <IViewModelFactory>(); var mockedCart = new Mock <IShoppingCart>(); var checkoutPresenter = new CheckoutPresenter(mockedView.Object, mockedAuthenticationProvider.Object, mockedUserService.Object, mockedViewModelFactory.Object, mockedCart.Object); var args = new CheckoutEventArgs(name, address, phoneNumber); mockedView.Raise(v => v.MyCheckout += null, args); mockedCart.Verify(c => c.FinishOrder(name, address, phoneNumber), Times.Once); }
public Checkout() { _presenter = new CheckoutPresenter(this, DependencyManager.GetNavigationService(), DependencyManager.GetCheckoutService()); }
public Checkout(string sessionID) { this._sessionID = sessionID; _presenter = new CheckoutPresenter(this, new NavigationService(), new StubCheckoutService()); InitializeComponent(); }
public Checkout() { _presenter = new CheckoutPresenter(this, DependencyManager.GetNavigationService(), DependencyManager.GetCheckoutService()); }
public Checkout(string sessionID) { this._sessionID = sessionID; _presenter = new CheckoutPresenter(this, new NavigationService(), new StubCheckoutService()); InitializeComponent(); }