/// <summary> /// Verifies the <b>Container</b>. This method will call all registered delegates, /// iterate registered collections and throws an exception if there was an error. /// </summary> /// <param name="option">Specifies how the container should verify its configuration.</param> /// <exception cref="InvalidOperationException">Thrown when the registration of instances was /// invalid.</exception> /// <exception cref="DiagnosticVerificationException">Thrown in case there are diagnostic errors and /// the <see cref="VerificationOption.VerifyAndDiagnose"/> option is supplied.</exception> /// <exception cref="ArgumentException">Thrown when <paramref name="option"/> has an invalid value.</exception> public void Verify(VerificationOption option) { Requires.IsValidEnum(option, "option"); this.VerifyInternal(); if (option == VerificationOption.VerifyAndDiagnose) { this.DiagnoseInternal(); } }
/// <summary> /// Verifies the <b>Container</b>. This method will call all registered delegates, /// iterate registered collections and throws an exception if there was an error. /// </summary> /// <param name="option">Specifies how the container should verify its configuration.</param> /// <exception cref="InvalidOperationException">Thrown when the registration of instances was /// invalid.</exception> /// <exception cref="DiagnosticVerificationException">Thrown in case there are diagnostic errors and /// the <see cref="VerificationOption.VerifyAndDiagnose"/> option is supplied.</exception> /// <exception cref="ArgumentException">Thrown when <paramref name="option"/> has an invalid value.</exception> public void Verify(VerificationOption option) { Requires.IsValidEnum(option, nameof(option)); bool diagnose = option == VerificationOption.VerifyAndDiagnose; this.VerifyInternal(suppressLifestyleMismatchVerification: diagnose); if (diagnose) { this.ThrowOnDiagnosticWarnings(); } }
public void Verify_SuppliedWithInvalidVerificationOptionEnum_ThrowsExpectedException() { // Arrange VerificationOption invalidOption = (VerificationOption)2; var container = new Container(); // Act Action action = () => container.Verify(invalidOption); // Assert AssertThat.ThrowsWithExceptionMessageContains <ArgumentException>( "The value of argument 'option' (2) is invalid for Enum type 'VerificationOption'.", action); }
private Task <ActivationResult> DoVerify(VerificationOption option) { return(Task <ActivationResult> .Factory.StartNew(() => { var response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), GetSettingsTelegramSettings(), option == VerificationOption.Voice); if (response == null || response.Response != Telegram.CodeRequest.Type.Success) { var message = Localize.GetString("TelegramVerifyError"); if (response != null) { if (response.Response == Telegram.CodeRequest.Type.NumberInvalid) { message = Localize.GetString("TelegramVerifyInvalidNumber"); } } return new ActivationResult { Success = false, ErrorMessage = message, }; } if (option == VerificationOption.Sms) { SetSettingsCodeHash(response.CodeHash); SetSettingsRegistered(response.Registered); } return new ActivationResult { Success = true }; })); }
private Task<ActivationResult> DoVerify(VerificationOption option) { return Task<ActivationResult>.Factory.StartNew(() => { var settings = GetSettingsTelegramSettings(); var response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), GetSettingsTelegramSettings(), option == VerificationOption.Voice); if (response.Response == Telegram.CodeRequest.Type.Migrate) { TelegramSettings newSettings; using (var migratedClient = Telegram.GetNewClient(response.MigrateId, GetSettingsTelegramSettings(), out newSettings)) { TelegramUtils.RunSynchronously(migratedClient.Connect()); response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), newSettings, option == VerificationOption.Voice); Utils.DebugPrint(">>>>> Response from the server " + ObjectDumper.Dump(response)); if (option == VerificationOption.Sms) { SetSettingsSettings(newSettings, false); SetSettingsCodeHash(response.CodeHash, false); SetSettingsRegistered(response.Registered, false); } return new ActivationResult { Success = true, }; } } if (response == null || response.Response != Telegram.CodeRequest.Type.Success) { var message = Localize.GetString("TelegramVerifyError"); if (response != null) { if (response.Response == Telegram.CodeRequest.Type.NumberInvalid) { message = Localize.GetString("TelegramVerifyInvalidNumber"); } } return new ActivationResult { Success = false, ErrorMessage = message, }; } if (option == VerificationOption.Sms) { SetSettingsCodeHash(response.CodeHash,true); SetSettingsRegistered(response.Registered,true); } return new ActivationResult { Success = true }; }); }
private Task<ActivationResult> DoVerify(VerificationOption option) { return Task<ActivationResult>.Factory.StartNew(() => { var response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), GetSettingsTelegramSettings(), option == VerificationOption.Voice); if (response == null || response.Response != Telegram.CodeRequest.Type.Success) { var message = Localize.GetString("TelegramVerifyError"); if (response != null) { if (response.Response == Telegram.CodeRequest.Type.NumberInvalid) { message = Localize.GetString("TelegramVerifyInvalidNumber"); } } return new ActivationResult { Success = false, ErrorMessage = message, }; } if (option == VerificationOption.Sms) { SetSettingsCodeHash(response.CodeHash); SetSettingsRegistered(response.Registered); } return new ActivationResult { Success = true }; }); }
private Task <ActivationResult> DoVerify(VerificationOption option) { return(Task <ActivationResult> .Factory.StartNew(() => { var settings = GetSettingsTelegramSettings(); var response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), GetSettingsTelegramSettings(), option == VerificationOption.Voice); if (response.Response == Telegram.CodeRequest.Type.Migrate) { TelegramSettings newSettings; using (var migratedClient = Telegram.GetNewClient(response.MigrateId, GetSettingsTelegramSettings(), out newSettings)) { TelegramUtils.RunSynchronously(migratedClient.Connect()); response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), newSettings, option == VerificationOption.Voice); Utils.DebugPrint(">>>>> Response from the server " + ObjectDumper.Dump(response)); if (option == VerificationOption.Sms) { SetSettingsSettings(newSettings, false); SetSettingsCodeHash(response.CodeHash, false); SetSettingsRegistered(response.Registered, false); } return new ActivationResult { Success = true, }; } } if (response == null || response.Response != Telegram.CodeRequest.Type.Success) { var message = Localize.GetString("TelegramVerifyError"); if (response != null) { if (response.Response == Telegram.CodeRequest.Type.NumberInvalid) { message = Localize.GetString("TelegramVerifyInvalidNumber"); } } return new ActivationResult { Success = false, ErrorMessage = message, }; } if (option == VerificationOption.Sms) { SetSettingsCodeHash(response.CodeHash, true); SetSettingsRegistered(response.Registered, true); } return new ActivationResult { Success = true }; })); }