public void TestDelete() { const string test = "foo"; try { // Arrange var ts = new TenantService(); using (new GlobalAdministratorContext()) { var id = TenantHelper.CreateTenant(test); id.Should().BeGreaterThan(0); } // Act ts.Delete(test); // Assert using (new GlobalAdministratorContext()) { TenantHelper.GetTenantId(test).Should().BeLessThan(0); } Action a1 = () => ts.Delete(null); a1.ShouldThrow <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: tenantName"); Action a2 = () => ts.Delete(string.Empty); a2.ShouldThrow <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: tenantName"); } finally { using (new GlobalAdministratorContext()) { var testId = TenantHelper.GetTenantId(test); if (testId > 0) { TenantHelper.DeleteTenant(testId); } } } }
public async void Delete() { var mock = new ServiceMockFacade<ITenantRepository>(); var model = new ApiTenantRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny<string>())).Returns(Task.CompletedTask); var service = new TenantService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.TenantModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLTenantMapperMock, mock.DALMapperMockFactory.DALTenantMapperMock); ActionResponse response = await service.Delete(default(string)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny<string>())); mock.ModelValidatorMockFactory.TenantModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny<string>())); }
public HttpResponseMessage Delete(int Id) { tenantService.Delete(Id); return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <ActionResult> Delete(int id) { return(Ok(await _service.Delete(id))); }
/// <summary> /// Carries out an operation on a <see cref="Tenant"/> on this plaform identified by the request. /// </summary> /// <param name="tenantRequest">The request.</param> /// <returns>The response.</returns> public TenantInfoResponse TenantOperation(TenantOperationRequest tenantRequest) { using (Profiler.Measure("CastActivityService.TenantOperation")) { var response = new TenantInfoResponse { Tenants = new TenantList() }; try { if (tenantRequest == null) { throw new ArgumentNullException("tenantRequest"); } if (string.IsNullOrEmpty(tenantRequest.Name)) { throw new ArgumentException("Tenant name may not be empty."); } if (!CastService.GetIsCastConfigured()) { throw new InvalidOperationException(); } var name = tenantRequest.Name; switch (tenantRequest.Operation) { case Operation.Create: TenantService.Create(name); break; case Operation.Delete: TenantService.Delete(name); break; case Operation.Enable: TenantService.Enable(name); break; case Operation.Disable: TenantService.Disable(name); break; case Operation.Rename: TenantService.Rename(tenantRequest.Id, tenantRequest.Name); break; default: throw new NotSupportedException(tenantRequest.Operation.ToString()); } if (tenantRequest.Operation != Operation.Delete) { var ti = TenantService.GetTenant(name); if (ti != null) { response.Tenants.Add(ti); } } } catch (Exception e) { response.IsError = true; response.Error = e.Message; } return(response); } }