Ejemplo n.º 1
0
 public TickRegistrationRequestPacket(int requestId, string symbol, RegistrationAction action)
     : base(APINetworkPacketType.TickRegistrationRequest)
 {
     this.RequestId = requestId;
     this.Symbol = symbol;
     this.RegistrationAction = action;
 }
Ejemplo n.º 2
0
 public TickRegistrationRequestPacket(int requestId, string symbol, RegistrationAction action)
     : base(APINetworkPacketType.TickRegistrationRequest)
 {
     this.RequestId          = requestId;
     this.Symbol             = symbol;
     this.RegistrationAction = action;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a registration handler that will be executed if the context's ResolvedType equals <typeparam name="T"/>
 /// </summary>
 /// <param name="options"></param>
 /// <param name="registrationAction"></param>
 /// <param name="priority"></param>
 /// <returns></returns>
 public static Options WithRegistrationHandlerFor <T>(this Options options, RegistrationAction registrationAction, int?priority = null) where T : class
 {
     return(options.WithRegistrationHandler(
                context => context.ResolvedType != null && context.ResolvedType == typeof(T),
                registrationAction,
                priority
                ));
 }
Ejemplo n.º 4
0
        public void RegistrationAction_AggregateException()
        {
            //Arrange
            var action = new RegistrationAction(_mockRepoTrue.Object, _mockUsService.Object, _mockValService.Object, _mockValManager.Object, _log);

            //Act and Assert
            Assert.ThrowsException <AggregateException>(() => action.ProcessAction(new ApiModel.User()).Result, "UserLogin property is null. Invalid value.");
            Assert.ThrowsException <AggregateException>(() => action.ProcessAction(null).Result, "Parameter is null. Invalid value.");
        }
Ejemplo n.º 5
0
        public void RegistrationAction_Successful()
        {
            //Arrange
            var action = new RegistrationAction(_mockRepoTrue.Object, _mockUsService.Object, _mockValService.Object, _mockValManager.Object, _log);
            //Act
            var result = action.ProcessAction(_userApi).Result;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RepoModel.User));
        }
Ejemplo n.º 6
0
        public void RegistrationAction_NoSavedToStorage_Failed()
        {
            //Arrange
            var action = new RegistrationAction(_mockRepoFalse.Object, _mockUsService.Object, _mockValService.Object, _mockValManager.Object, _log);
            //Act
            var result = action.ProcessAction(_userApi).Result;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Result));
            Assert.IsTrue(((Result)result).StatusCode == StatusCode.Failed);
            Assert.IsTrue(((Result)result).ErrorCode == ErrorCode.DataBaseError);
        }
Ejemplo n.º 7
0
        private void Update()
        {
            for (int i = 0, ilen = _actions.Count; i < ilen; ++i)
            {
                RegistrationAction action = _actions[i];
                if (action.Type == RegistrationActionType.Add)
                {
                    _items.Add(action.Updatable);
                }
                else
                {
                    _items.Remove(action.Updatable);
                }
            }
            _actions.Clear();

            for (int i = 0, ilen = _items.Count; i < ilen; ++i)
            {
                IUpdatable item = _items[i];
                item.Update(Time.deltaTime);
            }
        }
Ejemplo n.º 8
0
        public void RegistrationAction_ValidationService_Failed()
        {
            //Mock
            //Returns an error result in validation
            var mockValService = new Mock <IValidationService>();

            mockValService.Setup(v => v.ProcessValidation(_mockValManager.Object, It.IsAny <RepoModel.User>())).Returns(
                Task.FromResult(new Result
            {
                ErrorCode    = ErrorCode.UserAlreadyExists, StatusCode = StatusCode.Failed,
                StatusDetail = "Test User Already Exists"
            } as object));
            //Arrange
            var action = new RegistrationAction(_mockRepoTrue.Object, _mockUsService.Object, mockValService.Object, _mockValManager.Object, _log);
            //Act
            var result = action.ProcessAction(_userApi).Result;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Result));
            Assert.IsTrue(((Result)result).StatusCode == StatusCode.Failed);
            Assert.IsTrue(((Result)result).ErrorCode == ErrorCode.UserAlreadyExists);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actionToPerform"></param>
        /// <param name="sourceId"></param>
        /// <param name="objectHtml"></param>
        /// <param name="objectId"></param>
        /// <param name="css"></param>
        internal void PerformAction(RegistrationAction actionToPerform, String sourceId, String objectHtml, String objectId, String css)
        {
            var msg = new JSON.JsonHelper((int)actionToPerform, sourceId, objectHtml, objectId, css);

            _WEBVIEW_OWNERS[this].SendJavaScript(msg.ToString());
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actionToPerform"></param>
        /// <param name="id"></param>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        internal void PerformAction(RegistrationAction actionToPerform, String id, String propertyName, String propertyValue)
        {
            var msg = new JSON.JsonHelper((int)actionToPerform, id, propertyName, propertyValue);

            _WEBVIEW_OWNERS[this].SendJavaScript(msg.ToString());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Notifies the webview that an event
        /// </summary>
        /// <param name="actionToPerform">The action to send to the HTML page</param>
        /// <param name="id">Which element to send it to</param>
        /// <param name="type">The type of action</param>
        internal void PerformAction(RegistrationAction actionToPerform, String id, HtmlEventType type)
        {
            var msg = new JSON.JsonHelper((int)actionToPerform, id, type.ToString());

            _WEBVIEW_OWNERS[this].SendJavaScript(msg.ToString());
        }
 public RegistrationHandler(Predicate <RegistrationContext> predicate, RegistrationAction registrationAction, int priority)
 {
     Predicate          = predicate;
     RegistrationAction = registrationAction;
     Priority           = priority;
 }
 /// <summary>
 /// Extension point that allows the consumer to perform a specific registration if the provided predicate returns true.
 /// The highest priority (whose predicate returns true) is chosen for execution; if there are multiple of the same priority, then the highest priority that was the last one registered wins.
 /// If none can be found, the default behavior (registering by type using <see cref="TryResolveType"/> funcs) is executed.
 /// </summary>
 /// <param name="predicate">If this returns true (and I'm the first eligible), then execute the provided action.</param>
 /// <param name="registrationAction">The registration action to perform. Consider using extension methods such as <see cref="TypeRegistrationExtensions.ResolveUsingAutofac{T}"/></param>
 /// <param name="priority">Defaults to 0 if not provided.</param>
 /// <returns></returns>
 public Options WithRegistrationHandler(Predicate <RegistrationContext> predicate, RegistrationAction registrationAction, int?priority = null)
 {
     RegistrationHandlers.Add(new RegistrationHandler(predicate, registrationAction, priority ?? 0));
     return(this);
 }
Ejemplo n.º 14
0
        private void button_SaveUser(object sender, EventArgs e)
        {
            ResetLabels();

            bool isValid = true;

            if (String.IsNullOrEmpty(usernameTextBox.Text))
            {
                SetUsernameLabelMessage("Username is required");
                isValid = false;
            }
            else
            {
                bool isUserNameValid = RegistrationAction.CheckUsernameForRegistration(usernameTextBox.Text);
                if (isUserNameValid)
                {
                    int userId = UserService.GetUserById(usernameTextBox.Text);

                    if (userId != 0)
                    {
                        SetUsernameLabelMessage("The username exists already!");
                        isValid = false;
                    }
                }
                else
                {
                    SetUsernameLabelMessage("The username must contain between 5 and 15 characters.");
                    isValid = false;
                }
            }

            if (String.IsNullOrEmpty(passwordTextBox.Text))
            {
                SetPasswordLabelMessage("Password is required.");
                isValid = false;
            }
            else
            {
                bool isPasswordValid = RegistrationAction.CheckPasswordForRegistration(passwordTextBox.Text);
                if (!isPasswordValid)
                {
                    SetPasswordLabelMessage("The password is incorrect. Must contain at least 1 uppercase character, "
                                            + "\n"
                                            + "1 lowercase character and 1 digit "
                                            + "and have the lenght between 6 and 15");
                    isValid = false;
                }
            }

            if (String.IsNullOrEmpty(confirmPassTextBox.Text))
            {
                SetConfirmPassLabelMessage("Confirm password is required.");
                isValid = false;
            }
            else
            {
                if (passwordTextBox.Text != confirmPassTextBox.Text)
                {
                    SetConfirmPassLabelMessage("Must coincide with previous entry.");
                    isValid = false;
                }
            }

            if (isValid)
            {
                UserService.RegisterUser(usernameTextBox.Text, passwordTextBox.Text);
                SetSuccesfullLabelMessage("The user has been succesfully registered. You can now login!");
                usernameTextBox.Text    = "";
                passwordTextBox.Text    = "";
                confirmPassTextBox.Text = "";
            }
        }
Ejemplo n.º 15
0
 public void RequestTickRegistration_Has_Send_The_Right_Packet(string symbol, RegistrationAction action)
 {
     VerifyRequest <TickRegistrationRequestPacket>(c => c.RequestTickRegistration(symbol, action),
                                                   p => p.Symbol == symbol &&
                                                   p.RegistrationAction == action);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Registers for tick stream for a given instrument
 /// </summary>
 /// <param name="symbol">Symbol that is being registered for</param>
 /// <param name="action">Register for/Unregister from streaming</param>
 /// <returns>A task that represents tick registration process. The value of the result contains returnet packet.</returns>
 public Task <TickRegistrationResponsePacket> RequestTickRegistration(string symbol, RegistrationAction action)
 {
     return(HandleRequestPacket <TickRegistrationResponsePacket>(reqId => new TickRegistrationRequestPacket(reqId, symbol, action)));
 }