public void performing_updates_has_information_about_failure_modules_operations_throws() { ModulesOperations.Setup(x => x.LoadModules(It.IsAny <IModuleDiscovery>())) .Throws(new Exception("Can not discovery moduels")); var moduleManifests = new List <ModuleManifest> { new ModuleManifest(), }; // preapre stub module manifest NomadUpdater.PrepareUpdate(moduleManifests); ModulesRepository.Setup(x => x.GetModule(It.IsAny <string>())) .Returns(new ModulePackage() { ModuleManifest = moduleManifests[0] }); NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); // wait till end to get the information about failure NomadUpdater.UpdateFinished.WaitOne(); Assert.AreEqual(UpdaterStatus.Invalid, NomadUpdater.Status); }
public void performing_updates_unload_modules() { NomadUpdater.PerformUpdates(new CompositeModuleDiscovery()); NomadUpdater.UpdateFinished.WaitOne(); ModulesOperations.Verify(x => x.UnloadModules(), Times.Exactly(1)); }
private static List <string> GetModules(string header) { List <string> apiNames = new List <string>(); HeaderMap headerMap = new HeaderMap(); if (header != null) { DateTimeOffset headerValue = DateTimeOffset.FromUnixTimeMilliseconds(Convert.ToInt64(header)); DateTimeOffset targetTime = TimeZoneInfo.ConvertTime(headerValue, TimeZoneInfo.Local); headerMap.Add(GetModulesHeader.IF_MODIFIED_SINCE, targetTime); } APIResponse <Com.Zoho.Crm.API.Modules.ResponseHandler> response = new ModulesOperations().GetModules(headerMap); if (response != null) { if (new List <int>() { Constants.NO_CONTENT_STATUS_CODE, Constants.NOT_MODIFIED_STATUS_CODE }.Contains(response.StatusCode)) { return(apiNames); } // Check if expected response is received if (response.IsExpected) { Com.Zoho.Crm.API.Modules.ResponseHandler responseObject = response.Object; if (responseObject is Com.Zoho.Crm.API.Modules.ResponseWrapper) { List <Module> modules = ((Com.Zoho.Crm.API.Modules.ResponseWrapper)responseObject).Modules; foreach (Module module in modules) { if (module.APISupported != null && (bool)module.APISupported) { apiNames.Add(module.APIName); } } } else if (responseObject is Com.Zoho.Crm.API.Modules.APIException) { Com.Zoho.Crm.API.Modules.APIException exception = (Com.Zoho.Crm.API.Modules.APIException)responseObject; JObject errorResponse = new JObject(); errorResponse.Add(Constants.CODE, exception.Code.Value); errorResponse.Add(Constants.STATUS, exception.Status.Value); errorResponse.Add(Constants.MESSAGE, exception.Message.Value); throw new SDKException(Constants.API_EXCEPTION, errorResponse); } } } return(apiNames); }