コード例 #1
0
ファイル: DebugViewModel.cs プロジェクト: fut33v/LogControl9K
        void HowMuchEntriesAction()
        {
            uint z;

            Log9KUtil.GetEntriesNumberInFile(Log9KCore.Instance.TabAll.FilenameTempFile, Log9KEntry.ENTRY_SIZE, out z);
            HowMuchEntries = z;
        }
コード例 #2
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
 public void SumByteArrays_Three_Arrays_Result_Array_Not_Big_Enough()
 {
     // arrange
     byte[] first  = { 6, 6, 6 };
     byte[] second = { 1, 2 };
     byte[] third  = { 3, 0, 1, 5, 9 };
     byte[] actual = new byte[first.Length + second.Length + third.Length - 2];
     // act
     Log9KUtil.SumByteArrays(ref actual, first, second, third);
     // assert is handled by the ExpectedException
 }
コード例 #3
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
        public void SliceByteArray_Zero_Elements_Test()
        {
            // arrange
            byte[] actual   = { 1, 2, 3, 4, 5 };
            byte[] expected = {};
            int    size     = 0;

            // act
            Log9KUtil.SliceByteArray(ref actual, size);
            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #4
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
        public void TrimStringWithTrimToLessThan8_Test()
        {
            // arrange
            const string expected = "Abcdabc";

            // act
            const string inputString = "Abcdabcdasdf";
            string       actual      = Log9KUtil.TrimString(inputString, 7);

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
        public void TrimStringLessThanTrimTo_Test()
        {
            // arrange
            const string expected = "Abcdabcdasdf";

            // act
            const string inputString = "Abcdabcdasdf";
            string       actual      = Log9KUtil.TrimString(inputString, expected.Length + 5);

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
        public void StringSerialization_Test()
        {
            // arrange
            const string expected = "Allah Акбар";

            // act
            byte[] actualBytes = Log9KUtil.GetBytes(expected);
            string actual      = Log9KUtil.GetString(actualBytes);

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
 public void SumByteArrays_Three_Arrays()
 {
     // arrange
     byte[] first    = { 6, 6, 6 };
     byte[] second   = { 1, 2 };
     byte[] third    = { 3, 0, 1, 5, 9 };
     byte[] expected = { 6, 6, 6, 1, 2, 3, 0, 1, 5, 9 };
     byte[] actual   = new byte[first.Length + second.Length + third.Length];
     // act
     Log9KUtil.SumByteArrays(ref actual, first, second, third);
     // assert
     CollectionAssert.AreEqual(expected, actual);
 }
コード例 #8
0
ファイル: DebugViewModel.cs プロジェクト: fut33v/LogControl9K
        void ShowTempFileContentsAction()
        {
            Collection.Clear();
            string filename = Log9KCore.Instance.TabAll.FilenameTempFile;
            uint   start, end;

            uint.TryParse(Start, out start);
            uint.TryParse(End, out end);
            for (uint i = start; i < end; i++)
            {
                byte[] buffer;
                Log9KUtil.ReadFixedSizeByteArrayEntry(filename, Log9KEntry.ENTRY_SIZE, i, out buffer);
                Log9KEntry entry = Log9KEntry.FromByteArray(buffer);
                Collection.Add(new Tuple <uint, Log9KEntry>(i, entry));
            }
        }
コード例 #9
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
        public void SplitStringWithNullEnding_Test()
        {
            // arrange
            string s        = "abcd";
            string expected = s;

            s += "\0";
            s += "\0";
            s += "\0";
            s += "\0";
            // act
            string actual = Log9KUtil.SplitStringWithNullEnding(s);

            // assert
            Assert.AreEqual(actual, expected);
        }
コード例 #10
0
        private void LoadNewerLogArrayAction()
        {
            Log9KUtil.ExecuteCommand(StartRemovingFromTopCommand);
            int  pageUpDownToLoad;
            bool success = int.TryParse(PageUpDownToLoad, out pageUpDownToLoad);

            if (!success)
            {
                pageUpDownToLoad = 10;
            }
            for (int i = 0; i < pageUpDownToLoad; i++)
            {
                CurrentTab.LoadNewerLogEntry();
            }
            SelectedEntry = CurrentTab.LogEntryCollection[CurrentTab.LogEntryCollection.Count - 1];
        }
コード例 #11
0
ファイル: Log9KUtilTests.cs プロジェクト: fut33v/LogControl9K
        public void ByteArraySerialization_Test()
        {
            // arrange
            string filename = "ByteArraySerialization_Test.test";

            byte[] expected = { 3, 5, 9 };
            int    arraySize = expected.Length, numberOfArrays = 5;

            // act
            for (int i = 0; i < numberOfArrays; i++)
            {
                Log9KUtil.AppendByteArrayToFile(filename, expected);
            }
            // assert
            for (uint i = 0; i < numberOfArrays; i++)
            {
                byte[] actual;
                Log9KUtil.ReadFixedSizeByteArrayEntry(filename, arraySize, i, out actual);
                CollectionAssert.AreEqual(expected, actual);
            }
        }
コード例 #12
0
//        private static int _meatspin = 0;
        private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs mouseWheelEventArgs)
        {
            int  top, bottom;
            bool success = GetViewPortIndexes(this, out top, out bottom);

            if (!success)
            {
                return;
            }

            if (top == 0 && mouseWheelEventArgs.Delta > 0)
            {
                Log9KUtil.ExecuteCommand(LoadOlderLogCommand);
                Log9KUtil.ExecuteCommand(StartRemovingFromBottomCommand);
                return;
            }
            if (bottom != Items.Count || mouseWheelEventArgs.Delta >= 0)
            {
                return;
            }
            Log9KUtil.ExecuteCommand(LoadNewerLogCommand);
            Log9KUtil.ExecuteCommand(StartRemovingFromTopCommand);
        }