Ejemplo n.º 1
0
        public void Filters_OnRefreshAndCacheNotExpired_AreResetToDefaults()
        {
            // Arrange
            var serviceMock  = GetMockPersonService();
            var currentOrder = GetFakeCatalogOrder();
            var viewModel    = GetCustomViewModel(serviceMock.Object, currentOrder);
            var tracker      = new PropertyChangeTracker(viewModel);

            viewModel.Initialize();
            tracker.WaitForChange("LastUpdateTime", 1);
            viewModel.Include70s = false;
            viewModel.Include80s = false;
            viewModel.Include90s = false;
            viewModel.Include00s = false;

            // Act
            tracker.Reset();
            viewModel.RefreshCatalog();
            tracker.WaitForChange("LastUpdateTime", 1);
            serviceMock.Verify(s => s.EndGetPeople(It.IsAny <IAsyncResult>()), Times.Once(),
                               "Service was not called one (and only one) time");

            // Assert
            Assert.IsTrue(viewModel.Include70s, "Include70s filter was not reset");
            Assert.IsTrue(viewModel.Include80s, "Include80s filter was not reset");
            Assert.IsTrue(viewModel.Include90s, "Include90s filter was not reset");
            Assert.IsTrue(viewModel.Include00s, "Include00s filter was not reset");
        }
Ejemplo n.º 2
0
        public void CatalogViewModel_OnInitialization_CatalogIsPopulated()
        {
            // Arrange
            var viewModel = GetStandardViewModel();
            var tracker   = new PropertyChangeTracker(viewModel);

            // Act
            viewModel.Initialize();
            tracker.WaitForChange("LastUpdateTime", 1);

            // Assert
            Assert.IsNotNull(viewModel.Catalog);
        }
Ejemplo n.º 3
0
        public void Catalog_FilterDoesNotInclude00s_00sRecordIsNotIncluded()
        {
            // Arrange
            var viewModel = GetStandardViewModel();
            var tracker   = new PropertyChangeTracker(viewModel);

            viewModel.Initialize();
            tracker.WaitForChange("LastUpdateTime", 1);

            // Act
            viewModel.Include00s = false;

            // Assert
            Assert.IsFalse(viewModel.Catalog.Contains(_00sPerson));
        }
Ejemplo n.º 4
0
        public void CatalogService_OnRefreshAndCacheNotExpired_ServiceIsCalledOnce()
        {
            // Arrange
            var serviceMock  = GetMockPersonService();
            var currentOrder = GetFakeCatalogOrder();
            var viewModel    = GetCustomViewModel(serviceMock.Object, currentOrder);
            var tracker      = new PropertyChangeTracker(viewModel);

            viewModel.Initialize();
            tracker.WaitForChange("LastUpdateTime", 1);

            // Act
            tracker.Reset();
            viewModel.RefreshCatalog();
            var result = tracker.WaitForChange("LastUpdateTime", 1);

            // Assert
            serviceMock.Verify(s => s.EndGetPeople(It.IsAny <IAsyncResult>()),
                               Times.Once());
        }