示例#1
0
        public Specification when_updating_status_with_access_token()
        {
            const string statusText      = "some test status";
            var          statusViewModel = new StatusViewModel
            {
                Status = statusText
            };
            ISessionAdapter session       = sessionFactory();
            var             testDbContext = new TestDbContext();
            Container       container     = containerFactory(testDbContext);

            var mockTwitterProvider = MockTwitterProvider(statusText);

            container.TwitterServiceFactory = () => mockTwitterProvider.Object;

            int statusCount = testDbContext.Statuses.Count;

            return(new ActionSpecification <TwitterController>
            {
                On = () =>
                {
                    session.SetTwitterAccessToken(new OAuthToken("", ""));
                    return GetTwitterController(container, session);
                },
                When = ctrl => ctrl.UpdateStatus(statusViewModel),
                Expect =
                {
                    ctrl => testDbContext.Statuses.Count == statusCount + 1,
                    ctrl => testDbContext.Statuses.Last().Value.Text == statusText,
                },
            });
        }
示例#2
0
 public GameModule(
     ICacheAdapter appCache,
     ISessionAdapter session,
     IResponseAdapter response)
     : base(appCache, session, response)
 {
 }
 public FillFileHistory(ISessionAdapter sessionAdapter, IRepository api, ReviewRevision currentRevision, FeatureToggle features)
 {
     _sessionAdapter  = sessionAdapter;
     _api             = api;
     _currentRevision = currentRevision;
     _features        = features;
 }
示例#4
0
 public EnergyTankModule(
     ICacheAdapter appCache,
     ISessionAdapter session,
     IResponseAdapter response)
     : base(appCache, session, response)
 {
 }
 public EnergyTankModule(
     ICacheAdapter appCache,
     ISessionAdapter session,
     IResponseAdapter response) :
     base(appCache, session, response)
 {
 }
        public static bool ValidateJSONRequestSessionHasAdminOpsLevel(
            ISessionAdapter session,
            out string error_code)
        {
            bool success            = true;
            int  session_account_id = GetSessionAccountID(session);

            DatabaseConstants.OpsLevel opsLevel =
                AccountQueries.GetAccountOpsLevel(
                    ApplicationConstants.CONNECTION_STRING,
                    session_account_id,
                    out error_code);

            if (opsLevel != DatabaseConstants.OpsLevel.invalid)
            {
                if (opsLevel >= DatabaseConstants.OpsLevel.admin)
                {
                    error_code = SuccessMessages.GENERAL_SUCCESS;
                    success    = true;
                }
                else
                {
                    error_code = ErrorMessages.INSUFFICIENT_OPS_LEVEL;
                }
            }

            return(success);
        }
示例#7
0
        public static bool ValidateJSONRequestSessionHasAdminOpsLevel(
            ISessionAdapter session,
            out string error_code)
        {
            bool success = true;
            int session_account_id = GetSessionAccountID(session);
            DatabaseConstants.OpsLevel opsLevel =
                AccountQueries.GetAccountOpsLevel(
                    ApplicationConstants.CONNECTION_STRING,
                    session_account_id,
                    out error_code);

            if (opsLevel != DatabaseConstants.OpsLevel.invalid)
            {
                if (opsLevel >= DatabaseConstants.OpsLevel.admin)
                {
                    error_code = SuccessMessages.GENERAL_SUCCESS;
                    success = true;
                }
                else
                {
                    error_code = ErrorMessages.INSUFFICIENT_OPS_LEVEL;
                }
            }

            return success;
        }
示例#8
0
 public EffortsController(ISessionAdapter sessionAdapter, IAddNewJobTaskComboCommand addNewJobTaskComboCommand, IRemoveRowCommand removeRowCommand, IModifyJobTaskComboCommand modifyJobTaskComboCommand)
 {
     _sessionAdapter            = sessionAdapter;
     _addNewJobTaskComboCommand = addNewJobTaskComboCommand;
     _removeRowCommand          = removeRowCommand;
     _modifyJobTaskComboCommand = modifyJobTaskComboCommand;
 }
 public AccountModule(
     ICacheAdapter appCache,
     ISessionAdapter session,
     IResponseAdapter response) :
     base(appCache, session, response)
 {
 }
示例#10
0
        public static bool VerifySessionOwnsCharacter(ISessionAdapter session, int character_id)
        {
            int[] characters_ids       = (int[])session["CharacterIDs"];
            bool  sessionOwnsCharacter = characters_ids.Contains(character_id);

            return(sessionOwnsCharacter);
        }
示例#11
0
 public CharacterModule(
     ICacheAdapter appCache,
     ISessionAdapter session,
     IResponseAdapter response) :
     base(appCache, session, response)
 {
 }
示例#12
0
        public Specification when_updating_status_with_invalid_model()
        {
            string statusText      = new string('*', 141);
            var    statusViewModel = new StatusViewModel
            {
                Status = statusText
            };
            ISessionAdapter session       = sessionFactory();
            var             testDbContext = new TestDbContext();
            Container       container     = containerFactory(testDbContext);

            int maxId = testDbContext.Statuses.Max(_ => _.Key);

            return(new QuerySpecification <TwitterController, ViewResult>
            {
                On = () =>
                {
                    session.SetTwitterAccessToken(new OAuthToken("", ""));
                    return GetTwitterController(container, session);
                },
                When = ctrl => ctrl.UpdateStatus(statusViewModel) as ViewResult,
                Expect =
                {
                    routeResult => routeResult.ViewName == "Send",
                },
            });
        }
 protected TwitterController GetTwitterController(Container container = null, ISessionAdapter session = null)
 {
     return new TwitterController(container, session)
                {
                    ControllerContext =
                        new ControllerContext()
                };
 }
 public QuickJobTimeReportQuery(IConfiguration configuration, ISessionAdapter sessionAdapter, IJobsRepository jobsRepository, ISitesRepository sitesRepository, IClientsRepository clientsRepository)
 {
     this.configuration = configuration;
     _sessionAdapter    = sessionAdapter;
     _jobsRepository    = jobsRepository;
     _sitesRepository   = sitesRepository;
     _clientsRepository = clientsRepository;
 }
示例#15
0
 public ExpenseController(IJobsRepository jobsService, ISessionAdapter sessionAdapter, IExpenseService expenseService, IConfiguration config, IUploadLocationResolver uploadLocationResolver)
 {
     _jobsService            = jobsService;
     _sessionAdapter         = sessionAdapter;
     _expenseService         = expenseService;
     _config                 = config;
     _uploadLocationResolver = uploadLocationResolver;
 }
 protected TwitterController GetTwitterController(Container container = null, ISessionAdapter session = null)
 {
     return(new TwitterController(container, session)
     {
         ControllerContext =
             new ControllerContext()
     });
 }
示例#17
0
 public RestModule(
     ICacheAdapter appCache,
     ISessionAdapter session,
     IResponseAdapter response)
 {
     this.Application = appCache;
     this.Session     = session;
     this.Response    = response;
 }
示例#18
0
 public RestModule(
     ICacheAdapter appCache,
     ISessionAdapter session, 
     IResponseAdapter response)
 {
     this.Application = appCache;
     this.Session = session;
     this.Response = response;
 }
示例#19
0
        public static bool IsSessionAuthenticated(ISessionAdapter session)
        {
            bool isAuthenticated = false;

            if (session["Authenticated"] != null)
            {
                isAuthenticated = (bool)session["Authenticated"];
            }

            return isAuthenticated;
        }
示例#20
0
        public static bool IsSessionAdminAuthenticated(ISessionAdapter session)
        {
            bool isAdminAuthenticated = false;

            if (session["Authenticated"] != null && session["OpsLevel"] != null)
            {
                isAdminAuthenticated = (bool)session["Authenticated"] && (bool)session["OpsLevel"];
            }

            return(isAdminAuthenticated);
        }
示例#21
0
 public TimeApprovalController(ITimeApprovalService timeApprovalService,
                               IApproveTimeCommand approveTimeCommand,
                               IWeekOfTimeEntriesQuery weekOfTimeEntriesQuery,
                               ITimeApprovalListQuery timeApprovalListQuery,
                               ISessionAdapter sessionAdapter)
 {
     this.timeApprovalService    = timeApprovalService;
     this.approveTimeCommand     = approveTimeCommand;
     this.weekOfTimeEntriesQuery = weekOfTimeEntriesQuery;
     this.timeApprovalListQuery  = timeApprovalListQuery;
     this.sessionAdapter         = sessionAdapter;
 }
示例#22
0
 public JobsController(IClientsRepository clientRepository,
                       IJobsRepository jobsRepository,
                       IEmployeeRepository employeeRepository,
                       ISitesRepository siteRepository,
                       ITimeService timeService,
                       ISessionAdapter sessionAdapter,
                       IMapper mapper)
 {
     this.clientRepository    = clientRepository;
     this._jobsRepository     = jobsRepository;
     this._employeeRepository = employeeRepository;
     this.siteRepository      = siteRepository;
     this.timeService         = timeService;
     this.sessionAdapter      = sessionAdapter;
     _mapper = mapper;
 }
示例#23
0
        public static bool ValidateJSONRequestHasAuthenticatedSession(
            ISessionAdapter session,
            out string error_code)
        {
            bool success = true;

            error_code = SuccessMessages.GENERAL_SUCCESS;

            if (!IsSessionAuthenticated(session))
            {
                error_code = ErrorMessages.NOT_AUTHENTICATED;
                success = false;
            }

            return success;
        }
示例#24
0
        public static bool ValidateJSONRequestHasAuthenticatedSession(
            ISessionAdapter session,
            out string error_code)
        {
            bool success = true;

            error_code = SuccessMessages.GENERAL_SUCCESS;

            if (!IsSessionAuthenticated(session))
            {
                error_code = ErrorMessages.NOT_AUTHENTICATED;
                success    = false;
            }

            return(success);
        }
示例#25
0
        public static bool ValidateJSONRequestSessionOwnsCharacter(
            ISessionAdapter session,
            int characterId,
            out string error_code)
        {
            bool success = true;

            error_code = SuccessMessages.GENERAL_SUCCESS;

            if (!VerifySessionOwnsCharacter(session, characterId))
            {
                error_code = ErrorMessages.INVALID_REQUEST;
                success    = false;
            }

            return(success);
        }
示例#26
0
        public static bool ValidateJSONRequestSessionLoggedInAsUser(
            ISessionAdapter session,
            string username,
            out string error_code)
        {
            bool success = true;

            error_code = SuccessMessages.GENERAL_SUCCESS;

            if (GetSessionUsername(session) != username)
            {
                error_code = ErrorMessages.NOT_LOGGED_IN;
                success    = false;
            }

            return(success);
        }
示例#27
0
        public Specification when_updating_status_with_no_access_token()
        {
            const string statusText      = "some test status";
            var          statusViewModel = new StatusViewModel
            {
                Status = statusText
            };
            ISessionAdapter session = sessionFactory();

            return(new QuerySpecification <TwitterController, ActionResult>
            {
                On = () => GetTwitterController(session: session),
                When = ctrl => ctrl.UpdateStatus(statusViewModel),
                Expect =
                {
                    actionResult => session.GetTwitterNewStatus() == statusText,
                    actionResult => actionResult is RedirectToRouteResult,
                    actionResult =>
                    ((RedirectToRouteResult)actionResult).RouteValues["action"] == "SignIn",
                },
            });
        }
示例#28
0
 public TimeEntryController(//IWeekService weekService,
     ICopyPreviousWeekTimeCommand copyPreviousWeekTimeCommand,
     ISaveTimeEntriesCommand saveTimeEntriesCommand,
     IAddNewJobTaskComboCommand addNewJobTaskComboCommand,
     IWeekOfTimeEntriesQuery weekOfTimeEntriesQuery,
     IWeekIdentifierListQuery weekIdentifierListQuery,
     IApproveTimeCommand approveTimeCommand,
     IRemoveRowCommand removeRowCommand,
     IModifyJobTaskComboCommand modifyJobTaskComboCommand,
     ISessionAdapter sessionAdapter,
     IExpenseService expenseService)
 {
     //this.weekService = weekService;
     this.copyPreviousWeekTimeCommand = copyPreviousWeekTimeCommand;
     this.saveTimeEntriesCommand      = saveTimeEntriesCommand;
     this.addNewJobTaskComboCommand   = addNewJobTaskComboCommand;
     this.weekOfTimeEntriesQuery      = weekOfTimeEntriesQuery;
     this.weekIdentifierListQuery     = weekIdentifierListQuery;
     this.approveTimeCommand          = approveTimeCommand;
     this.removeRowCommand            = removeRowCommand;
     this.modifyJobTaskComboCommand   = modifyJobTaskComboCommand;
     this.sessionAdapter = sessionAdapter;
     _expenseService     = expenseService;
 }
 public static OAuthToken GetTwitterAccessToken(this ISessionAdapter obj)
 {
     return(obj.GetValueOrEmpty <OAuthToken>(AccessTokenCode));
 }
示例#30
0
 public TimeController(ISessionAdapter sessionAdapter, ISaveTimeEntriesCommand saveTimeEntriesCommand, IWeekOfTimeEntriesQuery weekOfTimeEntriesQuery)
 {
     _sessionAdapter         = sessionAdapter;
     _saveTimeEntriesCommand = saveTimeEntriesCommand;
     _weekOfTimeEntriesQuery = weekOfTimeEntriesQuery;
 }
 public FindOrCreateRevisionPublisher(ISessionAdapter sessionAdapter, RevisionFactory factory, IRepository api)
 {
     _sessionAdapter = sessionAdapter;
     _factory        = factory;
     _api            = api;
 }
 public FindOrCreateReviewPublisher(ISessionAdapter sessionAdapter, [CurrentUser] ReviewUser user)
 {
     _sessionAdapter = sessionAdapter;
     _user           = user;
 }
 //ctor for mocking
 internal BaseController(Container container, ISessionAdapter sessionAdapter)
 {
     _container = new Lazy<Container>(() => container);
     _sessionAdapter = new Lazy<ISessionAdapter>(() => sessionAdapter);
 }
 public static void SetTwitterStatus(this ISessionAdapter obj, string value)
 {
     obj.SetValue(StatusCode, value);
 }
示例#35
0
        public static bool VerifySessionOwnsCharacter(ISessionAdapter session, int character_id)
        {
            int[] characters_ids = (int[])session["CharacterIDs"];
            bool sessionOwnsCharacter = characters_ids.Contains(character_id);

            return sessionOwnsCharacter;
        }
示例#36
0
 public FileDiscussionsPublisher(ISessionAdapter sessionAdapter, FindReviewDelegate reviewForRevision, Func <ClientFileId, Guid> resolveFileId)
 {
     _sessionAdapter    = sessionAdapter;
     _reviewForRevision = reviewForRevision;
     _resolveFileId     = resolveFileId;
 }
 public static void SetTwitterAccessToken(this ISessionAdapter obj, OAuthToken value)
 {
     obj.SetValue(AccessTokenCode, value);
 }
示例#38
0
 public static string GetSessionUsername(ISessionAdapter session)
 {
     return (string)session["Username"];
 }
 internal TwitterController(Container container, ISessionAdapter sessionAdapter)
     : base(container, sessionAdapter)
 {
 }
 public static string GetTwitterNewStatus(this ISessionAdapter obj)
 {
     return(obj.GetValueOrEmpty <string>(StatusCode));
 }
示例#41
0
        public static bool ValidateJSONRequestSessionLoggedInAsUser(
            ISessionAdapter session,
            string username,
            out string error_code)
        {
            bool success = true;

            error_code = SuccessMessages.GENERAL_SUCCESS;

            if (GetSessionUsername(session) != username)
            {
                error_code = ErrorMessages.NOT_LOGGED_IN;
                success = false;
            }

            return success;
        }
 internal TwitterController(Container container, ISessionAdapter sessionAdapter)
     : base(container, sessionAdapter)
 {
 }
示例#43
0
        public static bool ValidateJSONRequestSessionOwnsCharacter(
            ISessionAdapter session,
            int characterId,
            out string error_code)
        {
            bool success = true;

            error_code = SuccessMessages.GENERAL_SUCCESS;

            if (!VerifySessionOwnsCharacter(session, characterId))
            {
                error_code = ErrorMessages.INVALID_REQUEST;
                success = false;
            }

            return success;
        }
示例#44
0
 public static int GetSessionAccountID(ISessionAdapter session)
 {
     return (int)session["AccountId"];
 }
 public ShoppingCartService(ITicketsService ticketsService, ISessionAdapter sessionAdapter)
 {
     this.ticketsService = ticketsService;
     this.sessionAdapter = sessionAdapter;
 }