public void Then_SearchStringIsMapped(string type, string searchString) { var result = MergeController.SearchEpao(type, searchString) as ViewResult; var model = result.Model as SearchOrganisationViewModel; model.SearchString.Should().Be(searchString); }
public void And_ModelIsValid_Then_RedirectToConfirmAndCompletePage() { var viewModel = _autoFixture.Create <MergeOverviewViewModel>(); var result = MergeController.MergeOverview(viewModel) as RedirectToActionResult; result.ActionName.Should().Be(nameof(MergeController.ConfirmAndComplete)); }
public async Task And_ExecuteMergeRequestSuccessful_Then_MarkMergeRequestComplete() { var viewModel = SetupViewModel(); await MergeController.ConfirmAndComplete(viewModel); _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.Is <MergeRequest>(r => r.Completed == true))); }
public async Task Then_GetEpaOrganisationData(string type) { var epaoId = _autoFixture.Create <string>(); await MergeController.ConfirmEpao(type, epaoId, null); _mockApiClient.Verify(c => c.GetEpaOrganisation(epaoId), Times.Once()); }
public async Task And_ExecuteMergeRequestSuccessful_Then_ReturnRedirectToComplete() { var viewModel = SetupViewModel(); var result = await MergeController.ConfirmAndComplete(viewModel) as RedirectToActionResult; result.ActionName.Should().Be(nameof(MergeController.MergeComplete)); }
public void Then_SearchTypeIsMapped(string type) { var result = MergeController.SearchEpao(type) as ViewResult; var model = result.Model as SearchOrganisationViewModel; model.OrganisationType.Should().Be(type); }
public void Setup() { _mergeBlacklistRepo = new MergeBlacklistRepositoryMock(); _wordRepo = new WordRepositoryMock(); _mergeService = new MergeService(_mergeBlacklistRepo, _wordRepo); _permissionService = new PermissionServiceMock(); _mergeController = new MergeController(_mergeService, _permissionService); }
public void And_ModelIsInvalid_Then_ReturnView() { MergeController.ModelState.AddModelError("Error", "Error message"); var viewModel = _autoFixture.Build <SetSecondaryEpaoEffectiveToDateViewModel>().Create(); var result = MergeController.SetSecondaryEpaoEffectiveToDate(viewModel) as ViewResult; result.Model.Should().BeEquivalentTo(viewModel); }
public void And_ModelIsValid_Then_ReturnRedirectToMergeOverview() { var dateTime = _autoFixture.Build <DateTime>().Create(); var viewModel = SetUpViewModel(dateTime); var result = MergeController.SetSecondaryEpaoEffectiveToDate(viewModel) as RedirectToActionResult; result.ActionName.Should().Be("MergeOverview"); }
public async Task And_ModelIsInvalid_Then_ReturnView(string type) { MergeController.ModelState.AddModelError("Error", "Error message"); var viewModel = _autoFixture.Create <SearchOrganisationViewModel>(); var result = await MergeController.EpaoSearchResults(type, null, viewModel) as ViewResult; result.Model.Should().BeEquivalentTo(viewModel); }
public void And_ModelIsValid_Then_RedirectToMergeOverview(string type) { SetUpGetMergeRequest(); var viewModel = _autoFixture.Create <ConfirmEpaoViewModel>(); var result = MergeController.ConfirmEpao(type, viewModel) as RedirectToActionResult; result.ActionName.Should().Be(nameof(MergeController.MergeOverview)); }
public void And_ModelIsInvalid_Then_ReturnView(string type) { MergeController.ModelState.AddModelError("Error", "Error message"); var viewModel = _autoFixture.Create <ConfirmEpaoViewModel>(); var result = MergeController.ConfirmEpao(type, viewModel) as ViewResult; result.Model.Should().BeEquivalentTo(viewModel); }
public async Task And_UserIsNavigatingForwards_Then_SearchCommandIsAdded(string type) { SetUpApiResponse(); var viewModel = _autoFixture.Create <SearchOrganisationViewModel>(); await MergeController.EpaoSearchResults(type, null, viewModel); _mockMergeSessionService.Verify(ms => ms.AddSearchEpaoCommand(type, viewModel.SearchString), Times.Once()); }
public void Then_MapMergeRequest() { var result = MergeController.ConfirmAndComplete() as ViewResult; var model = result.Model as ConfirmAndCompleteViewModel; model.AcceptWarning.Should().BeFalse(); model.PrimaryEpaoName.Should().Be(_mergeRequest.PrimaryEpao.Name); model.SecondaryEpaoName.Should().Be(_mergeRequest.SecondaryEpao.Name); }
public async Task And_MergeCommandThrowsException_Then_RedirectToErrorPage() { _mockApiClient.Setup(c => c.MergeOrganisations(It.IsAny <MergeOrganisationsCommand>())) .ThrowsAsync(new Exception()); var viewModel = SetupViewModel(); var result = await MergeController.ConfirmAndComplete(viewModel) as RedirectToActionResult; result.ActionName.Should().Be(nameof(MergeController.MergeError)); }
public async Task And_MergeCommandThrowsException_Then_MergeRequestIsNotUpdated() { _mockApiClient.Setup(c => c.MergeOrganisations(It.IsAny <MergeOrganisationsCommand>())) .ThrowsAsync(new Exception()); var viewModel = SetupViewModel(); await MergeController.ConfirmAndComplete(viewModel); _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.IsAny <MergeRequest>()), Times.Never()); }
public void Then_ReturnViewResult() { var viewResult = MergeController.SetSecondaryEpaoEffectiveToDate() as ViewResult; var model = viewResult.Model as SetSecondaryEpaoEffectiveToDateViewModel; model.SecondaryEpaoName.Should().Be(_mergeRequest.SecondaryEpao.Name); model.Day.Should().Be(_mergeRequest.SecondaryEpaoEffectiveTo.Value.Day.ToString()); model.Month.Should().Be(_mergeRequest.SecondaryEpaoEffectiveTo.Value.Month.ToString()); model.Year.Should().Be(_mergeRequest.SecondaryEpaoEffectiveTo.Value.Year.ToString()); }
public async Task Then_ExecuteMergeRequest() { var viewModel = SetupViewModel(); await MergeController.ConfirmAndComplete(viewModel); _mockApiClient.Verify(client => client.MergeOrganisations(It.Is <MergeOrganisationsCommand>( c => c.ActionedByUser == "*****@*****.**" && c.PrimaryEndPointAssessorOrganisationId == _mergeRequest.PrimaryEpao.Id && c.SecondaryEndPointAssessorOrganisationId == _mergeRequest.SecondaryEpao.Id && c.SecondaryStandardsEffectiveTo == _mergeRequest.SecondaryEpaoEffectiveTo.Value)), Times.Once()); }
public async Task Then_ResultsAreMapped(string type) { SetUpApiResponse(); var searchViewModel = _autoFixture.Create <SearchOrganisationViewModel>(); var result = await MergeController.EpaoSearchResults(type, true, searchViewModel) as ViewResult; var model = result.Model as EpaoSearchResultsViewModel; model.Results.Count.Should().Be(_response.Count); }
public async Task And_WarningIsNotAccepted_Then_ReturnView() { MergeController.ModelState.AddModelError("Error", "Error message"); var viewModel = _autoFixture.Build <ConfirmAndCompleteViewModel>() .With(c => c.AcceptWarning, false) .Create(); var result = await MergeController.ConfirmAndComplete(viewModel) as ViewResult; var model = result.Model as ConfirmAndCompleteViewModel; model.Should().BeEquivalentTo(viewModel); }
internal IncomingChangesTab( WorkspaceInfo wkInfo, IWorkspaceWindow workspaceWindow, IViewSwitcher switcher, NewIncomingChangesUpdater newIncomingChangesUpdater, EditorWindow parentWindow) { mWkInfo = wkInfo; mWorkspaceWindow = workspaceWindow; mSwitcher = switcher; mNewIncomingChangesUpdater = newIncomingChangesUpdater; mParentWindow = parentWindow; mGuiMessage = new UnityPlasticGuiMessage(); BuildComponents(mWkInfo); mProgressControls = new ProgressControlsForViews(); mCooldownClearUpdateSuccessAction = new CooldownWindowDelayer( DelayedClearUpdateSuccess, UnityConstants.NOTIFICATION_CLEAR_INTERVAL); PlasticNotifier plasticNotifier = new PlasticNotifier(); mMergeController = new MergeController( mWkInfo, null, null, EnumMergeType.IncomingMerge, true, plasticNotifier, null); mMergeViewLogic = new MergeViewLogic( mWkInfo, EnumMergeType.IncomingMerge, true, mMergeController, plasticNotifier, ShowIncomingChangesFrom.NotificationBar, null, mNewIncomingChangesUpdater, null, this, NewChangesInWk.Build(mWkInfo, new BuildWorkspacekIsRelevantNewChange()), mProgressControls, null); ((IRefreshableView)this).Refresh(); }
public void And_ModelIsValid_Then_CallUpdateWithNewEffectiveToDate() { var dateTime = DateTime.Now; var expectedDay = dateTime.Day; var expectedMonth = dateTime.Month; var expectedYear = dateTime.Year; var viewModel = SetUpViewModel(dateTime); var result = MergeController.SetSecondaryEpaoEffectiveToDate(viewModel); _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.Is <MergeRequest>( r => r.SecondaryEpaoEffectiveTo.Value == dateTime.Date)), Times.Once()); }
public async Task MergePolicies() { var policy = new PolicyEdit() { Id = Guid.NewGuid(), }; var merge = new MergePolicies() { TargetPolicy = policy, SourcePolicyIds = new List <Guid>() { Guid.NewGuid(), Guid.NewGuid() } }; var service = new Mock <IPolicyService>(); var authService = TestHelper.MockAuthenticationService(Scope.Branch); var result = new Result() { Success = true }; ScopeOptions options = null; MergePolicies merged = null; service.Setup(c => c.MergePolicies(It.IsAny <ScopeOptions>(), It.Is <MergePolicies>(m => m == merge))) .Callback((ScopeOptions o, MergePolicies m) => { merged = m; options = o; }) .ReturnsAsync(result); var controller = new MergeController(null, service.Object, authService.Object); var actual = await controller.MergePolicies(merge); Assert.Same(merge, merged); Assert.Equal(Scope.Branch, options.Scope); var okResult = Assert.IsType <OkObjectResult>(actual); var returnValue = Assert.IsType <Result>(okResult.Value); Assert.Same(result, returnValue); }
internal IncomingChangesTab( WorkspaceInfo wkInfo, IViewSwitcher switcher, PlasticGUIClient plasticClient, NewIncomingChangesUpdater newIncomingChangesUpdater, EditorWindow parentWindow) { mWkInfo = wkInfo; mSwitcher = switcher; mPlasticClient = plasticClient; mNewIncomingChangesUpdater = newIncomingChangesUpdater; mParentWindow = parentWindow; mGuiMessage = new UnityPlasticGuiMessage(parentWindow); BuildComponents(mWkInfo); mProgressControls = new ProgressControlsForViews(); PlasticNotifier plasticNotifier = new PlasticNotifier(); mMergeController = new MergeController( mWkInfo, null, null, EnumMergeType.IncomingMerge, true, plasticNotifier, null); mMergeViewLogic = new MergeViewLogic( mWkInfo, EnumMergeType.IncomingMerge, true, mMergeController, plasticNotifier, ShowIncomingChangesFrom.NotificationBar, null, mNewIncomingChangesUpdater, null, this, NewChangesInWk.Build(mWkInfo, new BuildWorkspacekIsRelevantNewChange()), mProgressControls, null); ((IRefreshableView)this).Refresh(); }
public void And_SessionIsSet_Then_MapViewModel() { var mergeRquest = _autoFixture.Build <MergeRequest>().Create(); _mockMergeSessionService.Setup(ms => ms.GetMergeRequest()) .Returns(mergeRquest); var viewResult = MergeController.MergeOverview() as ViewResult; var viewModel = viewResult.Model as MergeOverviewViewModel; viewModel.PrimaryEpaoId.Should().Be(mergeRquest.PrimaryEpao.Id); viewModel.PrimaryEpaoName.Should().Be(mergeRquest.PrimaryEpao.Name); viewModel.SecondaryEpaoId.Should().Be(mergeRquest.SecondaryEpao.Id); viewModel.SecondaryEpaoName.Should().Be(mergeRquest.SecondaryEpao.Name); viewModel.SecondaryEpaoEffectiveTo.Should().Be(mergeRquest.SecondaryEpaoEffectiveTo); }
public Object ProcessWrite(IPostProcessWriter writer) { ISet <Object> substitutedEntities = writer.SubstitutedEntities; if (substitutedEntities.Count == 0) { return(null); } IDisposableCache childCache = CacheFactory.Create(CacheFactoryDirective.NoDCE, "XmlMerge"); IServiceContext mergeContext = BeanContext.CreateService(delegate(IBeanContextFactory childContextFactory) { childContextFactory.RegisterBean(typeof(MergeHandle)).Autowireable <MergeHandle>().PropertyValue("Cache", childCache); }); try { IDictionary <Object, Int32> mutableToIdMap = writer.MutableToIdMap; IObjRefHelper objRefHelper = ObjRefHelper; MergeHandle mergeHandle = mergeContext.GetService <MergeHandle>(); IList <Object> toMerge = new List <Object>(substitutedEntities.Count); foreach (Object entity in substitutedEntities) { toMerge.Add(entity); IObjRef ori = objRefHelper.EntityToObjRef(entity); mergeHandle.objToOriDict.Add(entity, ori); Int32 id = mutableToIdMap[entity]; mutableToIdMap.Add(ori, id); } ICUDResult cudResult = MergeController.MergeDeep(toMerge, mergeHandle); if (cudResult.AllChanges.Count != 0) { return(cudResult); } else { return(null); } } finally { mergeContext.Dispose(); } }
public void And_SessionIsNull_ThenMapViewModel() { var mergeRequest = new MergeRequest(); mergeRequest.StartNewRequest(); _mockMergeSessionService.Setup(ms => ms.GetMergeRequest()) .Returns(mergeRequest); var viewResult = MergeController.MergeOverview() as ViewResult; var viewModel = viewResult.Model as MergeOverviewViewModel; viewModel.PrimaryEpaoId.Should().BeNull(); viewModel.PrimaryEpaoName.Should().BeNull(); viewModel.SecondaryEpaoId.Should().BeNull(); viewModel.SecondaryEpaoName.Should().BeNull(); viewModel.SecondaryEpaoEffectiveTo.Should().BeNull(); }
public void And_ModelIsValid_Then_UpdateMergeRequest(string type) { SetUpGetMergeRequest(); var viewModel = _autoFixture.Build <ConfirmEpaoViewModel>() .With(vm => vm.MergeOrganisationType, type) .Create(); MergeController.ConfirmEpao(type, viewModel); if (type == "primary") { _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.Is <MergeRequest>(r => r.PrimaryEpao.Id == viewModel.EpaoId)), Times.Once); } else if (type == "secondary") { _mockMergeSessionService.Verify(ms => ms.UpdateMergeRequest(It.Is <MergeRequest>(r => r.SecondaryEpao.Id == viewModel.EpaoId)), Times.Once); } }
public void Test_DataChange() { TestEntity newTestEntity = EntityFactory.CreateEntity <TestEntity>(); CountDownLatch latch = new CountDownLatch(1); MergeProcess.Process(newTestEntity, null, null, delegate(bool success) { latch.CountDown(); }); latch.Await(); WaitForUI(); newTestEntity.Relation = EntityFactory.CreateEntity <TestEntity2>(); ICacheWalkerResult cwResult = CacheWalker.WalkEntities(newTestEntity); Log.Info(cwResult.ToString()); ICUDResult mergeResult = MergeController.MergeDeep(newTestEntity, new MergeHandle()); latch = new CountDownLatch(1); RevertChangesHelper.RevertChanges(newTestEntity, delegate(bool success) { latch.CountDown(); }); latch.Await(); WaitForUI(); ((IWritableCache)Cache).Put(newTestEntity); latch = new CountDownLatch(1); ((INotifyPropertyChanged)newTestEntity).PropertyChanged += delegate(Object sender, PropertyChangedEventArgs evnt) { latch.CountDown(); }; MergeService.Merge(mergeResult, null); latch.Await(); WaitForUI(); Assert.AssertNotNull(newTestEntity.Relation); }
public void BeforeEachTest() { //_mockWebClient = new Mock<IWebClient>(); _controller = new MergeController(); }