예제 #1
0
        public void CalculationTest(double value, double answer)
        {
            var    calculator = new Reverse();
            double actual     = calculator.calculate(value);

            Assert.AreEqual(answer, actual, 0.001);
        }
예제 #2
0
        void InternalAdd(T1 t1, T2 t2)
        {
            try
            {
                if (t1 == null || t2 == null)
                {
                    throw new ArgumentException("Null key value", "Null value is not allowed.");
                }

                if (Forward.ContainsKey(t1) || Reverse.ContainsKey(t2))
                {
                    throw new System.ArgumentException("A pair with same item already exist!");
                }
                else
                {
                    Forward.Add(t1, t2);
                    Reverse.Add(t2, t1);
                }
            }
            catch (Exception e)
            {
                // throw new System.Exception("BiMap: Unknow exception in Add().");
                throw e;
            }
        }
예제 #3
0
        public void CalculateReverseTestStrong(double firstValue, double expected)
        {
            IOneArgumentCalculator calculator = new Reverse();
            double result = calculator.Calculate(firstValue);

            Assert.AreEqual(expected, result);
        }
예제 #4
0
        public void TestReverseWithOriginalString()
        {
            string reversed = ".eslaf eb t'ndluow ecnetnes siht ,dehctiws erew eslaf dna eurt fo sgninaem eht fI";
            string expected = "If the meanings of true and false were switched, this sentence wouldn't be false.";

            Assert.AreEquals(expected, Reverse.Reverse(reversed));
        }
예제 #5
0
 private void reversing()
 {
     TextOGlitchForm1.threadLocalization();
     CheckForIllegalCrossThreadCalls = false;
     ////for (int i = 0; i < work.Length; i++)
     ////{
     //if (work[i] != '\r')
     //{
     ////    reverseWork[reverseWork.Length - i - 1] = work[i];
     ////    label1.Text = "Реверснуто символов: " + (i + 1) + "/" + work.Length;
     //}
     //else
     //{
     //    reverseWork[reverseWork.Length - i - 1] = work[i + 1];
     //    reverseWork[reverseWork.Length - i - 2] = work[i];
     //    i++;
     //}
     ////label1.Update();
     ////}
     output = new string(work);
     output = output.Trim('\r');
     output = Reverse.Text(output);
     ////output = new string(reverseWork);
     richTextBox2.Text    = output;
     label1.Text          = Translate.done;
     richTextBox1.Enabled = true;
     glitchMass.Enabled   = true;
     replaceMass.Enabled  = true;
     reverseMass.Enabled  = true;
     startMass.Enabled    = true;
     paste.Enabled        = true;
 }
예제 #6
0
 public static void FinishMIDIHeader(BinaryWriter bw)
 {
     bw.BaseStream.Position  = 10L;
     HeaderData.TotalLayers += 1;
     // INSTANT VB WARNING: An assignment within expression was extracted from the following statement:
     // ORIGINAL LINE: bw.Write(OutputMIDI.Reverse.Int16(++OutputMIDI.HeaderData.TotalLayers));
     bw.Write(Reverse.Int16(HeaderData.TotalLayers));
 }
예제 #7
0
 public static void StartMIDIHeader(BinaryWriter bw)
 {
     bw.Write(Reverse.String32("MThd"));
     bw.Write(Reverse.Int32(6));
     bw.Write(Reverse.Int16(Conversions.ToShort(1)));
     bw.Write(Reverse.Int16(Conversions.ToShort(0)));
     bw.Write(Reverse.Int16(Conversions.ToShort(48)));
 }
예제 #8
0
        public ActionResult Index()
        {
            Reverse mReverse = new Reverse {
                sInput = "", sOutput = ""
            };

            return(View(mReverse));
        }
예제 #9
0
 public bool Contains(T2 key)
 {
     if (key == null)
     {
         throw new ArgumentException("Null key query", "Null is not allowed.");
     }
     return(Reverse.ContainsKey(key));
 }
예제 #10
0
        public void FindManyMultiKey()
        {
            var data  = CreateData();
            var table = CreateTable(data);

            table.FindByFirstNameAndAge(("aaa", 89)).Select(x => x.Id).Should().BeEquivalentTo(new[] { 2, 4 });
            table.FindByFirstNameAndAge(("aaa", 89)).Reverse.Select(x => x.Id).Should().BeEquivalentTo(new[] { 4, 2 });
        }
예제 #11
0
        public async Task <IActionResult> Create(IFormFile file, Student student)

        {
            if (ModelState.IsValid)
            {
                if (file == null || file.Length == 0)
                {
                    return(Content("file not selected"));
                }

                string path_Root = _appEnvironment.WebRootPath;

                string path_to_Images = path_Root + "\\Uploads\\Images\\" + file.FileName;

                using (var stream = new FileStream(path_to_Images, FileMode.Create))

                {
                    await file.CopyToAsync(stream);

                    string revUrl = Reverse.reverse(path_to_Images);
                    int    count  = 0;
                    int    flag   = 0;

                    for (int i = 0; i < revUrl.Length; i++)
                    {
                        if (revUrl[i] == '\\')
                        {
                            count++;
                        }
                        if (count == 3)
                        {
                            flag = i;
                            break;
                        }
                    }

                    string sub         = revUrl.Substring(0, flag + 1);
                    string finalString = Reverse.reverse(sub);

                    string f = finalString.Replace("\\", "/");
                    student.ImageUrl = f;
                }


                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
            }

            ViewBag.Image = student.ImageUrl;
            return(View(student));
        }
예제 #12
0
        protected virtual void CATransfer_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CATransfer transfer = (CATransfer)e.Row;

            if (transfer == null)
            {
                return;
            }

            transfer.RGOLAmt = transfer.TranIn - transfer.TranOut;

            bool transferOnHold      = (transfer.Hold == true);
            bool transferNotReleased = (transfer.Released != true);
            bool transferReleased    = (transfer.Released == true);

            PXUIFieldAttribute.SetVisible <CATransfer.inGLBalance>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.outGLBalance>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.cashBalanceIn>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.cashBalanceOut>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.tranIDIn_CATran_batchNbr>(sender, transfer, transferReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.tranIDOut_CATran_batchNbr>(sender, transfer, transferReleased);

            PXUIFieldAttribute.SetEnabled(sender, transfer, false);

            sender.AllowDelete = transferNotReleased;
            sender.AllowUpdate = transferNotReleased;
            Expenses.Cache.SetAllEditPermissions(transferNotReleased);

            CashAccount cashaccountOut = (CashAccount)PXSelectorAttribute.Select <CATransfer.outAccountID>(sender, e.Row);
            CashAccount cashaccountIn  = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, e.Row);

            bool clearEnabledIn  = transferNotReleased && (cashaccountIn != null) && (cashaccountIn.Reconcile == true);
            bool clearEnabledOut = transferNotReleased && (cashaccountOut != null) && (cashaccountOut.Reconcile == true);

            PXUIFieldAttribute.SetEnabled <CATransfer.hold>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.transferNbr>(sender, transfer, true);
            PXUIFieldAttribute.SetEnabled <CATransfer.descr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.curyTranIn>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inAccountID>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inDate>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inExtRefNbr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.curyTranOut>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outAccountID>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outDate>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outExtRefNbr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearedOut>(sender, transfer, clearEnabledOut);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearDateOut>(sender, transfer, clearEnabledOut && transfer.ClearedOut == true);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearedIn>(sender, transfer, clearEnabledIn);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearDateIn>(sender, transfer, clearEnabledIn && transfer.ClearedIn == true);

            Release.SetEnabled(transferNotReleased && !transferOnHold);
            Reverse.SetEnabled(transferReleased);

            UIState.RaiseOrHideErrorByErrorLevelPriority <CATransfer.inDate>(sender, transfer, transfer.Released != true && transfer.OutDate > transfer.InDate, Messages.EarlyInDate, PXErrorLevel.Warning);

            SetAdjRefNbrVisibility();
        }
예제 #13
0
        public void Do_ExampleInput_Outpub(string input, string output, int start, int end)
        {
            var c   = input.ToCharArray();
            var rev = new Reverse(start, end);

            rev.Do(ref c);

            Assert.AreEqual(output, c);
        }
예제 #14
0
 public void ReverseIterTest()
 {
     Assert.AreEqual("olleH", Reverse.ReverseIter("Hello"));
     Assert.AreEqual("taH", Reverse.ReverseIter("Hat"));
     Assert.AreEqual("aH", Reverse.ReverseIter("Ha"));
     Assert.AreEqual("H", Reverse.ReverseIter("H"));
     Assert.AreEqual("", Reverse.ReverseIter(""));
     Assert.AreEqual(null, Reverse.ReverseIter(null));
 }
예제 #15
0
        public async Task <Reverse> Reverse(Object data, string privateKey, string accessToken, string environment)
        {
            string compactJson = SignatureUtil.GenerateCompactJson(data);
            string method      = "post";
            string nonceStr    = RandomString.GenerateRandomString(32);
            string requestUrl  = "";

            if (environment == "sandbox")
            {
                requestUrl = String.Concat(Url.SandBoxOpen, "/v3/payment/reverse");
            }
            else if (environment == "production")
            {
                requestUrl = String.Concat(Url.ProductionOpen, "/v3/payment/reverse");
            }
            string    signType        = "sha256";
            string    timestamp       = Convert.ToString((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
            Signature signature       = new Signature();
            string    signatureResult = "";

            signatureResult = signature.GenerateSignature(compactJson, method, nonceStr, privateKey, requestUrl, signType, timestamp, environment);
            signatureResult = "sha256 " + signatureResult;
            Reverse result = new Reverse();

            try
            {
                var content     = JsonConvert.SerializeObject(data);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(content);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                client.DefaultRequestHeaders.Add("X-Nonce-Str", nonceStr);
                client.DefaultRequestHeaders.Add("X-Signature", signatureResult);
                client.DefaultRequestHeaders.Add("X-Timestamp", timestamp);
                var response = await client.PostAsync(requestUrl, byteContent);

                var responseStr = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    var jsonAsString = await response.Content.ReadAsStringAsync();

                    result = JsonConvert.DeserializeObject <Reverse>(jsonAsString);
                }
                else
                {
                    result = JsonConvert.DeserializeObject <Reverse>(response.Content.ReadAsStringAsync().Result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error", ex.Message);
            }
            return(result);
        }
예제 #16
0
        public void ReverseWords_text_return_reverse()
        {
            string testText = "The greatest victory is that which requires no battle";
            string expected = "battle no requires which that is victory greatest The";

            Reverse reverse = new Reverse();
            string  check   = reverse.ReverseWords(testText);

            Assert.AreEqual(expected, check);
        }
예제 #17
0
        static void RevDelegate()
        {
            Reverse rev = ReverseString;

            Console.WriteLine(rev("a string"));

            Func <string, string> rev2 = ReverseString;

            Console.WriteLine(rev2("another string"));
        }
예제 #18
0
        public void ArrayInput_PositivePath_ArrayReversed()
        {
            var input          = "1,2,3,5";
            var inputArray     = input.Split(',');
            var expectedOutput = "5 3 2 1";

            var reverseInput = new Reverse();

            Assert.IsTrue(reverseInput.ArrayInput(inputArray) == expectedOutput);
        }
예제 #19
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Gravity" && m_Rigidbody.velocity.y < 0)
     {
         print("hit gravity");
         OnGround = false;
         m_Rigidbody.gravityScale = 1;
     }
     if (other.gameObject.tag == "Coin")
     {
         Coin coin = other.GetComponent <Coin>();
         coin.Collect();
         PlayerStats.getCoin();
     }
     if (other.gameObject.tag == "ring")
     {
         print("hit ring");
         GameObject.FindGameObjectWithTag("RingSfx").GetComponent <AudioSource>().Play();
         PlayerStats.Scored(500);
         Destroy(other.gameObject.GetComponent <BoxCollider2D>());
         other.gameObject.GetComponentInParent <Animator>().SetBool("hit", true);
     }
     if (other.gameObject.tag == "Character Holder")
     {
         print("hit Character Holder");
         onMovingPlatform = true;
     }
     if (other.gameObject.tag == "Portal")
     {
         string       ident = other.gameObject.GetComponentInChildren <portal> ().identity;
         GameObject[] exits = GameObject.FindGameObjectsWithTag("Portal Exit");
         GameObject   exit  = GameObject.FindGameObjectWithTag("Portal Exit");
         foreach (GameObject i in exits)
         {
             if (i.GetComponentInChildren <portal> ().identity == ident)
             {
                 exit = i;
             }
         }
         exit.GetComponent <PortalExit> ().a      = true;
         exit.GetComponent <PortalExit> ().target = this.transform;
         exit.GetComponent <PortalExit> ().player = this.gameObject;
         GameMaster.portalmove(other.gameObject, exit);
         this.gameObject.SetActive(false);
     }
     if (other.gameObject.tag == "Reverse")
     {
         if (!other.gameObject.GetComponent <Reverse>().used)
         {
             Reverse r = other.gameObject.GetComponent <Reverse>();
             other.gameObject.GetComponent <SpriteRenderer>().sprite = r.pressed;
             GameMaster.reverse(r.rewind);
         }
     }
 }
예제 #20
0
        protected override void ProcessRecord()
        {
            RenumberIds renumberIds = new RenumberIds();

            renumberIds.OnWriteVerbose += RenumberIds_OnWriteVerbose;
            foreach (DictionaryEntry obj in RenumberList)
            {
                renumberIds.AddToRenumberList((int)obj.Key, (int)obj.Value, 1);
            }
            renumberIds.PerformRenumber(SourceFolder, DestinationFolder, Reverse.ToBool(), DontRename.ToBool());
        }
        public void Reverse(int input, bool expectedResult)
        {
            // Arrange
            var solution = new Reverse();

            //Assert
            var result = solution.IsPalindrome(input);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #22
0
    static void Main(string[] args)
    {
        Reverse    rev      = ReverseString;
        UpsideDown flip     = UpsideDownString;
        string     sentence = "hello there";

        Console.WriteLine(sentence);
        Console.WriteLine(rev(sentence));
        Console.WriteLine(flip(sentence));
        Console.WriteLine(flip(rev(sentence)));
    }
예제 #23
0
        public void can_Reverse_Array()
        {
            //Arrange
            int[] testArray = new[] { 1, 2, 3 };

            //Act
            int[] result = Reverse.ReverseArray(testArray);

            //Assert
            Assert.Equal(new[] { 3, 2, 1 }, result);
        }
예제 #24
0
        public void ReverseArray_reverses_an_empty_array()
        {
            // Arrange
            int[] arrayToReverse = new[] { 1, 2, 3 };

            // Act
            int[] result = Reverse.ReverseArray(arrayToReverse);

            //Assert
            Assert.Equal(new int[] { 3, 2, 1 }, result);
        }
예제 #25
0
        public void ReverseArray_reverses_an_empty_array()
        {
            // Arrange
            int[] array = new int[0];

            // Act
            int[] result = Reverse.ReverseArray(array);

            // Assert
            Assert.Empty(result);
        }
예제 #26
0
        public void ReverseByOne(int startingXCoordinate, int startingYCoordinate, char direction, string expected)
        {
            CompassDirection?compassDirection   = new DirectionFactory().Get(direction);
            IPosition        robotStartPosition = new Position(startingXCoordinate, startingYCoordinate, compassDirection);

            ICommand         robotCommand     = new Reverse();
            IRobotController robotController  = new RobotController(robotStartPosition, pluto);
            IPosition        robotEndPosition = robotController.Move(robotCommand);

            Assert.AreEqual(expected, robotEndPosition.ToString());
        }
예제 #27
0
 public static void StartMIDITrack(BinaryWriter bw, byte track)
 {
     bw.Write(Reverse.String32("MTrk"));
     bw.Write(Reverse.Int32(0));
     LayerData.WriteOffset = bw.BaseStream.Position;
     WriteMeta(bw, 0, 3);
     bw.Write(FirstByte(0));
     WriteControl.Program(bw, track, 0, Conversions.ToByte(0));
     WriteControl.Volume(bw, track, 0, Conversions.ToByte(127));
     WriteControl.Pan(bw, track, 0, Conversions.ToByte(0));
 }
예제 #28
0
        public void ReverseArray_reverse_a_nonempty_array()
        {
            // Arrange
            int[] arrayToReverse = new[] { 1, 2, 3 };

            // Act
            int[] result = Reverse.ReverseArray(arrayToReverse);

            // Assert
            int[] expected = new[] { 3, 2, 1 };
            Assert.Equal(expected, result);
        }
예제 #29
0
 public override void WriteToXml(XmlTextWriter xml)
 {
     xml.WriteStartElement("axis");
     xml.WriteAttributeString("type", SliderType.ToString());
     xml.WriteAttributeString("alias", InternalID);
     xml.WriteAttributeString("description", Description);
     xml.WriteAttributeString("min", Min.ToString());
     xml.WriteAttributeString("max", Max.ToString());
     xml.WriteAttributeString("axisName", AxisName);
     xml.WriteAttributeString("reverse", Reverse.ToString());
     xml.WriteEndElement();
 }
예제 #30
0
        private static void SimpleDelegateDemo()
        {
            string line = "This is a string";

            Console.WriteLine("Simple Delegate Demo.");
            Reverse rev = ReverseString;

            Console.WriteLine(line);
            Console.WriteLine("Reversed =>");

            Console.WriteLine(rev(line));
        }
예제 #31
0
파일: Program.cs 프로젝트: ryu-s/Reverse
 static void Show(Reverse.Stone[,] board)
 {
     var height = board.GetLength(0);
     var width = board.Length / height;
     for (int i = 0; i < height; i++)
     {
         Console.Write('|');
         for (int j = 0; j < width; j++)
         {
             var stone = board[i, j];
             char c;
             if (stone == Reverse.Stone.Black)
                 c = '●';
             else if (stone == Reverse.Stone.White)
                 c = '○';
             else
                 c = ' ';
             Console.Write(c);
         }
         Console.WriteLine('|');
     }
 }
예제 #32
0
파일: Program.cs 프로젝트: ryu-s/Reverse
        static void Main(string[] args)
        {
            var reverse = new Reverse(4, 4);
            var current = Reverse.Stone.Black;
            do
            {
                Show(reverse.Board);
                Console.WriteLine($"current={current}");

                int x;
                do
                {
                    Console.WriteLine("x:");
                    var xStr = Console.ReadLine();
                    if (int.TryParse(xStr, out x))
                        break;
                } while (true);
                int y;
                do
                {
                    Console.WriteLine("y:");
                    var yStr = Console.ReadLine();
                    if (int.TryParse(yStr, out y))
                        break;
                } while (true);
                var putPos = new Reverse.Pos { X = x, Y = y };
                if (!Reverse.Canput(reverse.Board, putPos, current))
                {
                    Console.WriteLine("置けない!");
                    continue;
                }
                reverse.ReverseStone(putPos, current);
                if (Reverse.IsFinished(reverse.Board))
                    break;
                current = Reverse.ReverseStone(current);
            } while (true);
            return;
        }
예제 #33
0
        public void Init(int width, int height)
        {
            reverse = new Reverse(width, height);
            myBoard = new Button[height, width];

            var baseX = 0;
            var baseY = 100;

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    var button = new Button();
                    button.Width = 20;
                    button.Height = 20;
                    button.Location = new Point(baseX + button.Width * j, baseY + button.Height * i);
                    button.Click += Button_Click;
                    this.Controls.Add(button);
                    myBoard[i, j] = button;
                    dict.Add(button, new Reverse.Pos { X = j, Y = i });
                }
            }
            ApplyBoard();
        }