예제 #1
0
        public void CancelingUdpDefaultFilterOnSearchFirstLoadLoadsTheSearchWithNoFilter()
        {
            const string NewFilterDefinition = @"{
  ""FilterGuid"": ""3732f424-216c-4fab-a2dc-a50c405512c3"",
  ""TimeStamp"": ""09/20/2013 15:05:08"",
  ""Version"": ""100.1"",
  ""Body"": {
    ""ColumnName"": ""Notes_f"",
    ""Operator"": ""IsEqualTo"",
    ""Value"": ""%{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Notes:\"",\""SystemName\"":\""Notes_f\"",\""DefaultValue\"":\""\""}%"",
    ""MemberType"": ""System.String""
  }
}";
            var udpFilter = new FilterViewModel(FilterType.UserFilter) { Name = "UdpFilter", OriginalFilterDefinitions = NewFilterDefinition };

            var vm = new FilterListViewModel { QuickFilterToolbarVM = new Lazy<QuickFilterToolbarViewModel>() };
            vm.SelectedFilter = null;
            vm.SearchViewModel = GetNewSearchListVm();
            Mock.Arrange(() => vm.SearchViewModel.AppliedFilter).Returns(() => null);
            Mock.Arrange(() => vm.SearchViewModel.ProcessSystemName).Returns("ProcessSystemName");

            var filterPreprocessor = new FilterPreprocessor();
            var udpValuesViewModel = new UdpValuesViewModel();
            filterPreprocessor.UDPValuesViewModel = new Lazy<UdpValuesViewModel>(() => udpValuesViewModel);
            
            var popupBuilderMock = Mock.Create<PopupBuilder>(Behavior.CallOriginal);
            Mock.Arrange(() => popupBuilderMock.SetCustomViewModel(Arg.IsAny<INotificationViewModel>())).Returns(popupBuilderMock);
            Mock.Arrange(() => popupBuilderMock.SetIsModal(Arg.AnyBool)).Returns(popupBuilderMock);
            Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>((ok, cancel) => cancel());
            var popupFactoryMock = Mock.Create<PopupFactory>(Behavior.Loose);
            Mock.Arrange(() => popupFactoryMock.Popup()).Returns(popupBuilderMock);
            filterPreprocessor.ThePopupFactory = new Lazy<PopupFactory>(() => popupFactoryMock);

            vm.FilterPreprocessor = new Lazy<IFilterPreprocessor>(() => filterPreprocessor);

            var dynamicTypeManager = Mock.Create<IDynamicTypeManager>(Behavior.CallOriginal);
            Mock.Arrange(() => dynamicTypeManager.GetFilterInfoType(Arg.AnyString)).Returns(() => null);
            Mock.Arrange(() => vm.TheDynamicTypeManager).Returns(new Lazy<IDynamicTypeManager>(() => dynamicTypeManager));
            Mock.Arrange(() => vm.SearchViewModel.RefreshSearchList(Arg.IsAny<MobileObservableCollection<IFilterDescriptor>>())).DoNothing();
            Mock.Arrange(() => vm.SearchViewModel.IsItemsLoaded).Returns(false);

            vm.ApplyFilter(udpFilter);
            Assert.IsNull(vm.SelectedFilter);
            Assert.IsNull(vm.AppliedFilter);
        }
예제 #2
0
        public void UdpQuickFilterSettingsReviewAndCancelingApplyingPreservePreviewslyApplyiedFilter()
        {
            const string PredifinedFilterDefinition = @"{
  ""FilterGuid"": ""3732f424-216c-4fab-a2dc-a50c405512c3"",
  ""TimeStamp"": ""09/20/2013 15:05:08"",
  ""Version"": ""100.1"",
  ""Body"": {
    ""ColumnName"": ""Notes_f"",
    ""Operator"": ""IsEqualTo"",
    ""Value"": ""%{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Notes:\"",\""SystemName\"":\""Notes_f\"",\""DefaultValue\"":\""\""}%"",
    ""MemberType"": ""System.String""
  }
}";
            const string NewFilterDefinition = @"{
  ""FilterGuid"": ""3732f424-216c-4fab-a2dc-a50c405512c3"",
  ""TimeStamp"": ""09/20/2013 15:05:08"",
  ""Version"": ""100.1"",
  ""Body"": {
    ""ColumnName"": ""Notes_f"",
    ""Operator"": ""IsEqualTo"",
    ""Value"": ""%{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Notes:\"",\""SystemName\"":\""Notes_f\"",\""DefaultValue\"":\""\""}%"",
    ""MemberType"": ""System.String""
  }
}";
            var predefinedFilter =
                new FilterViewModel(FilterType.UserFilter) { Name = "PreviouslySelectedFilter", OriginalFilterDefinitions = PredifinedFilterDefinition };
            var newFilter =
                new FilterViewModel(FilterType.UserFilter) { Name = "NewFilter_______________", OriginalFilterDefinitions = NewFilterDefinition };

            var vm = new FilterListViewModel { QuickFilterToolbarVM = new Lazy<QuickFilterToolbarViewModel>() };
            vm.SelectedFilter = predefinedFilter;
            vm.SearchViewModel = GetNewSearchListVm();
            vm.SearchViewModel.AppliedFilter = predefinedFilter;
            Mock.Arrange(() => vm.SearchViewModel.ProcessSystemName).Returns("ProcessSystemName");
            Mock.Arrange(() => vm.SearchViewModel.IsItemsLoaded).Returns(true);
            Mock.Arrange(() => vm.SearchViewModel.SetIsBusy(false)).DoNothing();

            var filterPreprocessor = new FilterPreprocessor();
            var udpValuesViewModel = new UdpValuesViewModel();
            filterPreprocessor.UDPValuesViewModel = new Lazy<UdpValuesViewModel>(() => udpValuesViewModel);


            var popupBuilderMock = Mock.Create<PopupBuilder>(Behavior.CallOriginal);
            Mock.Arrange(() => popupBuilderMock.SetCustomViewModel(Arg.IsAny<INotificationViewModel>())).Returns(popupBuilderMock);
            Mock.Arrange(() => popupBuilderMock.SetIsModal(Arg.AnyBool)).Returns(popupBuilderMock);
            Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>((ok, cancel) => cancel()).InSequence();
            var popupFactoryMock = Mock.Create<PopupFactory>(Behavior.Loose);
            Mock.Arrange(() => popupFactoryMock.Popup()).Returns(popupBuilderMock);
            filterPreprocessor.ThePopupFactory = new Lazy<PopupFactory>(() => popupFactoryMock);

            vm.FilterPreprocessor = new Lazy<IFilterPreprocessor>(() => filterPreprocessor);

            vm.ApplyFilter(newFilter);
            Assert.AreEqual(predefinedFilter.Name, vm.SelectedFilter.Name);

/*
            Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>((ok, cancel) => ok()).InSequence();
            vm.ApplyFilter(newFilter);
            Assert.AreEqual(newFilter.Name, vm.SelectedFilter.Name);
*/
        }