コード例 #1
0
        public void CalculateChecksum_array_length_1()
        {
            //Arrange

            //Act

            var result = Checksum.CalculateChecksum(new byte[1]);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("uCRNAomB1pOve0Vq+O+kytY9KC4Z/xSULCRuUNk1HSJwSoAqccNYC2Nw3kzrKTwySoQjNCVX1OXDhDjw42kQ7g==", result.ToString());
        }
コード例 #2
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            Checksum chk;
            string   istr;
            int      slen;
            uint     csum;
            bool     useBase10;
            int      numberLength;

            chk = new Checksum();
            // check the length
            if (txtLength.Text.Length == 0)
            {
                MessageBox.Show("Enter a valid length", "Checksum");
                txtLength.Focus();
                return;
            }
            slen = Convert.ToInt32(txtLength.Text);

            // see what base we are to use
            if (rdobtn10.Checked)
            {
                useBase10 = true;
            }
            else
            {
                useBase10 = false;
            }

            //
            // See what type of checksum is requested.
            //
            if (rdoBtnChksum1.Checked)
            {
                chk.ChecksumAlgorithm = Checksum.ChecksumType.Type1;
            }
            if (rdoBtnChksum2.Checked)
            {
                chk.ChecksumAlgorithm = Checksum.ChecksumType.Type2;
            }

            istr         = txtInput.Text;
            numberLength = Convert.ToInt32(txtLength.Text);
            chk.CalculateChecksum(istr);
            csum           = chk.ChecksumNumber;
            txtchksum.Text = NumberDisplay.CreateNumberString(csum, numberLength, useBase10);
        }
コード例 #3
0
        public void CalculateChecksum_array_length_0()
        {
            //Arrange

            //Act
            try
            {
                Checksum.CalculateChecksum(new byte[0]);
            }
            catch (ArgumentException)
            {
                return;
            }

            //Assert
            Assert.Fail();
        }
コード例 #4
0
        public void CalculateChecksum_null()
        {
            //Arrange

            //Act
            try
            {
                Checksum.CalculateChecksum(null);
            }
            catch (ArgumentNullException)
            {
                return;
            }

            //Assert
            Assert.Fail();
        }
コード例 #5
0
        public void Should_get_the_checksum_of_all_differences()
        {
            int checksum = _checksum.CalculateChecksum(_checksumTestList);

            Assert.AreEqual(18, checksum);
        }