public void WhenExceptionOccursErrorIsDisplayedInVisualizer()
        {
            MockRelatedPartsView mockView = new MockRelatedPartsView();

            SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator()
                                                                  .RegisterTypeMapping <IProductCatalogRepository, MockProductCatalog>()
                                                                  .RegisterTypeMapping <ILogger, MockLogger>());

            MockErrorVisualizer errorVisualizer = new MockErrorVisualizer();

            RelatedPartsPresenter target = new RelatedPartsPresenter(mockView);

            target.ErrorVisualizer = errorVisualizer;

            target.LoadParts("Error");

            Assert.IsTrue(errorVisualizer.DefaultErrorDisplayed);
        }
        public void WhenNoPartsErrorMessageIsSetOnView()
        {
            MockRelatedPartsView mockView = new MockRelatedPartsView();

            SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator()
                                                                  .RegisterTypeMapping <IProductCatalogRepository, MockProductCatalog>()
                                                                  .RegisterTypeMapping <ILogger, MockLogger>());

            MockErrorVisualizer errorVisualizer = new MockErrorVisualizer();

            RelatedPartsPresenter target = new RelatedPartsPresenter(mockView);

            target.ErrorVisualizer = errorVisualizer;

            target.LoadParts("sku");

            Assert.AreEqual("No parts found.", mockView.ErrorMessage);
        }
        public void CanLoadRelatedPartsOnClick()
        {
            MockRelatedPartsView mockView = new MockRelatedPartsView();

            SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator()
                                                                  .RegisterTypeMapping <IProductCatalogRepository, MockProductCatalog>(InstantiationType.AsSingleton));

            MockProductCatalog catalog = SharePointServiceLocator.Current.GetInstance <IProductCatalogRepository>() as MockProductCatalog;

            catalog.Parts = new List <Part> {
                new Part()
            };

            RelatedPartsPresenter target = new RelatedPartsPresenter(mockView);

            target.LoadParts("123456");

            Assert.AreEqual(1, mockView.Parts.Count());
            Assert.IsTrue(mockView.DataBound);
        }
Esempio n. 4
0
 public RelatedPartsControl()
 {
     presenter = new RelatedPartsPresenter(this);
 }