Ejemplo n.º 1
0
        private CatalogViewModel GetCustomViewModel(IPersonService service, CatalogOrder currentOrder)
        {
            var container = GetPopulatedContainer(service, currentOrder);
            var viewModel = new CatalogViewModel(container);

            return(viewModel);
        }
Ejemplo n.º 2
0
        private IUnityContainer GetPopulatedContainer()
        {
            IPersonService  serviceMock  = GetFakePersonService();
            CatalogOrder    currentOrder = GetFakeCatalogOrder();
            IUnityContainer container    = GetPopulatedContainer(serviceMock, currentOrder);

            return(container);
        }
Ejemplo n.º 3
0
        private CatalogOrder GetFakeCatalogOrder()
        {
            var currentOrder = new CatalogOrder()
            {
                SelectedPeople = new ObservableCollection <Person>(),
            };

            return(currentOrder);
        }
Ejemplo n.º 4
0
        public void CatalogViewModel_OnInitializationAndPersonServiceMissing_ThrowsException()
        {
            // Arrange
            CatalogOrder currentOrder = GetFakeCatalogOrder();
            var          viewModel    = GetCustomViewModel(null, currentOrder);

            // Act
            viewModel.Initialize();

            // Assert
            Assert.Fail("No Exception thrown when IPersonService is missing");
        }
Ejemplo n.º 5
0
        private IUnityContainer GetPopulatedContainer(IPersonService service, CatalogOrder currentOrder)
        {
            IUnityContainer container = new UnityContainer();

            if (service != null)
            {
                container.RegisterInstance <IPersonService>(service);
            }
            if (currentOrder != null)
            {
                container.RegisterInstance <CatalogOrder>("CurrentOrder", currentOrder);
            }
            return(container);
        }
Ejemplo n.º 6
0
        private void ConfigureContainer()
        {
            container = new UnityContainer();

            // Instantiate and register the Person Service
            var personService = new PersonServiceClient();

            container.RegisterInstance <IPersonService>(personService);

            // Instantiate and register our (fake) model
            var order = new CatalogOrder()
            {
                SelectedPeople = new ObservableCollection <Person>()
            };

            container.RegisterInstance <CatalogOrder>("CurrentOrder", order);
        }
Ejemplo n.º 7
0
 public void Initialize()
 {
     _service = GetServiceFromContainer();
     _model   = GetModelFromContainer();
     RefreshCatalog();
 }