public void Invoke_ValidData_DeleteAndSaveAreCalled() { // prepare var appToDelete = new AppModel() { Id = 1 }; var appFromDb = new DataAccess.Models.App() { Id = 1, }; var mockedAppRepository = new Mock <IAppRepository>(); mockedAppRepository.Setup(r => r.GetById(1)).Returns(appFromDb); var action = new DeleteApp(mockedAppRepository.Object); // action var actionResult = action.Invoke(appToDelete.Id); // assert Assert.True(actionResult); mockedAppRepository.Verify(r => r.Delete(It.IsAny <DataAccess.Models.App>()), Times.Once()); mockedAppRepository.Verify(r => r.Save(), Times.Once()); }
public void DeleteApp_Test() { using (ShimsContext.Create()) { CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin; CloudFoundry.Manifests.Fakes.ShimManifestDiskRepository.ReadManifestString = TestUtils.CustomReadManifest; CloudFoundry.Manifests.Fakes.ShimManifest.AllInstances.Applications = TestUtils.CustomManifestApplications; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllSpacesResponse> .AllInstances.ResourcesGet = TestUtils.CustomGetPaged; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.DeleteAppNullableOfGuid = TestUtils.CustomDeleteApp; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllAppsForSpaceResponse> .AllInstances.ResourcesGet = TestUtils.CusomListAllAppsForSpacePagedResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllAppsForSpaceNullableOfGuidRequestOptions = TestUtils.CustomListAllAppsForSpace; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllRoutesForAppResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllRoutesForAppResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.ListAllRoutesForAppNullableOfGuid = TestUtils.CustomListAllRoutesForApp; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractRoutesEndpoint.AllInstances.DeleteRouteNullableOfGuidObject = TestUtils.CustomDeleteRoute; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.ListAllServiceBindingsForAppNullableOfGuid = TestUtils.CustomListAllServiceBindingsForApp; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllServiceBindingsForAppResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllServiceBindingsForAppResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceBindingsEndpoint.AllInstances.DeleteServiceBindingNullableOfGuid = TestUtils.CustomDeleteServiceBinding; CloudFoundry.CloudController.V2.Client.Fakes.ShimServiceInstancesEndpoint.AllInstances.DeleteServiceInstanceNullableOfGuid = TestUtils.CustomDeleteServiceInstance; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllOrganizationsResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllSpacesForOrganizationResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization; TestUtils.InitTestMetadata(); DeleteApp task = new DeleteApp(); task.CFUser = Settings.Default.User; task.CFPassword = Settings.Default.Password; task.CFServerUri = Settings.Default.ServerUri; task.CFSpace = "TestSpace"; task.CFOrganization = "TestOrg"; task.CFManifest = Settings.Default.CFManifest; task.CFDeleteRoutes = true; task.CFDeleteServices = true; task.BuildEngine = new FakeBuildEngine(); Assert.IsTrue(task.Execute()); } }
public void DeleteApp_Test() { using (ShimsContext.Create()) { CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesResponse>.AllInstances.ResourcesGet = TestUtils.CustomGetPaged; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.DeleteAppNullableOfGuid = TestUtils.CustomDeleteApp; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllAppsForSpaceResponse>.AllInstances.ResourcesGet = TestUtils.CusomListAllAppsForSpacePagedResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllAppsForSpaceNullableOfGuidRequestOptions = TestUtils.CustomListAllAppsForSpace; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllRoutesForAppResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllRoutesForAppResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.ListAllRoutesForAppNullableOfGuid = TestUtils.CustomListAllRoutesForApp; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractRoutesEndpoint.AllInstances.DeleteRouteNullableOfGuid = TestUtils.CustomDeleteRoute; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.ListAllServiceBindingsForAppNullableOfGuid = TestUtils.CustomListAllServiceBindingsForApp; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllServiceBindingsForAppResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllServiceBindingsForAppResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceBindingsEndpoint.AllInstances.DeleteServiceBindingNullableOfGuid = TestUtils.CustomDeleteServiceBinding; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractServiceInstancesEndpoint.AllInstances.DeleteServiceInstanceNullableOfGuid = TestUtils.CustomDeleteServiceInstance; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllOrganizationsResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations; CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesForOrganizationResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse; CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization; TestUtils.InitTestMetadata(); DeleteApp task = new DeleteApp(); task.CFUser = Settings.Default.User; task.CFPassword = Settings.Default.Password; task.CFServerUri = Settings.Default.ServerUri; task.CFSpace = "TestSpace"; task.CFOrganization = "TestOrg"; task.CFAppName = "testApp"; task.CFDeleteRoutes = true; task.CFDeleteServices = true; task.BuildEngine = new FakeBuildEngine(); Assert.IsTrue(task.Execute()); } }
public async Task Should_remove_app_from_indexes_if_app_gets_deleted() { CreateApp(isArchived: true); var command = new DeleteApp { AppId = appId }; var context = new CommandContext(command, commandBus) .Complete(); await sut.HandleAsync(context); A.CallTo(() => cache.RemoveAsync(appId.Id)) .MustHaveHappened(); }
private void DeleteApp(DeleteApp command) { Raise(command, new AppDeleted()); }
public void Flow_IntegrationTest() { LoginTask login = new LoginTask(); login.BuildEngine = new FakeBuildEngine(); login.CFUser = Settings.Default.User; login.CFPassword = Settings.Default.Password; login.CFServerUri = Settings.Default.ServerUri; login.CFSkipSslValidation = true; login.Execute(); CreateApp task = new CreateApp(); task.CFRefreshToken = login.CFRefreshToken; task.CFServerUri = Settings.Default.ServerUri; task.CFSkipSslValidation = true; task.CFAppName = "testIntegration"; task.CFAppMemory = 512; task.CFAppInstances = 1; task.CFSpace = "TestSpace"; task.CFOrganization = "TestOrg"; task.CFStack = "win2012"; task.CFEnvironmentJson = "{\"mykey\":\"abcd\",\"secondkey\":\"efgh\"}"; task.BuildEngine = new FakeBuildEngine(); task.Execute(); PushApp pushTask = new PushApp(); pushTask.CFUser = Settings.Default.User; pushTask.CFPassword = Settings.Default.Password; pushTask.CFServerUri = Settings.Default.ServerUri; pushTask.CFSkipSslValidation = true; pushTask.CFAppGuid = task.CFAppGuid; pushTask.CFAppPath = Settings.Default.AppPath; pushTask.CFStart = true; pushTask.BuildEngine = new FakeBuildEngine(); pushTask.Execute(); CreateRoutes routeTask = new CreateRoutes(); routeTask.CFUser = Settings.Default.User; routeTask.CFPassword = Settings.Default.Password; routeTask.CFServerUri = Settings.Default.ServerUri; routeTask.CFSkipSslValidation = true; routeTask.CFRoutes = new string[1] { "testRoute.15.126.213.170.xip.io" }; routeTask.CFSpace = "TestSpace"; routeTask.CFOrganization = "TestOrg"; routeTask.BuildEngine = new FakeBuildEngine(); routeTask.Execute(); BindRoutes bindTask = new BindRoutes(); bindTask.CFUser = Settings.Default.User; bindTask.CFPassword = Settings.Default.Password; bindTask.CFServerUri = Settings.Default.ServerUri; bindTask.BuildEngine = new FakeBuildEngine(); bindTask.CFSkipSslValidation = true; bindTask.CFAppGuid = task.CFAppGuid; bindTask.CFRouteGuids = routeTask.CFRouteGuids; bindTask.Execute(); CreateService serviceTask = new CreateService(); serviceTask.CFUser = Settings.Default.User; serviceTask.CFPassword = Settings.Default.Password; serviceTask.CFServerUri = Settings.Default.ServerUri; serviceTask.BuildEngine = new FakeBuildEngine(); serviceTask.CFSkipSslValidation = true; serviceTask.CFServiceName = "testService"; serviceTask.CFServicePlan = "free"; serviceTask.CFServiceType = "mysql"; serviceTask.CFSpace = "TestSpace"; serviceTask.CFOrganization = "TestOrg"; serviceTask.Execute(); BindServices bindServiceTask = new BindServices(); bindServiceTask.CFUser = Settings.Default.User; bindServiceTask.CFPassword = Settings.Default.Password; bindServiceTask.CFServerUri = Settings.Default.ServerUri; bindServiceTask.BuildEngine = new FakeBuildEngine(); bindServiceTask.CFSkipSslValidation = true; bindServiceTask.CFAppGuid = task.CFAppGuid; bindServiceTask.CFServicesGuids = new string[1] { serviceTask.CFServiceGuid }; bindServiceTask.Execute(); if (CheckIfAppIsWorking(routeTask.CFRoutes[0], 3) == true) { DeleteApp delTask = new DeleteApp(); delTask.CFUser = Settings.Default.User; delTask.CFPassword = Settings.Default.Password; delTask.CFServerUri = Settings.Default.ServerUri; delTask.CFSkipSslValidation = true; delTask.CFOrganization = "TestOrg"; delTask.CFSpace = "TestSpace"; delTask.CFAppName = "testIntegration"; delTask.CFDeleteServices = true; delTask.CFDeleteRoutes = true; delTask.BuildEngine = new FakeBuildEngine(); Assert.IsTrue(delTask.Execute()); } else { Assert.Fail("Application is not working"); } }
public void Flow_IntegrationTest() { string assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string appPath = Path.Combine(assemblyDirectory, "TestApp"); LoginTask login = new LoginTask(); login.BuildEngine = new FakeBuildEngine(); login.CFUser = Settings.Default.User; login.CFPassword = Settings.Default.Password; login.CFServerUri = Settings.Default.ServerUri; login.CFSkipSslValidation = true; login.Execute(); CreateApp task = new CreateApp(); task.CFRefreshToken = login.CFRefreshToken; task.CFServerUri = Settings.Default.ServerUri; task.CFSkipSslValidation = true; task.CFAppName = Guid.NewGuid().ToString("N"); task.CFAppMemory = 256; task.CFAppInstances = 1; task.CFSpace = Settings.Default.Space; task.CFOrganization = Settings.Default.Organization; task.CFStack = Settings.Default.Stack; task.CFEnvironmentJson = "{\"mykey\":\"abcd\",\"secondkey\":\"efgh\"}"; task.BuildEngine = new FakeBuildEngine(); task.Execute(); PushApp pushTask = new PushApp(); pushTask.CFUser = Settings.Default.User; pushTask.CFPassword = Settings.Default.Password; pushTask.CFServerUri = Settings.Default.ServerUri; pushTask.CFSkipSslValidation = true; pushTask.CFAppGuid = task.CFAppGuid; pushTask.CFAppPath = appPath; pushTask.CFStart = true; pushTask.BuildEngine = new FakeBuildEngine(); pushTask.Execute(); CreateRoutes routeTask = new CreateRoutes(); routeTask.CFUser = Settings.Default.User; routeTask.CFPassword = Settings.Default.Password; routeTask.CFServerUri = Settings.Default.ServerUri; routeTask.CFSkipSslValidation = true; routeTask.CFRoutes = new string[1] { string.Format(Settings.Default.Route, task.CFAppName) }; routeTask.CFSpace = Settings.Default.Space; routeTask.CFOrganization = Settings.Default.Organization; routeTask.BuildEngine = new FakeBuildEngine(); routeTask.Execute(); BindRoutes bindTask = new BindRoutes(); bindTask.CFUser = Settings.Default.User; bindTask.CFPassword = Settings.Default.Password; bindTask.CFServerUri = Settings.Default.ServerUri; bindTask.BuildEngine = new FakeBuildEngine(); bindTask.CFSkipSslValidation = true; bindTask.CFAppGuid = task.CFAppGuid; bindTask.CFRouteGuids = routeTask.CFRouteGuids; bindTask.Execute(); CreateService serviceTask = new CreateService(); serviceTask.CFUser = Settings.Default.User; serviceTask.CFPassword = Settings.Default.Password; serviceTask.CFServerUri = Settings.Default.ServerUri; serviceTask.BuildEngine = new FakeBuildEngine(); serviceTask.CFSkipSslValidation = true; serviceTask.CFServiceName = Guid.NewGuid().ToString("N"); serviceTask.CFServicePlan = Settings.Default.ServicePlan; serviceTask.CFServiceType = Settings.Default.ServiceType; serviceTask.CFSpace = Settings.Default.Space; serviceTask.CFOrganization = Settings.Default.Organization; serviceTask.Execute(); BindServices bindServiceTask = new BindServices(); bindServiceTask.CFUser = Settings.Default.User; bindServiceTask.CFPassword = Settings.Default.Password; bindServiceTask.CFServerUri = Settings.Default.ServerUri; bindServiceTask.BuildEngine = new FakeBuildEngine(); bindServiceTask.CFSkipSslValidation = true; bindServiceTask.CFAppGuid = task.CFAppGuid; bindServiceTask.CFServicesGuids = new string[1] { serviceTask.CFServiceGuid }; bindServiceTask.Execute(); if (CheckIfAppIsWorking(routeTask.CFRoutes[0], 60) == true) { DeleteApp delTask = new DeleteApp(); delTask.CFUser = Settings.Default.User; delTask.CFPassword = Settings.Default.Password; delTask.CFServerUri = Settings.Default.ServerUri; delTask.CFSkipSslValidation = true; delTask.CFSpace = Settings.Default.Space; delTask.CFOrganization = Settings.Default.Organization; delTask.CFAppName = task.CFAppName; delTask.CFDeleteServices = true; delTask.CFDeleteRoutes = true; delTask.BuildEngine = new FakeBuildEngine(); Assert.IsTrue(delTask.Execute()); } else { Assert.Fail("Application is not working"); } }
private bool RunTasks(string manifest, string host, string appPath) { LoginTask login = new LoginTask(); login.BuildEngine = new FakeBuildEngine(); login.CFUser = Settings.Default.User; login.CFPassword = Settings.Default.Password; login.CFServerUri = Settings.Default.ServerUri; login.CFManifest = manifest; login.CFSkipSslValidation = true; login.Execute(); CreateApp task = new CreateApp(); task.CFRefreshToken = login.CFRefreshToken; task.CFServerUri = Settings.Default.ServerUri; task.CFSkipSslValidation = true; task.CFSpace = Settings.Default.Space; task.CFOrganization = Settings.Default.Organization; task.CFManifest = manifest; task.BuildEngine = new FakeBuildEngine(); task.Execute(); PushApp pushTask = new PushApp(); pushTask.CFUser = Settings.Default.User; pushTask.CFPassword = Settings.Default.Password; pushTask.CFServerUri = Settings.Default.ServerUri; pushTask.CFSkipSslValidation = true; pushTask.CFManifest = manifest; pushTask.CFOrganization = Settings.Default.Organization; pushTask.CFSpace = Settings.Default.Space; pushTask.CFAppPath = appPath; pushTask.BuildEngine = new FakeBuildEngine(); pushTask.Execute(); CreateRoutes routeTask = new CreateRoutes(); routeTask.CFUser = Settings.Default.User; routeTask.CFPassword = Settings.Default.Password; routeTask.CFServerUri = Settings.Default.ServerUri; routeTask.CFSkipSslValidation = true; routeTask.CFManifest = manifest; routeTask.CFSpace = Settings.Default.Space; routeTask.CFOrganization = Settings.Default.Organization; routeTask.BuildEngine = new FakeBuildEngine(); routeTask.Execute(); BindRoutes bindTask = new BindRoutes(); bindTask.CFUser = Settings.Default.User; bindTask.CFPassword = Settings.Default.Password; bindTask.CFServerUri = Settings.Default.ServerUri; bindTask.BuildEngine = new FakeBuildEngine(); bindTask.CFSkipSslValidation = true; bindTask.CFManifest = manifest; bindTask.CFOrganization = Settings.Default.Organization; bindTask.CFSpace = Settings.Default.Space; bindTask.Execute(); BindServices bindServiceTask = new BindServices(); bindServiceTask.CFUser = Settings.Default.User; bindServiceTask.CFPassword = Settings.Default.Password; bindServiceTask.CFServerUri = Settings.Default.ServerUri; bindServiceTask.BuildEngine = new FakeBuildEngine(); bindServiceTask.CFSkipSslValidation = true; bindServiceTask.CFManifest = manifest; bindServiceTask.CFOrganization = Settings.Default.Organization; bindServiceTask.CFSpace = Settings.Default.Space; bindServiceTask.Execute(); RestartApp restartTask = new RestartApp(); restartTask.BuildEngine = new FakeBuildEngine(); restartTask.CFUser = Settings.Default.User; restartTask.CFPassword = Settings.Default.Password; restartTask.CFServerUri = Settings.Default.ServerUri; restartTask.CFManifest = manifest; restartTask.CFSkipSslValidation = true; restartTask.CFOrganization = Settings.Default.Organization; restartTask.CFSpace = Settings.Default.Space; restartTask.Execute(); if (CheckIfAppIsWorking(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", host, Settings.Default.Domain), 60) == true) { DeleteApp delTask = new DeleteApp(); delTask.CFUser = Settings.Default.User; delTask.CFPassword = Settings.Default.Password; delTask.CFServerUri = Settings.Default.ServerUri; delTask.CFSkipSslValidation = true; delTask.CFSpace = Settings.Default.Space; delTask.CFOrganization = Settings.Default.Organization; delTask.CFManifest = manifest; delTask.CFDeleteServices = true; delTask.CFDeleteRoutes = true; delTask.BuildEngine = new FakeBuildEngine(); return(delTask.Execute()); } else { return(false); } }
private async Task OnDeleteAsync(DeleteApp delete) { await InvalidateItAsync(delete.AppId.Id, delete.AppId.Name); await Cache().RemoveAsync(delete.AppId.Id); }