public void MSFSSHTTP_FSSHTTPB_S04_TC06_ExclusiveLock_FileNotExistsOrCannotBeCreated() { // Initialize the service this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); string notExistsFileUrl = this.DefaultFileUrl.Substring(0, this.DefaultFileUrl.LastIndexOf('/')) + "/noexistsFile.txt"; ExclusiveLockSubRequestType subRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock); // Get the exclusive lock with nonexistent file URL and expect the server returns error code "LockRequestFail" or "Unknown". CellStorageResponse response = this.Adapter.CellStorageRequest(notExistsFileUrl, new SubRequestType[] { subRequest }); ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site); ErrorCodeType errorType = SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site); bool isR1926Verified = errorType == ErrorCodeType.LockRequestFail || errorType == ErrorCodeType.Unknown || errorType == ErrorCodeType.FileNotExistsOrCannotBeCreated; this.Site.Log.Add( LogEntryKind.Debug, "For requirement MS-FSSHTTP_R1926, expect the error code LockRequestFail or Unknown or FileNotExistsOrCannotBeCreated, but actually error code is " + errorType); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1926 Site.CaptureRequirementIfIsTrue( isR1926Verified, "MS-FSSHTTP", 1926, @"[In ExclusiveLock Subrequest][The protocol returns results based on the following conditions: ] If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""LockRequestFail "" or ""Unknown"" or ""FileNotExistsOrCannotBeCreated"" in the ErrorCode attribute sent back in the SubResponse element."); } else { Site.Assert.IsTrue( isR1926Verified, @"[In ExclusiveLock Subrequest][The protocol returns results based on the following conditions: ] If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""LockRequestFail "" or ""Unknown"" or ""FileNotExistsOrCannotBeCreated"" in the ErrorCode attribute sent back in the SubResponse element."); } }
internal static string ToSerializedValue(this ErrorCodeType value) { switch (value) { case ErrorCodeType.InvalidInputField: return("InvalidInputField"); case ErrorCodeType.BadRequest: return("BadRequest"); case ErrorCodeType.LowBalance: return("LowBalance"); case ErrorCodeType.AlreadyProcessed: return("AlreadyProcessed"); case ErrorCodeType.UnknownAsset: return("UnknownAsset"); case ErrorCodeType.NoLiquidity: return("NoLiquidity"); case ErrorCodeType.NotEnoughFunds: return("NotEnoughFunds"); case ErrorCodeType.Dust: return("Dust"); case ErrorCodeType.ReservedVolumeHigherThanBalance: return("ReservedVolumeHigherThanBalance"); case ErrorCodeType.NotFound: return("NotFound"); case ErrorCodeType.BalanceLowerThanReserved: return("BalanceLowerThanReserved"); case ErrorCodeType.LeadToNegativeSpread: return("LeadToNegativeSpread"); case ErrorCodeType.InvalidFee: return("InvalidFee"); case ErrorCodeType.Duplicate: return("Duplicate"); case ErrorCodeType.InvalidPrice: return("InvalidPrice"); case ErrorCodeType.Replaced: return("Replaced"); case ErrorCodeType.NotFoundPrevious: return("NotFoundPrevious"); case ErrorCodeType.Runtime: return("Runtime"); } return(null); }
public void MSFSSHTTP_FSSHTTPB_TestCase_S16_TC01_Versioning_EmptyUrl() { // Initialize the service this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); VersioningSubRequestType versioningSubRequest = SharedTestSuiteHelper.CreateVersioningSubRequest(SequenceNumberGenerator.GetCurrentToken(), VersioningRequestTypes.GetVersionList, null, this.Site); CellStorageResponse cellStoreageResponse = Adapter.CellStorageRequest(string.Empty, new SubRequestType[] { versioningSubRequest }); if (Common.IsRequirementEnabled(11151, this.Site)) { SubResponseType subResponse = cellStoreageResponse.ResponseCollection.Response[0].SubResponse[0]; ErrorCodeType errorCode = SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11151 Site.CaptureRequirementIfAreNotEqual <ErrorCodeType>( ErrorCodeType.Success, errorCode, "MS-FSSHTTP", 11151, @"[In VersioningSubResponseType] In the case of failure, the ErrorCode attribute that is part of a SubResponse element specifies the error code result for this subrequest."); } else { Site.Assert.AreNotEqual <ErrorCodeType>( ErrorCodeType.Success, errorCode, "Error should occur if call versioning request with empty url."); } } }
/// <summary> /// 设置为成功 /// </summary> public void SetSuccess() { ErrorCodeType messageType = ErrorCodeType.Success; ErrorCode = $"{(int)messageType}"; ErrorMessage = messageType.GetDescription(); }
/// <summary> /// Capture requirements related with CellRequestErrorCodeTypes. /// </summary> /// <param name="cellRequestErrorCode">A cellRequestErrorCode</param> /// <param name="site">Instance of ITestSite</param> private static void ValidateCellRequestErrorCodeTypes(ErrorCodeType cellRequestErrorCode, ITestSite site) { if (cellRequestErrorCode == ErrorCodeType.CellRequestFail || cellRequestErrorCode == ErrorCodeType.IRMDocLibarysOnlySupportWebDAV) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R772 site.CaptureRequirement( "MS-FSSHTTP", 772, @"[In CellRequestErrorCodeTypes][CellRequestErrorCodeTypes schema is:] <xs:simpleType name=""CellRequestErrorCodeTypes""> <xs:restriction base=""xs:string""> <!--cell request fail--> <xs:enumeration value=""CellRequestFail""/> <!--cell request etag not matching--> <xs:enumeration value=""IRMDocLibarysOnlySupportWebDAV""/> </xs:restriction> </xs:simpleType>"); // If the validation succeed, then the requirement MS-FSSHTTP_R773 can be captured. site.CaptureRequirement( "MS-FSSHTTP", 773, @"[In CellRequestErrorCodeTypes] The value of CellRequestErrorCodeTypes MUST be one of the following: [CellRequestFail, IRMDocLibarysOnlySupportWebDAV]"); } }
/// <summary> /// Initializes a new instance of the ErrorModel class. /// </summary> /// <param name="code">Well-known error code. Possible values include: /// 'InvalidInputField', 'BadRequest', 'LowBalance', /// 'AlreadyProcessed', 'UnknownAsset', 'NoLiquidity', /// 'NotEnoughFunds', 'Dust', 'ReservedVolumeHigherThanBalance', /// 'NotFound', 'BalanceLowerThanReserved', 'LeadToNegativeSpread', /// 'InvalidFee', 'Duplicate', 'InvalidPrice', 'Replaced', /// 'NotFoundPrevious', 'Runtime'</param> /// <param name="field">In case ErrorCoderType = 0</param> /// <param name="message">Localized Error message</param> public ErrorModel(ErrorCodeType code, string field, string message) { Code = code; Field = field; Message = message; CustomInit(); }
/// <summary> /// 消息返回 /// </summary> /// <param name="data"></param> /// <returns></returns> protected object RespMsg(ErrorCodeType code, string msg, object data = null) { object result = null; if (data is DataTable) { var dataTable = ConvertUtil.ConvertDataTableToList(data as DataTable); result = new { return_code = code.GetHashCode(), return_msg = msg, return_data = dataTable }; } else if (data is DataSet) { var dataSet = ConvertUtil.ConvertDataSetToDictionary(data as DataSet); result = new { return_code = code.GetHashCode(), return_msg = msg, return_data = dataSet }; } else if (data == null) { result = new { return_code = code.GetHashCode(), return_msg = msg }; } else { result = new { return_code = code.GetHashCode(), return_msg = msg, return_data = data }; } return(result); }
/// <summary> /// Transports constituent mass through pipe network /// under a period of constant hydraulic conditions. /// </summary> private ErrorCodeType Transport(long tstep) { ErrorCodeType errcode = 0; // --- repeat until time step is exhausted long qtime = 0; while (errcode == 0 && qtime < tstep) { // Qstep is nominal quality time step long dt = Math.Min(_msx.Qstep, tstep - qtime); qtime += dt; // update amount of input tstep taken errcode = _chemical.MSXchem_react(dt); // react species in each pipe & tank if (errcode != 0) { return(errcode); } AdvectSegs(dt); // advect segments in each pipe Accumulate(dt); // accumulate all inflows at nodes UpdateNodes(dt); // update nodal quality SourceInput(dt); // compute nodal inputs from sources Release(dt); // release new outflows from nodes } return(errcode); }
public ErrorCodeType Load(string msxFile) { ErrorCodeType err = 0; err = Utilities.Call(err, project.MSXproj_open(msxFile)); err = Utilities.Call(err, quality.MSXqual_open()); return(err); }
///<summary>computes reactions in all pipes and tanks.</summary> public ErrorCodeType MSXchem_react(long dt) { ErrorCodeType errcode = 0; // Save tolerances of pipe rate species for (int i = 1; i <= numPipeRateSpecies; i++) { int j = pipeRateSpecies[i]; atol[i] = msx.Species[j].ATol; rtol[i] = msx.Species[j].RTol; } // Examine each link for (int i = 1; i <= msx.Nobjects[(int)ObjectTypes.LINK]; i++) { // Skip non-pipe links if (msx.Link[i].Len == 0.0) { continue; } // Evaluate hydraulic variables EvalHydVariables(i); // Compute pipe reactions errcode = EvalPipeReactions(i, dt); if (errcode != 0) { return(errcode); } } // Save tolerances of tank rate species for (int i = 1; i <= numTankRateSpecies; i++) { int j = tankRateSpecies[i]; atol[i] = msx.Species[j].ATol; rtol[i] = msx.Species[j].RTol; } // Examine each tank for (int i = 1; i <= msx.Nobjects[(int)ObjectTypes.TANK]; i++) { // Skip reservoirs if (msx.Tank[i].A == 0.0) { continue; } // Compute tank reactions errcode = EvalTankReactions(i, dt); if (errcode != 0) { return(errcode); } } return(errcode); }
public static ResponseModel CreateFail(ErrorCodeType errorCodeType, string message) { return new ResponseModel { Error = new ErrorModel { Code = errorCodeType, Message = message } }; }
public static ResponseModel CreateFail(ErrorCodeType errorCodeType, string message) { return(new ResponseModel { Error = new ErrorModel { Code = errorCodeType, Message = message } }); }
public void AuthService_Login_UserDoesNotExist_Failure() { // Arrange ErrorCodeType expectedErrorCode = ErrorCodeType.MemberNotFound; UserToLogin user = GetUserToLogin(); // Act LoginResult loginResult = _authService.Login(user); // Assert AssertExpectedFailureResultForLogin(loginResult, expectedErrorCode); }
public ApiResultModel(ErrorCodeType _code, string msg) { Code = _code; if (msg != null && msg.Length > 0) { Msg = msg; } else { SetErrorCodeTypeMsg(); } }
/// <summary> /// 抛出对应类型的错误 /// </summary> /// <param name="type"></param> /// <param name="details"></param> public static Exception ThrowError(ErrorCodeType type, string details = null) { if (type == ErrorCodeType.UserAuthError) { return(new UserFriendlyException((int)ErrorCodeType.UserAuthError, L(ErrorCodeType.UserAuthError.ToString()), details)); } else if (type == ErrorCodeType.HomeOwerNotExists) { return(new UserFriendlyException((int)ErrorCodeType.HomeOwerNotExists, L(ErrorCodeType.HomeOwerNotExists.ToString()), details)); } else if (type == ErrorCodeType.HomeOwerUserNotExists) { return(new UserFriendlyException((int)ErrorCodeType.HomeOwerUserNotExists, L(ErrorCodeType.HomeOwerUserNotExists.ToString()), details)); } else if (type == ErrorCodeType.SMSSendCodeError) { return(new UserFriendlyException((int)ErrorCodeType.SMSSendCodeError, L(ErrorCodeType.SMSSendCodeError.ToString()), details)); } else if (type == ErrorCodeType.ValidateCodeError) { return(new UserFriendlyException((int)ErrorCodeType.ValidateCodeError, L(ErrorCodeType.ValidateCodeError.ToString()), details)); } else if (type == ErrorCodeType.DeliveryIsGathered) { return(new UserFriendlyException((int)ErrorCodeType.DeliveryIsGathered, L(ErrorCodeType.DeliveryIsGathered.ToString()), details)); } else if (type == ErrorCodeType.HomeOwerDoorNotExists) { return(new UserFriendlyException((int)ErrorCodeType.HomeOwerDoorNotExists, L(ErrorCodeType.HomeOwerDoorNotExists.ToString()), details)); } else if (type == ErrorCodeType.HomeOwerUserIsExists) { return(new UserFriendlyException((int)ErrorCodeType.HomeOwerUserIsExists, L(ErrorCodeType.HomeOwerUserIsExists.ToString()), details)); } else if (type == ErrorCodeType.HomeOwerUserIsAuthing) { return(new UserFriendlyException((int)ErrorCodeType.HomeOwerUserIsAuthing, L(ErrorCodeType.HomeOwerUserIsAuthing.ToString()), details)); } else if (type == ErrorCodeType.CreatedAccessKeyIsExistsButIsNotAuth) { return(new UserFriendlyException((int)ErrorCodeType.CreatedAccessKeyIsExistsButIsNotAuth, L(ErrorCodeType.CreatedAccessKeyIsExistsButIsNotAuth.ToString()), details)); } else if (type == ErrorCodeType.CreatedAccessKeyIsExists) { return(new UserFriendlyException((int)ErrorCodeType.CreatedAccessKeyIsExists, L(ErrorCodeType.CreatedAccessKeyIsExists.ToString()), details)); } else { return(new UserFriendlyException((int)ErrorCodeType.UnknowError, L(ErrorCodeType.UnknowError.ToString()), details)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the caption for the Unable to Import message box. /// </summary> /// <param name="codeType">Type of the code.</param> /// <returns>string for the message box caption</returns> /// ------------------------------------------------------------------------------------ private string GetDialogCaption(ErrorCodeType codeType) { switch (codeType) { case ErrorCodeType.BackTransErrorCode: return(ScriptureUtilsException.GetResourceString("kstidBTImportErrorCaption")); case ErrorCodeType.XmlErrorCode: return(ScriptureUtilsException.GetResourceString("kstidXmlImportErrorCaption")); default: return(ScriptureUtilsException.GetResourceString("kstidImportErrorCaption")); } }
public void AuthService_ConfirmEmail_TokenNotFound_Failure() { // Arrange ErrorCodeType expectedErrorCode = ErrorCodeType.ConfirmationTokenInfoNotFound; ConfirmationToken invalidToken = null; ReturnConfirmationToken(invalidToken); // Act Result confirmationResult = _authService.ConfirmEmail(Token); // Assert AssertExpectedFailureResultForConfirmEmail(confirmationResult, expectedErrorCode); }
public void AuthService_ConfirmEmail_TokenIsExpired_Failure() { // Arrange ErrorCodeType expectedErrorCode = ErrorCodeType.ConfirmationTokenIsExpired; ConfirmationToken invalidToken = GetConfirmationToken(UserId, expired: true); ReturnConfirmationToken(invalidToken); // Act Result confirmationResult = _authService.ConfirmEmail(Token); // Assert AssertExpectedFailureResultForConfirmEmail(confirmationResult, expectedErrorCode); }
public void AuthService_ConfirmEmail_ValidToken_ConfirmationFailed_Failure() { // Arrange ErrorCodeType expectedErrorCode = ErrorCodeType.UnknownError; ConfirmationToken valid = GetConfirmationToken(UserId); ReturnConfirmationToken(valid); EmailConfirmationFailed(UserId); // Act Result confirmationResult = _authService.ConfirmEmail(Token); // Assert AssertExpectedFailureResultForConfirmEmail(confirmationResult, expectedErrorCode, numberOfCalls: 1); }
public void AuthService_Login_ExistingUser_InvalidCredentialsOrUserIsNotApproved_Failure() { // Arrange ErrorCodeType expectedErrorCode = ErrorCodeType.MemberIsNotApprovedOrInvalidCredentials; UserToLogin user = GetUserToLogin(); ReturnExistingAdditionalInfo(user.Email); ReturnInvalidUserValue(Username, user.Password); // Act LoginResult loginResult = _authService.Login(user); // Assert AssertExpectedFailureResultForLogin(loginResult, expectedErrorCode); }
/// <summary> /// This method is used to test whether the exclusive lock with the specified id exist on the file. /// </summary> /// <param name="file">Specify the file.</param> /// <param name="exclusiveLockId">Specify the exclusive lock.</param> /// <param name="userName">Specify the user name of the user who calls cell storage service.</param> /// <param name="password">Specify the password of the user who calls cell storage service.</param> /// <param name="domain">Specify the domain of the user who calls cell storage service.</param> /// <returns>Return true if exist, otherwise return false.</returns> protected bool CheckExclusiveLockExist(string file, string exclusiveLockId, string userName, string password, string domain) { this.InitializeContext(file, userName, password, domain); // Generate a new schema lock id value which is different with the given one. System.Guid newId; do { newId = System.Guid.NewGuid(); }while (newId == new System.Guid(exclusiveLockId)); ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability); exclusiveLocksubRequest.SubRequestData.ExclusiveLockID = newId.ToString(); CellStorageResponse response = this.Adapter.CellStorageRequest(file, new SubRequestType[] { exclusiveLocksubRequest }); ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site); ErrorCodeType error = SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site); if (error == ErrorCodeType.FileAlreadyLockedOnServer) { // Now there could be kind of two conditions: // 1) There is an exclusive lock // 2) There is a schema lock // So it is needed to check the exclusive lock with the given exclusive lock id should exist. exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability); exclusiveLocksubRequest.SubRequestData.ExclusiveLockID = exclusiveLockId; response = this.Adapter.CellStorageRequest(file, new SubRequestType[] { exclusiveLocksubRequest }); exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site); return(SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site) == ErrorCodeType.Success); } else { if (error != ErrorCodeType.Success) { this.Site.Assert.Fail( "If the exclusive lock {0} does not exist, check the schema lock using the id {0} should success, but actual the result is {2}", exclusiveLockId, newId.ToString(), error.ToString()); } return(false); } }
public void TestCase_S17_TC02_FileOperation_ErrorCode() { // Initialize the service this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); FileOperationSubRequestType fileOperationSubRequest = new FileOperationSubRequestType(); fileOperationSubRequest.SubRequestToken = SequenceNumberGenerator.GetCurrentToken().ToString(); fileOperationSubRequest.SubRequestData = new FileOperationSubRequestDataType(); fileOperationSubRequest.SubRequestData.FileOperation = FileOperationRequestTypes.Rename; fileOperationSubRequest.SubRequestData.FileOperationRequestTypeSpecified = false; fileOperationSubRequest.SubRequestData.ExclusiveLockID = null; CellStorageResponse cellStoreageResponse = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { fileOperationSubRequest }); FileOperationSubResponseType subResponse = SharedTestSuiteHelper.ExtractSubResponse <FileOperationSubResponseType>(cellStoreageResponse, 0, 0, this.Site); ErrorCodeType errorCode = SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11267 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 11267, this.Site)) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11267 Site.CaptureRequirementIfAreEqual <ErrorCodeType>( ErrorCodeType.InvalidArgument, errorCode, "MS-FSSHTTP", 11267, @"[In Appendix B: Product Behavior] If the specified attributes[FileOperationRequestType attribute] are not provided, the implementation does return an ""InvalidArgument"" error code as part of the SubResponseData element associated with the file opeartion subresponse. (Microsoft Office 2010 suites/Microsoft SharePoint Foundation 2010/Microsoft SharePoint Server 2010/Microsoft SharePoint Workspace 2010/Microsoft Office 2016/Microsoft SharePoint Server 2016 follow this behavior.)"); } } else { if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 11267, this.Site)) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11267 Site.Assert.AreEqual <ErrorCodeType>( ErrorCodeType.InvalidArgument, errorCode, @"[In Appendix B: Product Behavior] If the specified attributes[FileOperationRequestType attribute] are not provided, the implementation does return an ""InvalidArgument"" error code as part of the SubResponseData element associated with the file opeartion subresponse. (Microsoft Office 2010 suites/Microsoft SharePoint Foundation 2010/Microsoft SharePoint Server 2010/Microsoft SharePoint Workspace 2010/Microsoft Office 2016/Microsoft SharePoint Server 2016 follow this behavior.)"); } } }
public void AccountService_Register_CanNotRegister_Failure() { // Arrange IMember existedMember = Substitute.For <IMember>(); ErrorCodeType expectedError = ErrorCodeType.MemberAlreadyExists; UserToRegister user = GetUserToRegister(); _memberService.GetByEmail(user.Email).Returns(existedMember); // Act Result registrationResult = _accountService.Register(user); // Assert Assert.IsNotNull(registrationResult, Common.ShowResponseTypeMismatchMessage(typeof(Result))); Assert.IsTrue(registrationResult.IsFailure, Common.ShowNotSatisfiedExpectationMessage(true, "registrationResult.IsFailure")); Assert.AreEqual(expectedError, registrationResult.ErrorCode, Common.ShowNotSatisfiedExpectationMessage(expectedError, registrationResult.ErrorCode)); _userRegistration.ReceivedWithAnyArgs(0).Register(null); }
/// <summary> /// Convert a ErrorCodeType to an host-byte ordered unsigned short /// </summary> /// <param name="mClass">The ErrorCodeType to convert</param> /// <returns> /// The unsigned short (16bits) matching the ErrorCodeType /// Return max UInt16 value if the mClass parameter is ErrorCodeType.Unmanaged /// </returns> public static UInt16 ErrorCodeTypeToUInt16(ErrorCodeType mClass) { foreach (FieldInfo field in typeof(ErrorCodeType).GetFields()) { if (field.Name == mClass.ToString()) { Object[] fieldAttributes = field.GetCustomAttributes(typeof(StunValueAttribute), false); if (fieldAttributes.Length == 1) { StunValueAttribute stunValueAttribute = fieldAttributes.GetValue(0) as StunValueAttribute; return(stunValueAttribute.Value); } } } return(0xFFFF); }
public void AccountService_Register_RegistrationFailed_Failure() { // Arrange IMember existedMember = null; ErrorCodeType expectedError = ErrorCodeType.UnknownError; UserToRegister user = GetUserToRegister(); _memberService.GetByEmail(user.Email).Returns(existedMember); UserRegistrationFailed(user); // Act Result registrationResult = _accountService.Register(user); // Assert Assert.IsNotNull(registrationResult, Common.ShowResponseTypeMismatchMessage(typeof(Result))); Assert.IsTrue(registrationResult.IsFailure, Common.ShowNotSatisfiedExpectationMessage(true, "registrationResult.IsFailure")); Assert.AreEqual(expectedError, registrationResult.ErrorCode, Common.ShowNotSatisfiedExpectationMessage(expectedError, registrationResult.ErrorCode)); _userRegistration.Received(1).Register(Arg.Is(RegistrationPredicate(user))); }
/// <summary>Opens an EPANET-MSX project.</summary> public ErrorCodeType MSXproj_open(string msxFile) { ErrorCodeType errcode = 0; //MSX.QualityOpened = false; StreamReader buffReader = File.OpenText(msxFile); // initialize data to default values this.msx.SetDefaults(); // Open the MSX input file //MSX.MsxFile.setFilename(fname); //if(!MSX.MsxFile.openAsTextReader()) // return ErrorCodeType.ERR_OPEN_MSX_FILE.id; // create hash tables to look up object ID names errcode = Utilities.Call(errcode, this.CreateHashTables()); // allocate memory for the required number of objects errcode = Utilities.Call(errcode, this.reader.CountMsxObjects(buffReader)); errcode = Utilities.Call(errcode, this.reader.CountNetObjects()); errcode = Utilities.Call(errcode, this.CreateObjects()); buffReader.Close(); buffReader = File.OpenText(msxFile); // Read in the EPANET and MSX object data errcode = Utilities.Call(errcode, this.reader.ReadNetData()); errcode = Utilities.Call(errcode, this.reader.ReadMsxData(buffReader)); //if (MSX.RptFile.getFilename().equals("")) // errcode = Utilities.CALL(errcode, openRptFile()); // Convert user's units to internal units errcode = Utilities.Call(errcode, this.ConvertUnits()); // Close input file //MSX.MsxFile.close(); return(errcode); }
/// <summary> /// 获取错误字符串 /// </summary> /// <param name="ex"></param> /// <returns></returns> public static ErrorCode GetErrorCode(Exception ex) { Type type = ex.GetType(); ErrorCode model = new ErrorCode(); try { ErrorCodeType errorCodeType = (ErrorCodeType)Enum.Parse(typeof(ErrorCodeType), type.Name); ErrorType errorType = (ErrorType)Convert.ToInt32(((int)errorCodeType).ToString().Substring(0, 1)); model.ErrorValue = string.Format("{0}{1}{2}{3}", BuType, (int)errorType, (int)BusinessType.HHTravel, (int)errorCodeType); model.ErrorTitle = string.Format("{0},{1},{2}", BusinessType.HHTravel.ToString(), errorType.ToString(), errorCodeType.ToString()); } catch (Exception exp) { return(null); } return(model); }
/// <summary>Computes equilibrium concentrations for a set of chemical species.</summary> public ErrorCodeType MSXchem_equil(ObjectTypes zone, double[] c) { ErrorCodeType errcode = 0; if (zone == ObjectTypes.LINK) { if (numPipeEquilSpecies > 0) { errcode = EvalPipeEquil(c); } EvalPipeFormulas(c); } if (zone == ObjectTypes.NODE) { if (numTankEquilSpecies > 0) { errcode = EvalTankEquil(c); } EvalTankFormulas(c); } return(errcode); }
/// <summary> /// Saves any statistical results plus the following information to the end of the MSX binary output file: /// <list type="bullet"> /// <item>byte offset into file where WQ results for each time period begins,</item> /// <item>total number of time periods written to the file,</item> /// <item>any error code generated by the analysis (0 if there were no errors),</item> /// <item>the Magic Number to indicate that the file is complete.</item> /// </list> /// </summary> public ErrorCodeType MSXout_saveFinalResults() { int magic = Constants.MAGICNUMBER; ErrorCodeType err = 0; // Save statistical results to the file //if ( MSX.Statflag != TstatType.SERIES ) // err = saveStatResults(out); if (err > 0) { return(err); } // Write closing records to the file try { this.outStream.Write((int)this.ResultsOffset); this.outStream.Write((int)this.msx.Nperiods); this.outStream.Write((int)this.msx.ErrCode); this.outStream.Write((int)magic); } catch (IOException) {} return(0); }
public static string GetErrorMessage(ErrorCodeType errorCode) { switch (errorCode) { case ErrorCodeType.UnableToConnectNetwork: return("Unable to connect to network."); case ErrorCodeType.FailedToGetCurrentConditionsData: return("Failed to retrieve Current Conditions from network."); case ErrorCodeType.FailedParsingVideos: return("Failed parsing of video feed."); case ErrorCodeType.GpsFailure: return("GPS was unable to locate your position."); case ErrorCodeType.GpsLocateTimedOut: return("GSP location timed out."); case ErrorCodeType.LocationAlreadyExistsInYourList: return("Location is already in your list."); } return("Unknown Error"); }
public Result(ErrorCodeType errorCode, string errorMessage = "") { ErrorCode = errorCode; ErrorMessage = errorMessage; }
public Error(ErrorClassType errorClass, ErrorCodeType errorCode) { this.ErrorClass = errorClass; this.ErrorCode = errorCode; }
/// <summary> /// Capture requirements related with ErrorCodeTypes. /// </summary> /// <param name="errorCode">The error code returned by the protocol server</param> /// <param name="site">Instance of ITestSite</param> private static void ValidateErrorCodeTypes(ErrorCodeType errorCode, ITestSite site) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R341 site.CaptureRequirement( "MS-FSSHTTP", 341, @"[In ErrorCodeTypes][ErrorCodeTypes schema is:] <xs:simpleType name=""ErrorCodeTypes""> <xs:union memberTypes=""tns:GenericErrorCodeTypes tns:CellRequestErrorCodeTypes tns:DependencyCheckRelatedErrorCodeTypes tns:LockAndCoauthRelatedErrorCodeTypes tns:NewEditorsTableCategoryErrorCodeTypes""/> </xs:simpleType>"); switch (errorCode) { // Verify DependencyCheckRelatedErrorCodeTypes case ErrorCodeType.DependentRequestNotExecuted: case ErrorCodeType.DependentOnlyOnSuccessRequestFailed: case ErrorCodeType.DependentOnlyOnFailRequestSucceeded: case ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported: case ErrorCodeType.InvalidRequestDependencyType: { ValidateDependencyCheckRelatedErrorCodeTypes(site); break; } // Verify LockAndCoauthRelatedErrorCodeTypes case ErrorCodeType.LockRequestFail: case ErrorCodeType.FileAlreadyLockedOnServer: case ErrorCodeType.FileNotLockedOnServer: case ErrorCodeType.FileNotLockedOnServerAsCoauthDisabled: case ErrorCodeType.LockNotConvertedAsCoauthDisabled: case ErrorCodeType.FileAlreadyCheckedOutOnServer: case ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser: case ErrorCodeType.CoauthRefblobConcurrencyViolation: case ErrorCodeType.MultipleClientsInCoauthSession: case ErrorCodeType.InvalidCoauthSession: case ErrorCodeType.NumberOfCoauthorsReachedMax: case ErrorCodeType.ExitCoauthSessionAsConvertToExclusiveFailed: { ValidateLockAndCoauthRelatedErrorCodeTypes(site); break; } // Verify GenericErrorCodeTypes case ErrorCodeType.Success: case ErrorCodeType.IncompatibleVersion: case ErrorCodeType.FileNotExistsOrCannotBeCreated: case ErrorCodeType.FileUnauthorizedAccess: case ErrorCodeType.InvalidSubRequest: case ErrorCodeType.SubRequestFail: case ErrorCodeType.BlockedFileType: case ErrorCodeType.DocumentCheckoutRequired: case ErrorCodeType.InvalidArgument: case ErrorCodeType.RequestNotSupported: case ErrorCodeType.InvalidWebUrl: case ErrorCodeType.WebServiceTurnedOff: case ErrorCodeType.ColdStoreConcurrencyViolation: case ErrorCodeType.Unknown: case ErrorCodeType.EditorClientIdNotFound: case ErrorCodeType.EditorMetadataQuotaReached: case ErrorCodeType.EditorMetadataStringExceedsLengthLimit: { ValidateGenericErrorCodeTypes(site); break; } // Verify CellRequestErrorCodeTypes case ErrorCodeType.CellRequestFail: case ErrorCodeType.IRMDocLibarysOnlySupportWebDAV: { ValidateCellRequestErrorCodeTypes(errorCode, site); break; } default: site.Assert.Fail(string.Format("Unknown ErrorCodeType: {0}", errorCode.ToString())); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the caption for the Unable to Import message box. /// </summary> /// <param name="codeType">Type of the code.</param> /// <returns>string for the message box caption</returns> /// ------------------------------------------------------------------------------------ private string GetDialogCaption(ErrorCodeType codeType) { switch(codeType) { case ErrorCodeType.BackTransErrorCode: return ScriptureUtilsException.GetResourceString("kstidBTImportErrorCaption"); case ErrorCodeType.XmlErrorCode: return ScriptureUtilsException.GetResourceString("kstidXmlImportErrorCaption"); default: return ScriptureUtilsException.GetResourceString("kstidImportErrorCaption"); } }
/// <summary> /// Convert a ErrorCodeType to an host-byte ordered unsigned short /// </summary> /// <param name="mClass">The ErrorCodeType to convert</param> /// <returns> /// The unsigned short (16bits) matching the ErrorCodeType /// Return max UInt16 value if the mClass parameter is ErrorCodeType.Unmanaged /// </returns> public static UInt16 ErrorCodeTypeToUInt16(ErrorCodeType mClass) { foreach (FieldInfo field in typeof(ErrorCodeType).GetFields()) { if (field.Name == mClass.ToString()) { Object[] fieldAttributes = field.GetCustomAttributes(typeof(StunValueAttribute), false); if (fieldAttributes.Length == 1) { StunValueAttribute stunValueAttribute = fieldAttributes.GetValue(0) as StunValueAttribute; return stunValueAttribute.Value; } } } return 0xFFFF; }