public void EqualsFailTest(string postId, EAccessMode access, string content, string image, string postIdExpected, EAccessMode accessExpected, string contentExpected, string imageExpected)
        {
            var actual   = new UpdatePostRequestModel(postId, access, content, image);
            var expected = new UpdatePostRequestModel(postIdExpected, accessExpected, contentExpected, imageExpected);

            Assert.IsFalse(actual.Equals(expected));
        }
 public void CtorTestExceptions(string postId, EAccessMode access, string content, string file)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var model = new UpdatePostRequestModel(postId, access, content, file);
     });
 }
Beispiel #3
0
        private bool CheckFields(string price, EBuySell recommend, EAccessMode access, string tool, EForecastTime timePeriod, string comment, string img, out bool isSimple)
        {
            bool isFieldsValid = true;

            isSimple = true;
            bool commentState = !string.IsNullOrWhiteSpace(comment);

            if (IsBuySellSelected(recommend) || IsForecastTimeSelected(timePeriod) || IsToolSelected(tool))
            {
                if (!(IsBuySellSelected(recommend) && IsForecastTimeSelected(timePeriod) && IsToolSelected(tool) &&
                      IsAccessModeSelected(access) && !string.IsNullOrWhiteSpace(price)))
                {
                    BuySellSelected(recommend);
                    ForecastTimeSelected(timePeriod);
                    ToolSelected(tool);
                    AccessModeSelected(access);
                    isFieldsValid = false;
                }
                isSimple = false;
            }

            if (string.IsNullOrWhiteSpace(img) && !IsCommentInput(commentState, true))
            {
                CommentInput(commentState, true);
                isFieldsValid = false;
            }

            return(isFieldsValid);
        }
Beispiel #4
0
 public void CtorTestExceptions(string market, EAccessMode access, string content, string file)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var model = new CreateSimplePostRequestModel(market, access, content, file);
     });
 }
Beispiel #5
0
        public void EqualsFailTest(string market, EAccessMode access, string content, string image, string marketExpected, EAccessMode accessExpected, string contentExpected, string imageExpected)
        {
            var actual   = new CreateSimplePostRequestModel(market, access, content, image);
            var expected = new CreateSimplePostRequestModel(marketExpected, accessExpected, contentExpected, imageExpected);

            Assert.IsFalse(actual.Equals(expected));
        }
Beispiel #6
0
        public void AccessModeSelectedSuccessTest(EAccessMode access)
        {
            _presenterMock.Setup(f => f.AccessModeState(EState.None));

            _interactor.AccessModeSelected(access);

            _presenterMock.Verify(f => f.AccessModeState(EState.None));
        }
Beispiel #7
0
        public void AccessModeSelectedFailTest(EAccessMode access)
        {
            _presenterMock.Setup(f => f.AccessModeState(EState.Fail));

            _interactor.AccessModeSelected(access);

            _presenterMock.Setup(f => f.AccessModeState(EState.Fail));
        }
 public void PerformQueryTestExceptions(string quote, string market, EBuySell recommend, string price,
                                        EAccessMode access, string content, string forecast, string file)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var model = new CreatePostRequestModel(quote, market, recommend, price, access, content, forecast, file);
     });
 }
 private bool IsAccessModeSelected(EAccessMode access)
 {
     if (access != EAccessMode.None)
     {
         return(true);
     }
     return(false);
 }
 public void SaveData(EAccessMode access, string comment, string image)
 {
     if (_repository.UpdatePostModel != null)
     {
         _repository.UpdatePostModel.Access  = access;
         _repository.UpdatePostModel.Image   = image;
         _repository.UpdatePostModel.Content = comment;
     }
 }
        public void AddSimplePostPositiveTest(string price, EBuySell recommend, EAccessMode access, string tool, string forecast, string comment, string img)
        {
            _repositoryMock.Setup(f => f.LangCreatePost.PriceLabel).Returns(It.IsAny <string>());
            _repositoryMock.Setup(f => f.LangCreatePost.ToolsButton).Returns(It.IsAny <string>());

            _connectionSenderMock.Setup(f => f.Send(It.IsAny <CreateSimplePostRequestModel>()));

            _interactor.AddPost(price, recommend, access, tool, forecast, comment, img);
        }
Beispiel #12
0
 /// <summary>
 /// Maps a signal to a register.
 /// </summary>
 /// <param name="sig">signal to map</param>
 /// <param name="mode">register access</param>
 /// <param name="reg">register idnex</param>
 /// <param name="startBit">bit offset in register</param>
 protected void MapSignal(SLSignal sig, EAccessMode mode, int reg, int startBit)
 {
     if (mode != EAccessMode.Read)
     {
         _writeBits[reg, startBit] = sig;
         _writeSignals.Add(sig);
     }
     if (mode != EAccessMode.Write)
     {
         _readBits[reg, startBit] = sig;
         _readSignals.Add(sig);
     }
 }
        public void PerformQueryTest(EAccessMode access, string content, string image)
        {
            var model  = new UpdatePostRequestModel("id", access, content, image);
            var actual = model.PerformQuery();

            var expected = new JObject
            {
                ["post"] = new JObject
                {
                    ["access"]  = access == EAccessMode.None ? string.Empty : access.ToString(),
                    ["content"] = content,
                    ["image"]   = !string.IsNullOrWhiteSpace(image) ? "data:image/gif;base64," + image : string.Empty
                }
            };

            Assert.IsTrue(JToken.DeepEquals(actual, expected));
        }
Beispiel #14
0
 /// <summary>
 /// Maps a signal to a register.
 /// </summary>
 /// <param name="sig">signal to map</param>
 /// <param name="mode">register access</param>
 /// <param name="reg">register index</param>
 /// <param name="startBit">start bit in register</param>
 protected void MapSignal(SLVSignal sig, EAccessMode mode, int reg, int startBit)
 {
     if (mode != EAccessMode.Read)
     {
         for (int i = 0; i < sig.Size(); i++)
         {
             _writeBits[reg, i + startBit] = sig[i];
         }
         _writeSignals.Add(sig);
     }
     if (mode != EAccessMode.Write)
     {
         for (int i = 0; i < sig.Size(); i++)
         {
             _readBits[reg, i + startBit] = sig[i];
         }
         _readSignals.Add(sig);
     }
 }
Beispiel #15
0
        public CreateSimplePostRequestModel(string market, EAccessMode access, string content, string image)
        {
            if (string.IsNullOrWhiteSpace(image) && string.IsNullOrWhiteSpace(content))
            {
                throw new ArgumentNullException(nameof(content) + " or " + nameof(image));
            }

            if (access == EAccessMode.None)
            {
                throw new ArgumentNullException(nameof(access));
            }

            Market  = market;
            Content = content;
            Image   = image;
            Access  = access.ToString();

            ApiPath        = "/api/v3/posts";
            Method         = ERestCommands.POST;
            ResponseModule = EResponseModule.CreatePost;
        }
        public void PerformQueryTest(string quote, string market, EBuySell recommend, string price,
                                     EAccessMode access, string content, string forecast, string file)
        {
            CreatePostRequestModel model = new CreatePostRequestModel(quote, market, recommend, price, access, content, forecast, file);
            var actual = model.PerformQuery();

            foreach (var item in typeof(CreatePostRequestModel).GetRuntimeMethods())
            {
                var res = item.GetParameters();
                if (item.Name.Equals("GetStringForecastTime") && item.GetParameters().First().ParameterType == typeof(string))
                {
                    forecast = item.Invoke(model, new object[] { forecast }) as string;
                    break;
                }
            }

            var expected = new JObject
            {
                ["quote"]     = quote,
                ["market"]    = market,
                ["recommend"] = recommend == EBuySell.None ? string.Empty : recommend.ToString(),
                ["access"]    = access == EAccessMode.None ? string.Empty : access.ToString(),
                ["forecast"]  = forecast
            };

            if (!string.IsNullOrWhiteSpace(price))
            {
                expected["price"] = price;
            }
            if (!string.IsNullOrWhiteSpace(file))
            {
                expected["image"] = "data:image/gif;base64," + file;
            }
            if (!string.IsNullOrWhiteSpace(content))
            {
                expected["content"] = content;
            }

            Assert.IsTrue(JToken.DeepEquals(actual, expected));
        }
Beispiel #17
0
        public void PerformQueryTest(string market, EAccessMode access, string content, string image)
        {
            var model  = new CreateSimplePostRequestModel(market, access, content, image);
            var actual = model.PerformQuery();

            var expected = new JObject
            {
                ["market"] = market,
                ["access"] = access == EAccessMode.None ? string.Empty : access.ToString()
            };

            if (!string.IsNullOrWhiteSpace(image))
            {
                expected["image"] = "data:image/gif;base64," + image;
            }
            if (!string.IsNullOrWhiteSpace(content))
            {
                expected["content"] = content;
            }

            Assert.IsTrue(JToken.DeepEquals(actual, expected));
        }
Beispiel #18
0
        public void AddPost(string price, EBuySell recommend, EAccessMode access, string tool, string timePeriod, string comment, string img)
        {
            if (_currentRecieveStatus == EControllerStatus.Processing)
            {
                return;
            }

            if (!CheckFields(price, recommend, access, tool, timePeriod, comment, img, out bool isPostSimple))
            {
                return;
            }
            comment = comment?.Trim(' ').Trim('\n');

            if (isPostSimple)
            {
                _createPostController.Send(new CreateSimplePostRequestModel(market: "Simple", access: access, content: comment, image: img));
            }
            else
            {
                _createPostController.Send(new CreatePostRequestModel(quote: tool, market: "Currency",
                                                                      recommend: recommend, price: price, access: access, content: comment, forecast: timePeriod, image: img));
            }
        }
        public void UpdatePost(EAccessMode access, string comment, string image)
        {
            if (_currentRecieveStatus == EControllerStatus.Processing)
            {
                return;
            }

            if (!IsCommentInput(comment, true) && string.IsNullOrWhiteSpace(image))
            {
                CommentInput(comment, true);
                return;
            }

            if (!IsAccessModeSelected(access))
            {
                AccessModeSelected(access);
                return;
            }

            comment = comment?.Trim(' ').Trim('\n');

            _updatePostController.Send(new UpdatePostRequestModel(_repository.UpdatePostModel.Id, access, comment, image));
        }
Beispiel #20
0
        public UpdatePostRequestModel(string id, EAccessMode access, string content, string image)
        {
            if (string.IsNullOrWhiteSpace(image) && string.IsNullOrWhiteSpace(content))
            {
                throw new ArgumentNullException(nameof(content) + " or " + nameof(image));
            }

            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (access == EAccessMode.None)
            {
                throw new ArgumentNullException(nameof(access));
            }

            Content = content;
            Image   = image;
            Access  = access.ToString();

            ApiPath = "/api/v3/posts/" + id;
            Method  = ERestCommands.PUT;
        }
Beispiel #21
0
 /// <summary>
 /// Maps a signal to a register.
 /// </summary>
 /// <param name="sig">signal to map</param>
 /// <param name="mode">register access</param>
 /// <param name="reg">register index</param>
 /// <param name="startBit">offset into register</param>
 protected void MapSignal(SLSignal sig, EAccessMode mode, int reg, int startBit)
 {
     if (mode != EAccessMode.Read)
     {
         _writeBits[reg, startBit] = sig;
         _writeSignals.Add(sig);
     }
     if (mode != EAccessMode.Write)
     {
         _readBits[reg, startBit] = sig;
         _readSignals.Add(sig);
     }
 }
Beispiel #22
0
 /// <summary>
 /// Maps a signal to a register.
 /// </summary>
 /// <param name="sig">signal to map</param>
 /// <param name="mode">register access</param>
 /// <param name="reg">register index</param>
 /// <param name="startBit">start bit in register</param>
 protected void MapSignal(SLVSignal sig, EAccessMode mode, int reg, int startBit)
 {
     if (mode != EAccessMode.Read)
     {
         for (int i = 0; i < sig.Size(); i++)
             _writeBits[reg, i + startBit] = sig[i];
         _writeSignals.Add(sig);
     }
     if (mode != EAccessMode.Write)
     {
         for (int i = 0; i < sig.Size(); i++)
             _readBits[reg, i + startBit] = sig[i];
         _readSignals.Add(sig);
     }
 }
        public void AddPostForecastStringPositiveTest(string price, EBuySell recommend, EAccessMode access, string tool, string forecast, string comment, string img)
        {
            _presenterMock.Setup(f => f.AccessModeState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.ForecastTimeState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.ToolState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.CommentState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.BuySellState(It.IsAny <EState>()));
            _repositoryMock.Setup(f => f.LangCreatePost.PriceLabel).Returns(It.IsAny <string>());
            _repositoryMock.Setup(f => f.LangCreatePost.ToolsButton).Returns(It.IsAny <string>());

            foreach (var item in typeof(InteractorCreatePost).GetRuntimeFields())
            {
                if (item.Name.Equals("_selectedTool"))
                {
                    item.SetValue(_interactor, "AUD/CAD");
                }
            }

            _connectionSenderMock.Setup(f => f.Send(It.IsAny <CreatePostRequestModel>()));

            _interactor.AddPost(price, recommend, access, tool, forecast, comment, img);
            _connectionSenderMock.Verify(f => f.Send(It.IsAny <CreatePostRequestModel>()));
        }
Beispiel #24
0
 public void AddPost(string price, EBuySell recommend, EAccessMode access, string tool, string timePeriod, string comment, string img)
 {
     _interactor.AddPost(price, recommend, access, tool, timePeriod, comment, img);
 }
 public void AccessModeSelected(EAccessMode access)
 {
     Presenter.AccessModeState(IsAccessModeSelected(access) ? EState.None : EState.Fail);
 }
Beispiel #26
0
        public static string GetLocaleStringFromEnum(this EAccessMode recommend)
        {
            var result = Locale.Localization.Lang.GetType().GetRuntimeProperty(recommend.ToString()).GetValue(Locale.Localization.Lang) as string;

            return(result);
        }
Beispiel #27
0
 public void AccessModeSelected(EAccessMode access)
 {
     _interactor.AccessModeSelected(access);
 }
Beispiel #28
0
 public void UpdatePost(EAccessMode access, string comment, string image)
 {
     _interactor.UpdatePost(access, comment, image);
 }
Beispiel #29
0
 public void SaveData(EAccessMode access, string comment, string image)
 {
     _interactor.SaveData(access, comment, image);
 }
        public void AddPostForecastStringNegativeTest(string price, EBuySell recommend, EAccessMode access, string tool, string forecast, string comment, string img)
        {
            _presenterMock.Setup(f => f.AccessModeState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.ForecastTimeState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.ToolState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.CommentState(It.IsAny <EState>()));
            _presenterMock.Setup(f => f.BuySellState(It.IsAny <EState>()));
            _repositoryMock.Setup(f => f.LangCreatePost.PriceLabel).Returns(It.IsAny <string>());
            _repositoryMock.Setup(f => f.LangCreatePost.ToolsButton).Returns(It.IsAny <string>());

            _interactor.AddPost(price, recommend, access, tool, forecast, comment, img);
        }
Beispiel #31
0
 private static extern SafeFileHandle CreateFile(string fileName, EAccessMode accessMode,
                                                 EShareMode shareMode, IntPtr lpSecurityAttributes, ECreationDisposition creationDisposition,
                                                 uint dwFlagsAndAttributes, IntPtr hTemplateFile);
Beispiel #32
0
        private void CreatePostRequestModelMainPart(string quote, string market, EBuySell recommend, string price, EAccessMode access, string content, string forecast, string file)
        {
            if (string.IsNullOrWhiteSpace(file) && string.IsNullOrWhiteSpace(content))
            {
                throw new ArgumentNullException(nameof(file) + " or " + nameof(content));
            }

            if (recommend == EBuySell.None || access == EAccessMode.None || string.IsNullOrWhiteSpace(price) ||
                string.IsNullOrWhiteSpace(forecast) || string.IsNullOrWhiteSpace(quote))
            {
                throw new ArgumentNullException(nameof(recommend) + " or " + nameof(access) + " or " + nameof(price) + " or " + nameof(forecast) + " or " + nameof(quote));
            }

            Quote     = quote?.Replace("/", string.Empty);
            Recommend = recommend == EBuySell.None ? string.Empty : recommend.ToString();
            Price     = price;
            Forecast  = forecast;
        }