private void InitializationResponseSetViewModel(ResponseSetsType type, string propertyName)
        {
            bool isTestCompleteCalled = false;
            ResponseSetsViewModel responseSet = new ResponseSetsViewModel(type);
            responseSet.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == propertyName)
                {
                    Assert.AreEqual(ResponseSetsViewModel.TOP_COUNT, responseSet.TopResponses.Count);                    
                    if (type == ResponseSetsType.Submitted)
                    {
                        var submitted = responseSet.DisplayedResponses.Where(item => item.IsSubmitted == true);
                        Assert.AreEqual(responseSet.DisplayedResponses.Count, submitted.Count());
                    }
                    else
                    {
                        Assert.AreEqual(RESPONSE_SETS_COUNT - RESPONSE_SETS_COUNT / 4, responseSet.DisplayedResponses.Count);
                    }

                    CallTestComplete(ref isTestCompleteCalled);
                }
            };

            responseSet.InitializeViewModelCommand.Execute(null);
            EndOnWaitingResponse();
        }
        private void InitializationResponseSetViewModel(ResponseSetsType type, string propertyName)
        {
            bool isTestCompleteCalled         = false;
            ResponseSetsViewModel responseSet = new ResponseSetsViewModel(type);

            responseSet.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == propertyName)
                {
                    Assert.AreEqual(ResponseSetsViewModel.TOP_COUNT, responseSet.TopResponses.Count);
                    if (type == ResponseSetsType.Submitted)
                    {
                        var submitted = responseSet.DisplayedResponses.Where(item => item.IsSubmitted == true);
                        Assert.AreEqual(responseSet.DisplayedResponses.Count, submitted.Count());
                    }
                    else
                    {
                        Assert.AreEqual(RESPONSE_SETS_COUNT - RESPONSE_SETS_COUNT / 4, responseSet.DisplayedResponses.Count);
                    }

                    CallTestComplete(ref isTestCompleteCalled);
                }
            };

            responseSet.InitializeViewModelCommand.Execute(null);
            EndOnWaitingResponse();
        }
 public ResponseSetsViewModel(ResponseSetsType type)
 {
     this.currentType = type;
     this.InitializeViewModelCommand = new RelayCommand(this.InitializeViewModelExecute);
     this.searchHelper             = new DeferredSearchHelper("SearchString", this, this.Search);
     this.NavigateBackCommand      = new RelayCommand(this.NavigateBackExecute);
     this.DeleteResponseSetCommand = new RelayCommand <ResponseSet>(this.DeleteResponseSetExecute);
     this.OpenDuplicateCommand     = new RelayCommand <int>(this.OpenDuplicateExecute);
 }
 public ResponseSetsViewModel(ResponseSetsType type)
 {
     this.currentType = type;
     this.InitializeViewModelCommand = new RelayCommand(this.InitializeViewModelExecute);
     this.searchHelper = new DeferredSearchHelper("SearchString", this, this.Search);
     this.NavigateBackCommand = new RelayCommand(this.NavigateBackExecute);
     this.DeleteResponseSetCommand = new RelayCommand<ResponseSet>(this.DeleteResponseSetExecute);
     this.OpenDuplicateCommand = new RelayCommand<int>(this.OpenDuplicateExecute);
 }
        private bool DeleteResponseSet(ResponseSetsType viewModelType, ResponseSetType responseType)
        {
            SurveyMock.RemoveAllSurveys();
            bool isCompleted = false;
            var  survey      = SurveyMock.GenerateAndSaveSurvey(SURVEY_ID);
            var  responseSet = SurveyMock.GenerateAndSaveResponseSet(responseType, survey);
            ResponseSetsViewModel viewModel = new ResponseSetsViewModel(viewModelType);

            viewModel.TestCompleted += (sender, args) =>
            {
                if (args.Message == RESPONSE_DELETED)
                {
                    Assert.AreEqual(0, viewModel.DisplayedResponses.Count);
                    Assert.AreEqual(0, viewModel.TopResponses.Count);
                    isCompleted = true;
                }
            };

            viewModel.DeleteResponseSetCommand.Execute(responseSet);
            return(isCompleted);
        }
        private bool DeleteResponseSet(ResponseSetsType viewModelType, ResponseSetType responseType)
        {
            SurveyMock.RemoveAllSurveys();
            bool isCompleted = false;
            var survey = SurveyMock.GenerateAndSaveSurvey(SURVEY_ID);
            var responseSet = SurveyMock.GenerateAndSaveResponseSet(responseType, survey);
            ResponseSetsViewModel viewModel = new ResponseSetsViewModel(viewModelType);
            viewModel.TestCompleted += (sender, args) =>
            {
                if (args.Message == RESPONSE_DELETED)
                {
                    Assert.AreEqual(0, viewModel.DisplayedResponses.Count);
                    Assert.AreEqual(0, viewModel.TopResponses.Count);
                    isCompleted = true;
                }
            };

            viewModel.DeleteResponseSetCommand.Execute(responseSet);
            return isCompleted;
        }