public XmlExtensionFunction ResolveFunction(string name, string ns, int numArgs, IErrorHelper errorHelper) { Type type; if (_nsToType.TryGetValue(ns, out type)) { try { return _extFuncs.Bind(name, ns, numArgs, type, XmlQueryRuntime.EarlyBoundFlags); } catch (XslTransformException e) { errorHelper.ReportError(e.Message); } } return null; }
/// <summary> /// Initializes a new instance of the <see cref="ErrorController" /> class. /// </summary> /// <param name="errorHelper">The error helper.</param> /// <param name="benchmarkHelper">The benchmark helper.</param> /// <param name="viewHelper">The view helper.</param> public ErrorController(IErrorHelper errorHelper, IBenchmarkHelper benchmarkHelper, IViewHelper viewHelper) : base(errorHelper, benchmarkHelper, viewHelper) { }
public XmlExtensionFunction ResolveFunction(string name, string ns, int numArgs, IErrorHelper errorHelper) { Type type; if (_nsToType.TryGetValue(ns, out type)) { try { return(_extFuncs.Bind(name, ns, numArgs, type, XmlQueryRuntime.EarlyBoundFlags)); } catch (XslTransformException e) { errorHelper.ReportError(e.Message); } } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="ChartDataAccess"/> class. /// </summary> /// <param name="errorHelper"> /// The error helper. /// </param> /// <param name="benchmarkHelper"> /// The benchmark helper. /// </param> public ChartDataAccess(IErrorHelper errorHelper, IBenchmarkHelper benchmarkHelper) : base(errorHelper, benchmarkHelper) { }
public MediaLibraryUploaderController(IFileManager fileManager, IErrorHelper errorHandler) { FileManager = fileManager ?? throw new ArgumentNullException(nameof(fileManager)); ErrorHelper = errorHandler ?? throw new ArgumentNullException(nameof(errorHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="ChartOrchestrator" /> class. /// </summary> /// <param name="assembler">The assembler.</param> /// <param name="dataAccess">The data access.</param> /// <param name="errorHelper">The error helper.</param> /// <exception cref="System.ArgumentNullException"> /// Exception thrown if the assembler, error helper or data access are null. /// </exception> public ChartOrchestrator(IChartAssembler assembler, IChartDataAccess dataAccess, IErrorHelper errorHelper) { if (assembler == null) { throw new ArgumentNullException(nameof(assembler)); } if (dataAccess == null) { throw new ArgumentNullException(nameof(dataAccess)); } if (errorHelper == null) { throw new ArgumentNullException(nameof(errorHelper)); } this.assembler = assembler; this.dataAccess = dataAccess; this.errorHelper = errorHelper; }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/Res.Xslt_InvalidAttrValue, "lang", lang); } else { throw new XslTransformException(Res.Xslt_InvalidAttrValue, "lang", lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/Res.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguage, lang); } } } } } return lcid; }
public bool ParseQName(string qname, out string prefix, out string localName, IErrorHelper errorHelper) { Debug.Assert(qname != null); try { ValidateNames.ParseQNameThrow(qname, out prefix, out localName); return(true); } catch (XmlException e) { errorHelper.ReportError(/*[XT_042]*/ e.Message, null); prefix = PhantomNCName; localName = PhantomNCName; return(false); } }
public void SetUp() { validViewModel = new BillViewModel { Amount = 10, Category = "TEST", Id = Guid.NewGuid(), Name = "TEST", ReoccurringPeriod = TimePeriod.Daily, StartDate = DateTime.Now, UserId = Guid.NewGuid() }; validBillProxy = new BillProxy { Amount = 10, Category = new CategoryProxy { Id = Guid.NewGuid(), Name = "TEST" }, CategoryId = Guid.NewGuid(), Id = Guid.NewGuid(), Name = "TEST", ReoccurringPeriod = 1, StartDate = DateTime.Now, UserId = Guid.NewGuid() }; validManageBillsViewModel = new ManageBillsViewModel(); validDeleteBillRequest = new DeleteBillRequest { BillId = validBillProxy.Id }; validDeleteBillResponse = new DeleteBillResponse { DeleteSuccess = true }; validAddBillRequest = new AddBillRequest { Bill = validBillProxy }; validAddBillResponse = new AddBillResponse { Bill = validBillProxy }; validGetBillRequest = new GetBillRequest { BillId = validBillProxy.Id }; validGetBillResponse = new GetBillResponse { Bill = validBillProxy }; validGetBillsForUserRequest = new GetBillsForUserRequest { UserId = validBillProxy.Id }; validGetBillsForUserResponse = new GetBillsForUserResponse { Bills = new List <BillProxy> { validBillProxy } }; validEditBillRequest = new EditBillRequest { Bill = validBillProxy }; validEditBillResponse = new EditBillResponse { Bill = validBillProxy }; validGetBillsForUserForMonthRequest = new GetBillsForUserForMonthRequest { UserId = validBillProxy.Id }; validGetBillsForUserForMonthResponse = new GetBillsForUserForMonthResponse { Data = new List <KeyValuePair <DateTime, double> >() }; invalidBillViewModel = new BillViewModel { Id = Guid.NewGuid() }; invalidAddBillRequest = new AddBillRequest(); invalidAddBillResponse = new AddBillResponse { Errors = { new ResponseErrorWrapper() } }; invalidGetBillRequest = new GetBillRequest(); invalidGetBillResponse = new GetBillResponse { Errors = { new ResponseErrorWrapper() } }; invalidDeleteBillRequest = new DeleteBillRequest(); invalidDeleteBillResponse = new DeleteBillResponse { Errors = { new ResponseErrorWrapper() } }; invalidGetBillsForUserRequest = new GetBillsForUserRequest(); invalidGetBillsForUserResponse = new GetBillsForUserResponse { Errors = { new ResponseErrorWrapper() } }; invalidEditBillRequest = new EditBillRequest(); invalidEditBillResponse = new EditBillResponse { Errors = { new ResponseErrorWrapper() } }; invalidGetBillsForUserForMonthRequest = new GetBillsForUserForMonthRequest(); invalidGetBillsForUserForMonthResponse = new GetBillsForUserForMonthResponse { Errors = { new ResponseErrorWrapper() } }; assembler = Substitute.For <IBillAssembler>(); dataAccess = Substitute.For <IBillDataAccess>(); errorHelper = Substitute.For <IErrorHelper>(); errorHelper.Create(Arg.Any <Exception>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); errorHelper.Create(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); assembler.NewAddBillRequest(validViewModel, validUsername).Returns(validAddBillRequest); assembler.NewAddBillRequest(invalidBillViewModel, validUsername).Returns(invalidAddBillRequest); assembler.NewAddBillRequest(null, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewBillViewModel(validAddBillResponse).Returns(validViewModel); assembler.NewBillViewModel(validEditBillResponse).Returns(validViewModel); assembler.NewDeleteBillRequest(validViewModel.Id, validUsername).Returns(validDeleteBillRequest); assembler.NewDeleteBillRequest(invalidBillViewModel.Id, validUsername).Returns(invalidDeleteBillRequest); assembler.NewDeleteBillRequest(Guid.Empty, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewGetBillRequest(validViewModel.Id, validUsername).Returns(validGetBillRequest); assembler.NewGetBillRequest(invalidBillViewModel.Id, validUsername).Returns(invalidGetBillRequest); assembler.NewGetBillRequest(Guid.Empty, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewGetBillsForUserRequest(validViewModel.Id, validUsername).Returns(validGetBillsForUserRequest); assembler.NewGetBillsForUserRequest(invalidBillViewModel.Id, validUsername) .Returns(invalidGetBillsForUserRequest); assembler.NewGetBillsForUserRequest(Guid.Empty, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewEditBillRequest(validViewModel, validUsername).Returns(validEditBillRequest); assembler.NewEditBillRequest(invalidBillViewModel, validUsername).Returns(invalidEditBillRequest); assembler.NewEditBillRequest(null, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewGetBillsForUserForMonthRequest(1, validViewModel.Id, validUsername) .Returns(validGetBillsForUserForMonthRequest); assembler.NewGetBillsForUserForMonthRequest(1, invalidBillViewModel.Id, validUsername) .Returns(invalidGetBillsForUserForMonthRequest); assembler.NewManageBillsViewModel(validGetBillsForUserResponse).Returns(validManageBillsViewModel); assembler.NewExportViewModel(ExportType.Json, Arg.Any <IList <BillProxy> >()).Throws(new Exception("TEST")); dataAccess.AddBill(validAddBillRequest).Returns(validAddBillResponse); dataAccess.AddBill(invalidAddBillRequest).Returns(invalidAddBillResponse); dataAccess.DeleteBill(validDeleteBillRequest).Returns(validDeleteBillResponse); dataAccess.DeleteBill(invalidDeleteBillRequest).Returns(invalidDeleteBillResponse); dataAccess.GetBill(validGetBillRequest).Returns(validGetBillResponse); dataAccess.GetBill(invalidGetBillRequest).Returns(invalidGetBillResponse); dataAccess.GetBillsForUser(validGetBillsForUserRequest).Returns(validGetBillsForUserResponse); dataAccess.GetBillsForUser(invalidGetBillsForUserRequest).Returns(invalidGetBillsForUserResponse); dataAccess.EditBill(validEditBillRequest).Returns(validEditBillResponse); dataAccess.EditBill(invalidEditBillRequest).Returns(invalidEditBillResponse); dataAccess.GetBillsForUserForMonth(validGetBillsForUserForMonthRequest) .Returns(validGetBillsForUserForMonthResponse); dataAccess.GetBillsForUserForMonth(invalidGetBillsForUserForMonthRequest) .Returns(invalidGetBillsForUserForMonthResponse); assembler.NewExportViewModel(ExportType.Csv, new List <BillProxy> { validBillProxy }) .Returns(new ExportViewModel()); orchestrator = new BillOrchestrator(assembler, dataAccess, errorHelper); }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // Check if lang is valid language tag according to RFC 3066 if (!XmlComplianceUtil.IsValidLanguageID(lang.ToCharArray(), 0, lang.Length)) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/Res.Xslt_InvalidLanguageTag, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguageTag, lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/Res.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguage, lang); } } } } } return lcid; }
public SlideshowManagementController(IFileManagementHelper fileManagementHelper, IErrorHelper errorHandler) { FileManagementHelper = fileManagementHelper ?? throw new ArgumentNullException(nameof(fileManagementHelper)); ErrorHelper = errorHandler ?? throw new ArgumentNullException(nameof(ErrorHelper)); }
public void SetUp() { assembler = Substitute.For <IChartAssembler>(); dataAccess = Substitute.For <IChartDataAccess>(); validUserId = Guid.NewGuid(); invalidUserId = Guid.Empty; validUsername = "******"; validGetBillCategoryChartDataRequest = new GetBillCategoryChartDataRequest { UserId = validUserId, Username = validUsername }; invalidGetBillCategoryChartDataRequest = new GetBillCategoryChartDataRequest(); validGetBillCategoryChartDataResponse = new GetBillCategoryChartDataResponse { Data = new List < KeyValuePair <string, int> >() }; invalidGetBillPeriodChartDataResponse = new GetBillPeriodChartDataResponse { Errors = { new ResponseErrorWrapper () } }; validGetBillPeriodChartDataRequest = new GetBillPeriodChartDataRequest { UserId = validUserId, Username = validUsername }; invalidGetBillPeriodChartDataRequest = new GetBillPeriodChartDataRequest(); validGetBillPeriodChartDataResponse = new GetBillPeriodChartDataResponse { Data = new List < KeyValuePair <string, int> >() }; invalidGetBillPeriodChartDataResponse = new GetBillPeriodChartDataResponse { Errors = { new ResponseErrorWrapper () } }; invalidGetBillCategoryChartDataResponse = new GetBillCategoryChartDataResponse { Errors = { new ResponseErrorWrapper () } }; validGetExpenditureChartDataRequest = new GetExpenditureChartDataRequest { Month = 1, UserId = validUserId, Username = validUsername }; invalidGetExpenditureChartDataRequest = new GetExpenditureChartDataRequest { Month = 1, UserId = invalidUserId, Username = string.Empty }; validGetExpenditureChartDataResponse = new GetExpenditureChartDataResponse { Data = new List <KeyValuePair <DateTime, double> >() }; invalidGetExpenditureChartDataResponse = new GetExpenditureChartDataResponse { Errors = { new ResponseErrorWrapper() } }; assembler.NewGetBillCategoryChartDataRequest(invalidUserId, validUsername) .Returns(invalidGetBillCategoryChartDataRequest); assembler.NewGetBillCategoryChartDataRequest(validUserId, validUsername) .Returns(validGetBillCategoryChartDataRequest); assembler.NewGetBillCategoryChartDataRequest(validUserId, string.Empty) .Throws(new Exception("TEST EXCEPTION")); dataAccess.GetBillCategoryChartData(validGetBillCategoryChartDataRequest) .Returns(validGetBillCategoryChartDataResponse); dataAccess.GetBillCategoryChartData(invalidGetBillCategoryChartDataRequest) .Returns(invalidGetBillCategoryChartDataResponse); assembler.NewGetBillPeriodChartDataRequest(invalidUserId, validUsername) .Returns(invalidGetBillPeriodChartDataRequest); assembler.NewGetBillPeriodChartDataRequest(validUserId, validUsername) .Returns(validGetBillPeriodChartDataRequest); assembler.NewGetBillPeriodChartDataRequest(validUserId, string.Empty) .Throws(new Exception("TEST EXCEPTION")); assembler.NewGetExpenditureChartDataRequest(1, invalidUserId, validUsername) .Returns(invalidGetExpenditureChartDataRequest); assembler.NewGetExpenditureChartDataRequest(1, validUserId, validUsername) .Returns(validGetExpenditureChartDataRequest); assembler.NewGetExpenditureChartDataRequest(-1, invalidUserId, string.Empty) .Throws(new Exception("TEST EXCEPTION")); dataAccess.GetBillPeriodChartData(validGetBillPeriodChartDataRequest) .Returns(validGetBillPeriodChartDataResponse); dataAccess.GetBillPeriodChartData(invalidGetBillPeriodChartDataRequest) .Returns(invalidGetBillPeriodChartDataResponse); dataAccess.GetExpenditureChartData(validGetExpenditureChartDataRequest) .Returns(validGetExpenditureChartDataResponse); dataAccess.GetExpenditureChartData(invalidGetExpenditureChartDataRequest) .Returns(invalidGetExpenditureChartDataResponse); errorHelper = Substitute.For <IErrorHelper>(); errorHelper.Create(Arg.Any <Exception>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); errorHelper.Create(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); orchestrator = new ChartOrchestrator(assembler, dataAccess, errorHelper); }
public void SetUp() { validViewModel = new GoalViewModel { Amount = 10, Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; validGoalProxy = new GoalProxy { Amount = 10, Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; validManageGoalsViewModel = new ManageGoalsViewModel(); validDeleteGoalRequest = new DeleteGoalRequest { GoalId = validGoalProxy.Id }; validDeleteGoalResponse = new DeleteGoalResponse { DeleteSuccess = true }; validAddGoalRequest = new AddGoalRequest { Goal = validGoalProxy }; validAddGoalResponse = new AddGoalResponse { Goal = validGoalProxy }; validGetGoalRequest = new GetGoalRequest { GoalId = validGoalProxy.Id }; validGetGoalResponse = new GetGoalResponse { Goal = validGoalProxy }; validGetGoalsForUserRequest = new GetGoalsForUserRequest { UserId = validGoalProxy.Id }; validGetGoalsForUserResponse = new GetGoalsForUserResponse { Goals = new List <GoalProxy> { validGoalProxy } }; validEditGoalRequest = new EditGoalRequest { Goal = validGoalProxy }; validEditGoalResponse = new EditGoalResponse { Goal = validGoalProxy }; invalidGoalViewModel = new GoalViewModel { Id = Guid.NewGuid() }; invalidAddGoalRequest = new AddGoalRequest(); invalidAddGoalResponse = new AddGoalResponse { Errors = { new ResponseErrorWrapper() } }; invalidGetGoalRequest = new GetGoalRequest(); invalidGetGoalResponse = new GetGoalResponse { Errors = { new ResponseErrorWrapper() } }; invalidDeleteGoalRequest = new DeleteGoalRequest(); invalidDeleteGoalResponse = new DeleteGoalResponse { Errors = { new ResponseErrorWrapper() } }; invalidGetGoalsForUserRequest = new GetGoalsForUserRequest(); invalidGetGoalsForUserResponse = new GetGoalsForUserResponse { Errors = { new ResponseErrorWrapper() } }; invalidEditGoalRequest = new EditGoalRequest(); invalidEditGoalResponse = new EditGoalResponse { Errors = { new ResponseErrorWrapper() } }; assembler = Substitute.For <IGoalAssembler>(); dataAccess = Substitute.For <IGoalDataAccess>(); assembler.NewAddGoalRequest(validViewModel, validUsername).Returns(validAddGoalRequest); assembler.NewAddGoalRequest(invalidGoalViewModel, validUsername).Returns(invalidAddGoalRequest); assembler.NewAddGoalRequest(null, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewDeleteGoalRequest(validViewModel.Id, validUsername).Returns(validDeleteGoalRequest); assembler.NewDeleteGoalRequest(invalidGoalViewModel.Id, validUsername).Returns(invalidDeleteGoalRequest); assembler.NewDeleteGoalRequest(Guid.Empty, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewGetGoalRequest(validViewModel.Id, validUsername).Returns(validGetGoalRequest); assembler.NewGetGoalRequest(invalidGoalViewModel.Id, validUsername).Returns(invalidGetGoalRequest); assembler.NewGetGoalRequest(Guid.Empty, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewGetGoalsForUserRequest(validViewModel.Id, validUsername).Returns(validGetGoalsForUserRequest); assembler.NewGetGoalsForUserRequest(invalidGoalViewModel.Id, validUsername) .Returns(invalidGetGoalsForUserRequest); assembler.NewGetGoalsForUserRequest(Guid.Empty, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewEditGoalRequest(validViewModel, validUsername).Returns(validEditGoalRequest); assembler.NewEditGoalRequest(invalidGoalViewModel, validUsername).Returns(invalidEditGoalRequest); assembler.NewEditGoalRequest(null, validUsername).Throws(new Exception("TEST EXCEPTION")); assembler.NewManageGoalsViewModel(new List <GoalProxy> { validGoalProxy }) .Returns(validManageGoalsViewModel); dataAccess.AddGoal(validAddGoalRequest).Returns(validAddGoalResponse); dataAccess.AddGoal(invalidAddGoalRequest).Returns(invalidAddGoalResponse); dataAccess.DeleteGoal(validDeleteGoalRequest).Returns(validDeleteGoalResponse); dataAccess.DeleteGoal(invalidDeleteGoalRequest).Returns(invalidDeleteGoalResponse); dataAccess.GetGoal(validGetGoalRequest).Returns(validGetGoalResponse); dataAccess.GetGoal(invalidGetGoalRequest).Returns(invalidGetGoalResponse); dataAccess.GetGoalsForUser(validGetGoalsForUserRequest).Returns(validGetGoalsForUserResponse); dataAccess.GetGoalsForUser(invalidGetGoalsForUserRequest).Returns(invalidGetGoalsForUserResponse); dataAccess.EditGoal(validEditGoalRequest).Returns(validEditGoalResponse); dataAccess.EditGoal(invalidEditGoalRequest).Returns(invalidEditGoalResponse); errorHelper = Substitute.For <IErrorHelper>(); errorHelper.Create(Arg.Any <Exception>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); errorHelper.Create(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); orchestrator = new GoalOrchestrator(dataAccess, assembler, errorHelper); }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } else { throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(SR.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(SR.Xslt_InvalidLanguage, lang); } } } } } return(lcid); }
public void SetUp() { userId = Guid.NewGuid(); expenditureId = Guid.NewGuid(); validData = new List <GoalDataModel>(); invalidDeleteGoalRequest = new DeleteGoalRequest(); invalidEditGoalRequest = new EditGoalRequest(); invalidGetGoalsForUserRequest = new GetGoalsForUserRequest(); invalidGetGoalRequest = new GetGoalRequest(); invalidAddGoalRequest = new AddGoalRequest(); validGoalDataModel = new GoalDataModel { Amount = 1, CreationTime = DateTime.Now, Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; expenditureProxy = new GoalProxy { Amount = 1.0, Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; validDeleteGoalRequest = new DeleteGoalRequest { GoalId = Guid.NewGuid(), Username = "******" }; validAddGoalRequest = new AddGoalRequest { Goal = expenditureProxy, Username = "******" }; validGetGoalsForUserRequest = new GetGoalsForUserRequest { UserId = userId, Username = "******" }; validGetGoalRequest = new GetGoalRequest { GoalId = expenditureId, Username = "******" }; validEditGoalRequest = new EditGoalRequest { Goal = expenditureProxy, Username = "******" }; validGetGoalsForUserResponse = new GetGoalsForUserResponse { Goals = new List <GoalProxy> { expenditureProxy } }; validGetGoalResponse = new GetGoalResponse { Goal = expenditureProxy }; validAddGoalResponse = new AddGoalResponse { Goal = expenditureProxy }; validEditGoalResponse = new EditGoalResponse { Goal = expenditureProxy }; validDeleteGoalResponse = new DeleteGoalResponse { DeleteSuccess = true }; assembler = Substitute.For <IGoalAssembler>(); repository = Substitute.For <IGoalRepository>(); errorHelper = Substitute.For <IErrorHelper>(); errorHelper.Create(Arg.Any <Exception>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); errorHelper.Create(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); repository.AddGoal(validGoalDataModel).Returns(validGoalDataModel); repository.AddGoal(null).Throws(new Exception("TEST")); repository.DeleteGoal(validDeleteGoalRequest.GoalId).Returns(true); repository.DeleteGoal(invalidDeleteGoalRequest.GoalId).Throws(new Exception("TEST")); repository.EditGoal(validGoalDataModel).Returns(validGoalDataModel); repository.EditGoal(null).Throws(new Exception("TEST")); repository.GetGoal(expenditureId).Returns(validGoalDataModel); repository.GetGoal(Guid.Empty).Throws(new Exception("TEST")); repository.GetGoalsForUser(validGetGoalsForUserRequest.UserId) .Returns(new List <GoalDataModel> { validGoalDataModel }); repository.GetGoalsForUser(Guid.Empty).Throws(new Exception("TEST")); assembler.NewAddGoalResponse(validGoalDataModel, validAddGoalRequest.RequestReference) .Returns(validAddGoalResponse); assembler.NewDeleteGoalResponse(true, validDeleteGoalRequest.GoalId).Returns(validDeleteGoalResponse); assembler.NewEditGoalResponse(validGoalDataModel, validEditGoalRequest.RequestReference) .Returns(validEditGoalResponse); assembler.NewGoalDataModel(expenditureProxy).Returns(validGoalDataModel); assembler.NewGetGoalsForUserResponse( Arg.Any <List <GoalDataModel> >(), validGetGoalsForUserRequest.RequestReference) .Returns(validGetGoalsForUserResponse); assembler.NewDeleteGoalResponse(true, validDeleteGoalRequest.RequestReference) .Returns(validDeleteGoalResponse); assembler.NewGetGoalResponse(validGoalDataModel, validGetGoalRequest.RequestReference) .Returns(validGetGoalResponse); orchestrator = new GoalOrchestrator(assembler, repository, errorHelper); }
internal static string LangToNameInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { string cultName = InvariantCultureName; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/ SR.Xslt_InvalidAttrValue, nameof(lang), lang); } else { throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } } } else { // Check if lang is a supported culture name try { cultName = new CultureInfo(lang).Name; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/ SR.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(SR.Xslt_InvalidLanguage, lang); } } } } } return(cultName); }
/// <summary> /// Initializes a new instance of the <see cref="GoalOrchestrator"/> class. /// </summary> /// <param name="assembler"> /// The assembler. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="errorHelper"> /// The error helper. /// </param> /// <exception cref="System.ArgumentNullException"> /// Exception thrown if the assembler or repository are null. /// </exception> public GoalOrchestrator(IGoalAssembler assembler, IGoalRepository repository, IErrorHelper errorHelper) : base(errorHelper) { if (assembler == null) { throw new ArgumentNullException(nameof(assembler)); } if (repository == null) { throw new ArgumentNullException(nameof(repository)); } this.assembler = assembler; this.repository = repository; }
internal static string LangToNameInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { string cultName = InvariantCultureName; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/SR.Xslt_InvalidAttrValue, nameof(lang), lang); } else { throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } } } else { // Check if lang is a supported culture name try { cultName = new CultureInfo(lang).Name; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/SR.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(SR.Xslt_InvalidLanguage, lang); } } } } } return cultName; }
/// <summary> /// Initializes a new instance of the <see cref="UserOrchestrator"/> class. /// </summary> /// <param name="assembler">The assembler.</param> /// <param name="dataAccess">The data access.</param> /// <param name="errorHelper">The error helper.</param> /// <exception cref="System.ArgumentNullException"> /// assembler /// or /// dataAccess /// or /// errorHelper /// </exception> public UserOrchestrator(IUserAssembler assembler, IUserDataAccess dataAccess, IErrorHelper errorHelper) : base(errorHelper) { if (assembler == null) { throw new ArgumentNullException(nameof(assembler)); } if (dataAccess == null) { throw new ArgumentNullException(nameof(dataAccess)); } this.assembler = assembler; this.dataAccess = dataAccess; }
public ScriptClass GetScriptClass(string ns, string language, IErrorHelper errorHelper) { CompilerInfo compilerInfo; try { compilerInfo = CodeDomProvider.GetCompilerInfo(language); Debug.Assert(compilerInfo != null); } catch (ConfigurationException) { // There is no CodeDom provider defined for this language errorHelper.ReportError(/*[XT_010]*/SR.Xslt_ScriptInvalidLanguage, language); return null; } foreach (ScriptClass scriptClass in _scriptClasses) { if (ns == scriptClass.ns) { // Use object comparison because CompilerInfo.Equals may throw if (compilerInfo != scriptClass.compilerInfo) { errorHelper.ReportError(/*[XT_011]*/SR.Xslt_ScriptMixedLanguages, ns); return null; } return scriptClass; } } ScriptClass newScriptClass = new ScriptClass(ns, compilerInfo); newScriptClass.typeDecl.TypeAttributes = TypeAttributes.Public; _scriptClasses.Add(newScriptClass); return newScriptClass; }
public void SetUp() { assembler = Substitute.For <IUserAssembler>(); dataAccess = Substitute.For <IUserDataAccess>(); errorHelper = Substitute.For <IErrorHelper>(); errorHelper.Create(Arg.Any <Exception>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); errorHelper.Create(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <string>()) .Returns(new ResponseErrorWrapper()); validRegisterUserRequest = new RegisterUserRequest { DateOfBirth = DateTime.Now, EmailAddress = "TEST", FirstName = "TEST", LastName = "TEST", Password = "******", Username = "******" }; validValidateUserResponse = new ValidateUserResponse { LoginSuccess = true, RequestReference = Guid.NewGuid(), User = new UserProxy { EmailAddress = "TEST", DateOfBirth = DateTime.Now, FirstName = "TEST", Id = Guid.NewGuid(), LastName = "TEST" } }; invalidValidateUserResponse = new ValidateUserResponse { Errors = { new ResponseErrorWrapper() } }; validValidateUserRequest = new ValidateUserRequest { EmailAddress = "TEST", Password = "******", Username = "******" }; invalidValidateUserRequest = new ValidateUserRequest { EmailAddress = string.Empty, Password = string.Empty, Username = string.Empty }; validLoginViewModel = new LoginViewModel { EmailAddress = "TEST", Password = "******", ReturnUrl = "TEST" }; invalidLoginViewModel = new LoginViewModel { EmailAddress = string.Empty, Password = string.Empty, ReturnUrl = string.Empty }; invalidRegisterViewModel = new RegisterViewModel { AcceptTermsAndConditions = false, ConfirmPassword = string.Empty, DateOfBirth = DateTime.MinValue, EmailAddress = string.Empty, FirstName = string.Empty, LastName = string.Empty, Password = string.Empty }; validRegisterUserResponse = new RegisterUserResponse { RequestReference = Guid.NewGuid(), RegisterSuccess = true }; invalidRegisterUserResponse = new RegisterUserResponse { RequestReference = Guid.NewGuid(), Errors = { new ResponseErrorWrapper() }, RegisterSuccess = false }; validRegisterViewModel = new RegisterViewModel { AcceptTermsAndConditions = true, ConfirmPassword = "******", DateOfBirth = DateTime.Now, EmailAddress = "TEST", FirstName = "TEST", LastName = "TEST", Password = "******" }; invalidRegisterUserRequest = new RegisterUserRequest { DateOfBirth = DateTime.MinValue, EmailAddress = string.Empty, FirstName = string.Empty, LastName = string.Empty, Password = string.Empty, Username = string.Empty }; assembler.NewRegisterUserRequest(invalidRegisterViewModel).Returns(invalidRegisterUserRequest); assembler.NewRegisterUserRequest(validRegisterViewModel).Returns(validRegisterUserRequest); assembler.NewRegisterUserRequest(null).Throws(new Exception("TEST EXCEPTION")); assembler.NewValidateUserRequest(invalidLoginViewModel).Returns(invalidValidateUserRequest); assembler.NewValidateUserRequest(validLoginViewModel).Returns(validValidateUserRequest); assembler.NewValidateUserRequest(null).Throws(new Exception("TEST EXCEPTION")); assembler.NewClaimsIdentity(validValidateUserResponse).Returns(new ClaimsIdentity()); dataAccess.RegisterUser(invalidRegisterUserRequest).Returns(invalidRegisterUserResponse); dataAccess.RegisterUser(validRegisterUserRequest).Returns(validRegisterUserResponse); dataAccess.ValidateUser(invalidValidateUserRequest).Returns(invalidValidateUserResponse); dataAccess.ValidateUser(validValidateUserRequest).Returns(validValidateUserResponse); orchestrator = new UserOrchestrator(assembler, dataAccess, errorHelper); }