public static SetupEnvironmentModel ( ) : Mock |
||
return | Mock |
public void DeploySummaryPredicateExisting_EnvironmentContainsResourceWithSameIDButDifferentName_ExpectedTrue() { Guid resourceGuid = Guid.NewGuid(); Mock <IContextualResourceModel> mockResourceModel = CreateMockResourceModel(resourceGuid, "OtherResource"); IEnvironmentModel environmentModel; IExplorerItemModel resourceVm; IExplorerItemModel rootItem; StudioResourceRepository studioResourceRepository = CreateModels(false, mockResourceModel, out environmentModel, out resourceVm, out rootItem); Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService, resourceGuid); environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>()).Object; var navigationViewModel = CreateDeployNavigationViewModel(environmentModel, studioResourceRepository); ExplorerItemModel explorerItemModel = new ExplorerItemModel { DisplayName = "localhost", ResourceType = ResourceType.Server }; explorerItemModel.Children.Add(resourceVm); navigationViewModel.ExplorerItemModels.Add(explorerItemModel); navigationViewModel.Environment = environmentModel; resourceVm.IsChecked = true; bool actual = DeployStatsCalculator.DeploySummaryPredicateExisting(resourceVm, navigationViewModel); Assert.IsTrue(actual); Assert.IsTrue(DeployStatsCalculator.ConflictingResources.Count > 0); }
public void DeploySummaryPredicateNew_UnCheckedNavigationItemViewModel_Expected_False() { IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object; bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(null, environmentModel); Assert.IsFalse(actual); }
public void DeploySummaryPredicateNew_NullResourceOnNavigationItemViewModel_Expected_False() { ExplorerItemModel navigationItemViewModel = new ExplorerItemModel(); IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object; bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel); Assert.IsFalse(actual); }
public void DeploySummaryPredicateNew_EnvironmentContainsResource_Expected_False() { Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService); ExplorerItemModel navigationItemViewModel = new ExplorerItemModel(); IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>()).Object; bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel); Assert.IsFalse(actual); }
public void DeploySummaryPredicateNew_NullResourcesOnEnvironmentModel_Expected_False() { Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService); ExplorerItemModel navigationItemViewModel = new ExplorerItemModel(); Mock <IEnvironmentModel> mockEnvironmentModel = Dev2MockFactory.SetupEnvironmentModel(); mockEnvironmentModel.Setup(e => e.ResourceRepository).Returns <object>(null); IEnvironmentModel environmentModel = mockEnvironmentModel.Object; bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel); Assert.IsFalse(actual); }
public void DeployStatsCalculator_Calculate_HasFolders_Expect_NoFoldersCounted() { //------------Setup for test-------------------------- var conn = new Mock <IConnectControlSingleton>().Object; var studio = new Mock <IStudioResourceRepository>().Object; ExplorerItemModel navigationItemViewModel = new ExplorerItemModel(conn, studio) { ResourceType = ResourceType.Folder, IsChecked = true }; IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object; bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel); Assert.IsFalse(actual); }
public void DeploySummaryPredicateExisting_EnvironmentDoesntContainResource_Expected_False() { Mock <IContextualResourceModel> mockResourceModel = CreateMockResourceModel(); IEnvironmentModel environmentModel; IExplorerItemModel resourceVm; IExplorerItemModel rootItem; StudioResourceRepository studioResourceRepository = CreateModels(false, mockResourceModel, out environmentModel, out resourceVm, out rootItem); Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService, Guid.NewGuid()); environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>(), new List <IResourceModel>()).Object; var navigationViewModel = CreateDeployNavigationViewModel(environmentModel, studioResourceRepository); resourceVm.IsChecked = true; bool actual = DeployStatsCalculator.DeploySummaryPredicateExisting(null, navigationViewModel); Assert.IsFalse(actual); }
protected StudioResourceRepository CreateModels(bool isChecked, Mock <IContextualResourceModel> mockResourceModel, out IEnvironmentModel environmentModel, out IExplorerItemModel resourceVm, out IExplorerItemModel rootItem) { Mock <IContextualResourceModel> resourceModel = mockResourceModel; var connection = new Mock <IEnvironmentConnection>(); var mockEnvironmentModel = new Mock <IEnvironmentModel>(); mockEnvironmentModel.Setup(e => e.Connection).Returns(connection.Object); mockEnvironmentModel.Setup(a => a.AuthorizationService).Returns(new Mock <IAuthorizationService>().Object); environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>()).Object; var serverItemModel = new ExplorerItemModel { DisplayName = "localhost", ResourceType = ResourceType.Server, EnvironmentId = environmentModel.ID, ResourcePath = "", ResourceId = Guid.NewGuid() }; rootItem = serverItemModel; ExplorerItemModel workflowsFolder = new ExplorerItemModel { DisplayName = "WORKFLOWS", ResourceType = ResourceType.Folder, ResourcePath = "WORKFLOWS", EnvironmentId = mockEnvironmentModel.Object.ID, ResourceId = Guid.NewGuid() }; serverItemModel.Children.Add(workflowsFolder); var studioResourceRepository = new StudioResourceRepository(serverItemModel, _Invoke); resourceModel.Setup(model => model.Category).Returns("WORKFLOWS\\" + resourceModel.Object.DisplayName); resourceModel.Setup(a => a.ID).Returns(resourceIdConflict); TestEnvironmentRespository testEnvironmentRespository = new TestEnvironmentRespository(environmentModel); // ReSharper disable ObjectCreationAsStatement new EnvironmentRepository(testEnvironmentRespository); // ReSharper restore ObjectCreationAsStatement IEnvironmentModel internalEnvironmentModel = environmentModel; studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID; studioResourceRepository.AddResouceItem(resourceModel.Object); resourceVm = workflowsFolder.Children[0]; resourceVm.IsChecked = isChecked; return(studioResourceRepository); }