private void ShimCurrentUser() { ShimECNSession.Constructor = (instance) => { }; var ecnSession = CreateECNSession(); var shimSession = new ShimECNSession(); shimSession.ClearSession = () => { }; shimSession.Instance.CurrentUser = new User { UserID = 1, UserName = "******" }; ShimECNSession.CurrentSession = () => shimSession.Instance; }
private void InitializeSessionFakes() { var shimSession = new ShimECNSession(); shimSession.Instance.CurrentUser = new User() { UserID = 1, UserName = TestUserName, IsActive = true }; ShimECNSession.CurrentSession = () => shimSession.Instance; }
private void InitializeSessionFakes() { var shimSession = new ShimECNSession(); shimSession.Instance.CurrentUser = new User() { UserID = 1, UserName = "******", IsActive = true }; shimSession.Instance.CurrentBaseChannel = new BaseChannel { BaseChannelID = 1 }; ShimECNSession.CurrentSession = () => shimSession.Instance; }
private static void InitializeUdf() { var shimECNSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimECNSession; ShimECNSession.AllInstances.CustomerIDGet = (x) => GroupId; var fieldCurrentUser = typeof(ECNSession).GetField(CurrentUser); if (fieldCurrentUser == null) { throw new InvalidOperationException($"Field fieldCurrentCustomer should not be null"); } fieldCurrentUser.SetValue(shimECNSession.Instance, new User { UserID = GroupId, CustomerID = GroupId }); BusinessLogicFakes.ShimUser.HasAccessUserEnumsServicesEnumsServiceFeaturesEnumsAccess = (x, y, z, b) => true; ShimUser.HasAccessUserEnumsServicesEnumsServiceFeaturesEnumsAccess = (x, y, z, b) => true; var user = new User() { CurrentClient = new Client() { ClientID = GroupId }, CustomerID = GroupId }; ShimConvenienceMethods.GetCurrentUser = () => user; ShimDataFunctions.GetDataTableSqlCommandString = (x, y) => new DataTable(); DataLayerFakes.ShimEmail.GetSqlCommand = (x) => new Email() { EmailID = EmailId, CustomerID = GroupId, EmailAddress = EmailAddress }; var dataFieldSets = new DataFieldSets(); DataLayerFakes.ShimDataFieldSets.GetListSqlCommand = (x) => new List <DataFieldSets> { dataFieldSets }; ShimHttpContext.CurrentGet = () => { var context = new HttpContext(new HttpRequest(null, TempURL, null), new HttpResponse(null)); return(context); }; var httpSessionBase = new Moq.Mock <HttpSessionStateBase>(); httpSessionBase.Setup(x => x.Add(SelectedEmailId, Value)); ShimController.AllInstances.SessionGet = (x) => httpSessionBase.Object; }
private void SetPageProperties(int userId) { var shimECNSession = new ShimECNSession(); shimECNSession.Instance.CurrentUser = new KMPlatform.Entity.User() { UserID = userId }; ShimCommunicator.AllInstances.UserSessionGet = (c) => shimECNSession; ShimMessageTriggers.AllInstances.MasterGet = (mt) => new ecn.communicator.MasterPages.Communicator(); ShimHttpResponse.AllInstances.RedirectStringBoolean = (h, u, b) => { }; ShimPage.AllInstances.ResponseGet = (p) => new ShimHttpResponse(); ShimPage.AllInstances.RequestGet = (p) => new ShimHttpRequest(); }
private void InitializeSessionFakes() { var shimSession = new ShimECNSession(); var client = CreateInstance(typeof(Client)); shimSession.Instance.CurrentUser = new User() { UserID = 1, UserName = TestUser, IsActive = true, CurrentClient = client }; shimSession.Instance.CurrentBaseChannel = new BaseChannel { BaseChannelID = 1 }; ShimECNSession.CurrentSession = () => shimSession.Instance; }
private void ShimCurrentUser() { ShimECNSession.Constructor = (instance) => { }; var ecnSession = CreateECNSession(); var shimSession = new ShimECNSession(); shimSession.ClearSession = () => { }; shimSession.Instance.CurrentUser = new KMPlatform.Entity.User { UserID = 1, UserName = "******" }; shimSession.Instance.CurrentBaseChannel = _testChannel; shimSession.Instance.CurrentCustomer = _testCustomer; ShimECNSession.CurrentSession = () => shimSession.Instance; }
protected override void SetPageSessionContext() { base.SetPageSessionContext(); _defineSurveyInstance = new DefineSurvey(); _shimDefineSurvey = new ShimDefineSurvey(_defineSurveyInstance); _defineSurveyPrivateObject = new PrivateObject(_defineSurveyInstance); InitializeAllControls(_defineSurveyInstance); var shimEcnSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimEcnSession; ECNSession.CurrentSession().CurrentUser = new KMPlatform.Entity.User() { UserID = 10 }; }
public void HasAuthorised_NotAuthorisedClient_false() { // Arrange var authorisedUserId = 10; var session = new ShimECNSession(); session.Instance.CurrentUser = new User() { UserClientSecurityGroupMaps = new List <UserClientSecurityGroupMap>() }; ShimECNSession.CurrentSession = () => session; // Act and Assert _controller.HasAuthorized(0, authorisedUserId).ShouldBeFalse(); }
private static ShimECNSession CreateShimEcnSessionObject() { ShimECNSession.Constructor = (instance) => { }; var shimSession = new ShimECNSession { ClearSession = () => { }, ClientIDGet = () => DefaultId, UserIDGet = () => DefaultId, BaseChannelIDGet = () => DefaultId, ClientGroupIDGet = () => DefaultId, CustomerIDGet = () => DefaultId, }; return(shimSession); }
private void InitializeSessionFakes() { var shimSession = new ShimECNSession(); shimSession.Instance.CurrentUser = new User() { UserID = 1, UserName = "******", IsActive = true }; shimSession.Instance.CurrentBaseChannel = new BaseChannel { BaseChannelID = 1 }; ShimECNSession.CurrentSession = () => shimSession.Instance; Shimroledetail.AllInstances.MasterGet = (p) => new ecn.accounts.MasterPages.Accounts(); ShimAccounts.AllInstances.UserSessionGet = (a) => shimSession.Instance; }
private void SetPageProperties_Menu_MenuItemDataBound() { var shimECNSession = new ShimECNSession(); ShimCommunicator.AllInstances.UserSessionGet = (c) => shimECNSession; ShimConfigurationManager.AppSettingsGet = () => { var settingsCollection = new NameValueCollection(); settingsCollection.Add(MID_VirtaulPathSettingKey, MID_VirtaulPathSettingValue); return(settingsCollection); }; ShimMenuItemCollection.AllInstances.RemoveMenuItem = (collection, menuItem) => { _removedMenuItemText = menuItem?.Text; }; }
protected override void SetPageSessionContext() { base.SetPageSessionContext(); _shimEcnSession = new ShimECNSession(); var fieldCurrentUser = typeof(ECNSession).GetField("CurrentUser"); var currUser = new User { CustomerID = 1 }; fieldCurrentUser.SetValue(_shimEcnSession.Instance, currUser); ShimECNSession.CurrentSession = () => _shimEcnSession.Instance; _control = new WizardContent_Champion(); InitializeAllControls(_control); _privateControlObj = new PrivateObject(_control); ShimConfigurationManager.AppSettingsGet = () => _appSettings; }
private static void CreateEcnSession() { var shimECNSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimECNSession; var fieldCurrentUser = typeof(ECNSession).GetField(CurrentUser); if (fieldCurrentUser == null) { throw new InvalidOperationException($"Field fieldCurrentCustomer should not be null"); } fieldCurrentUser.SetValue(shimECNSession.Instance, new User { UserID = FilterGroupId, CustomerID = FilterGroupId }); }
private void SetPagePropertiesForBindPreview() { var shimSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimSession; shimSession.Instance.CurrentUser = new User(); var appSettings = new NameValueCollection(); var queryString = new NameValueCollection(); queryString[BindPreviewBlastIdQueryStringKey] = BindPreviewBlastId; appSettings.Add(AppSettingsLitmusAPIKey, AppSettingsLitmusAPIKeyValue); appSettings.Add(AppSettingsLitmusAPIPasswordKey, AppSettingsLitmusAPIPasswordValue); appSettings.Add(AppSettingsKMCommonApplicationKey, AppSettingsKMCommonApplicationValue); ShimHttpRequest.AllInstances.QueryStringGet = (request) => queryString; ShimPage.AllInstances.RequestGet = (p) => new ShimHttpRequest(); ShimConfigurationManager.AppSettingsGet = () => appSettings; }
private void SetPageProperties_btnReport_Click() { var shimECNSession = new ShimECNSession(); shimECNSession.Instance.CurrentUser = new User() { UserID = BRC_UserId }; shimECNSession.Instance.CurrentCustomer = new Customer() { CustomerID = BRC_CustomerID }; ShimCommunicator.AllInstances.UserSessionGet = (c) => shimECNSession; ShimDataDumpReport.AllInstances.MasterGet = (mt) => new CommMaster.Communicator(); ShimHttpResponse.AllInstances.RedirectStringBoolean = (h, u, b) => { }; ShimPage.AllInstances.ResponseGet = (p) => new ShimHttpResponse(); ShimPage.AllInstances.RequestGet = (p) => new ShimHttpRequest(); }
private void SetBtnSaveGatewayClickTest_PageProperties(int userId) { var shimECNSession = new ShimECNSession(); shimECNSession.Instance.CurrentUser = new User() { UserID = userId }; shimECNSession.Instance.CurrentCustomer = new Customer() { CustomerID = SG_CustomerID }; ShimCommunicator.AllInstances.UserSessionGet = (c) => shimECNSession; ShimGatewaySetup.AllInstances.MasterGet = (mt) => new ecn.communicator.MasterPages.Communicator(); ShimHttpResponse.AllInstances.RedirectStringBoolean = (h, u, b) => { }; ShimPage.AllInstances.ResponseGet = (p) => new ShimHttpResponse(); ShimPage.AllInstances.RequestGet = (p) => new ShimHttpRequest(); }
protected override void SetPageSessionContext() { base.SetPageSessionContext(); _shimContext = ShimsContext.Create(); _defineTemplateInstance = new DefineTemplate(); _shimDefineQuestions = new ShimDefineTemplate(_defineTemplateInstance); _defineTemplatePrivateObject = new PrivateObject(_defineTemplateInstance); InitializeAllControls(_defineTemplateInstance); var shimEcnSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimEcnSession; ECNSession.CurrentSession().CurrentUser = new KMPlatform.Entity.User() { UserID = 10 }; InitControls(); InitCommonShims(); }
private void InitializeSessionFakes() { QueryString.Clear(); var shimSession = new ShimECNSession(); shimSession.Instance.CurrentUser = new User() { UserID = 1, UserName = "******", IsActive = true, CustomerID = 1 }; shimSession.Instance.CurrentBaseChannel = new BaseChannel { BaseChannelID = 1 }; ShimECNSession.CurrentSession = () => shimSession.Instance; ShimBaseChannelUpdateEmail.AllInstances.MasterGet = (s) => new MasterPage.Communicator { }; ShimCommunicator.AllInstances.UserSessionGet = (m) => shimSession.Instance; }
public void HasAuthorised_AuthorisedClient_true() { // Arrange var authorisedUserId = 10; var session = new ShimECNSession(); session.Instance.CurrentUser = new User() { UserClientSecurityGroupMaps = new List <UserClientSecurityGroupMap>() { new UserClientSecurityGroupMap() { ClientID = authorisedUserId } } }; ShimECNSession.CurrentSession = () => session; // Act and Assert _communicatorInstance.HasAuthorized(0, authorisedUserId).ShouldBeTrue(); }
private static User CreateUserObject(ShimECNSession shimSession) { return(new User { UserID = DefaultId, CustomerID = DefaultId, UserName = DefaultText, IsActive = true, CurrentSecurityGroup = new SecurityGroup { AdministrativeLevel = SecurityGroupAdministrativeLevel.ChannelAdministrator, IsActive = true }, IsPlatformAdministrator = true, CurrentClient = new Client { ClientTestDBConnectionString = string.Empty, ClientLiveDBConnectionString = string.Empty }, }); }
public void Setup() { _gallery = new imageGallery(); _galleryPrivate = new PrivateObject(_gallery); _shimsContext = ShimsContext.Create(); _mocks = new MocksContext(); _mocks.AppSettings.Add(ImagesVirtualPathKey, GetAnyString()); _mocks.AppSettings.Add(CommunicatorVirtualPathKey, CommunicatorVirtualPath); _mocks.AppSettings.Add(ImageDomainPathKey, ImageDomainPath); InitializeControlChildren(); var session = new ShimECNSession(); ReflectionHelper.SetField(session.Instance, "CurrentUser", new KMPlatform.Entity.User()); ShimECNSession.CurrentSession = () => session; var request = new HttpRequest(AnyUrl, AnyUrl, "cuID=1000&chID=1000"); ShimUserControl.AllInstances.RequestGet = (c) => request; ShimHttpContext.CurrentGet = () => new HttpContext(request, new HttpResponse(TextWriter.Null)); }
private void InitializeSessionFakes() { QueryString.Clear(); QueryString.Add(ReportScheduleIdKey, "1"); var shimSession = new ShimECNSession(); shimSession.Instance.CurrentUser = new User() { UserID = 1, UserName = "******", IsActive = true, CustomerID = 1 }; shimSession.Instance.CurrentBaseChannel = new BaseChannel { BaseChannelID = 1 }; ShimECNSession.CurrentSession = () => shimSession.Instance; ShimscheduledReportSetup.AllInstances.MasterGet = (s) => new ecn.communicator.MasterPages.Communicator { }; ecn.communicator.MasterPages.Fakes.ShimCommunicator.AllInstances.UserSessionGet = (m) => shimSession.Instance; }
protected override void SetPageSessionContext() { base.SetPageSessionContext(); _responseOptionsPropertyWrapper = string.Empty; _questionDeleteMethodCallCount = 0; _itemCommandRegisteredStartupScript = false; _defineQuestionsInstance = new DefineQuestions(); _shimDefineQuestions = new ShimDefineQuestions(_defineQuestionsInstance); _defineQuestionsPrivateObject = new PrivateObject(_defineQuestionsInstance); InitializeAllControls(_defineQuestionsInstance); _shimDefineQuestions.ResponseoptionsGet = () => _responseOptionsPropertyWrapper; _shimDefineQuestions.ResponseoptionsSetString = (responseOptions) => _responseOptionsPropertyWrapper = responseOptions; ShimQuestion.DeleteInt32User = (i, u) => _questionDeleteMethodCallCount++; SetPageControls(); var shimEcnSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimEcnSession; ECNSession.CurrentSession().CurrentUser = new KMPlatform.Entity.User() { UserID = 10 }; }
public void GetFolders_IfFolderTypeEqualsToImg_ReturnsFolders() { // Arrange var directories = new string[] { "directory01", "directory02" }; ShimDirectory.GetDirectoriesString = (path) => { return(directories); }; _testEntity.FolderType = FolderTypes.IMG.ToString(); var shimEcnSession = new ShimECNSession(); shimEcnSession.Instance.CurrentUser = new User(); ShimECNSession.CurrentSession = () => { return(shimEcnSession.Instance); }; // Act var returnedValue = _testEntityPrivate.Invoke(GetFoldersMethodName) as List <Folder>; // Assert returnedValue.ShouldSatisfyAllConditions( () => returnedValue.ShouldNotBeNull(), () => returnedValue.ShouldBeOfType <List <Folder> >(), () => returnedValue.Count.ShouldBe(directories.Length), () => returnedValue.ForEach(fld => directories.ShouldContain(fld.FolderName)));; }
private void SetUpFakes() { var shimECNSession = new ShimECNSession(); shimECNSession.Instance.CurrentUser = new User() { UserID = 1 }; ShimECNSession.CurrentSession = () => shimECNSession.Instance; _testEntity.Session[SessionRequestBlastIDKey] = 1; ShimBlastSchedule.InsertBlastSchedule = (schedule) => { _savedSchedule = schedule; _isScheduleInserted = true; return(1); }; ShimBlastSchedule.UpdateBlastScheduleInt32 = (schedule, id) => { _savedSchedule = schedule; _isScheduleUpdated = true; return(id); }; }
private void ShimCurrentUser(bool isActive = false) { ShimECNSession.Constructor = (instance) => { }; var ecnSession = CreateECNSession(); var shimSession = new ShimECNSession(); shimSession.ClearSession = () => { }; shimSession.Instance.CurrentUser = new KMPlatform.Entity.User { UserID = 1, UserName = DefaultText, IsActive = isActive, CurrentSecurityGroup = new KMPlatform.Entity.SecurityGroup { AdministrativeLevel = SecurityGroupAdministrativeLevel.ChannelAdministrator, IsActive = true }, IsPlatformAdministrator = true, }; shimSession.Instance.CurrentBaseChannel = new BaseChannel { BaseChannelID = 1, CreatedUserID = 1 }; shimSession.Instance.CurrentCustomer = new Customer { CustomerID = 1, CustomerName = DefaultText }; ShimECNSession.CurrentSession = () => shimSession.Instance; ShimMarketingAutomation.CheckIfControlExistsInt32EnumsMarketingAutomationControlType = (x, y) => { return(new List <MarketingAutomation> { new MarketingAutomation { Name = DefaultText } }); }; }
private static void CreateEcnSession() { var shimECNSession = new ShimECNSession(); ShimECNSession.CurrentSession = () => shimECNSession; ShimECNSession.AllInstances.CustomerIDGet = (x) => GroupId; var fieldCurrentUser = typeof(ECNSession).GetField(CurrentUser); if (fieldCurrentUser == null) { throw new InvalidOperationException($"Field fieldCurrentCustomer should not be null"); } fieldCurrentUser.SetValue(shimECNSession.Instance, new User { UserID = GroupId }); var fieldCurrentBaseChannel = typeof(ECNSession).GetField(CurrentBaseChannel); if (fieldCurrentBaseChannel == null) { throw new InvalidOperationException($"Field fieldCurrentBaseChannel should not be null"); } fieldCurrentBaseChannel.SetValue(shimECNSession.Instance, new BaseChannel { BaseChannelID = GroupId }); var fieldCurrentCustomer = typeof(ECNSession).GetField(CurrentCustomer); if (fieldCurrentCustomer == null) { throw new InvalidOperationException($"Field fieldCurrentCustomer should not be null"); } fieldCurrentCustomer.SetValue(shimECNSession.Instance, new Customer { CustomerID = GroupId }); }
private void ShimCurrentUser(bool isActive = true) { ShimECNSession.Constructor = (instance) => { }; var ecnSession = CreateECNSession(); var shimSession = new ShimECNSession(); shimSession.ClearSession = () => { }; shimSession.Instance.CurrentUser = new KMPlatform.Entity.User { UserID = 1, UserName = TestUser, IsActive = isActive, CurrentSecurityGroup = new KMPlatform.Entity.SecurityGroup { AdministrativeLevel = SecurityGroupAdministrativeLevel.ChannelAdministrator, IsActive = true }, IsPlatformAdministrator = true }; shimSession.Instance.CurrentCustomer = new Customer { CustomerID = 1, CustomerName = TestUser, BaseChannelID = 1 }; ShimECNSession.CurrentSession = () => shimSession.Instance; }
private static void SetupShimsFor_ClientDropdownTest( int clientGroupId, string expectedHash, bool isUserAuthorised, bool isSysytemAdministrator) { const int clientId = 10; ShimBaseChannel.GetAll = () => new List <ECN_Framework_Entities.Accounts.BaseChannel> { new ECN_Framework_Entities.Accounts.BaseChannel() { PlatformClientGroupID = clientGroupId } }; ShimClient.AllInstances.SelectActiveForClientGroupLiteInt32 = (instance, _) => new List <Client> { new Client() { ClientID = clientId } }; ShimFormsAuthentication.SetAuthCookieStringBoolean = (_, __) => { }; ShimFormsAuthentication.EncryptFormsAuthenticationTicket = t => { _authenticationUserData = t.UserData; return(expectedHash); }; ShimFormsAuthentication.SignOut = () => { }; ShimCustomer.GetByClientIDInt32Boolean = (_, __) => { return(new ECN_Framework_Entities.Accounts.Customer()); }; var session = new ShimECNSession(); session.Instance.CurrentUser = new User(); session.Instance.CurrentUserClientGroupClients = new List <Client>(); session.ClientIDGet = () => 20; session.ClientGroupIDGet = () => clientGroupId; KM.Platform.Fakes.ShimUser.IsSystemAdministratorUser = (_) => isSysytemAdministrator; if (isUserAuthorised) { session.Instance.CurrentUser.UserClientSecurityGroupMaps = new List <UserClientSecurityGroupMap>() { new UserClientSecurityGroupMap() { ClientID = clientId }, new UserClientSecurityGroupMap() { ClientID = session.Instance.ClientID }, }; } ShimECNSession.CurrentSession = () => session; ShimConfigurationManager.AppSettingsGet = () => new NameValueCollection() { { "Communicator_VirtualPath", string.Empty } }; }