示例#1
0
        public void should_correctly_read_file_signature()
        {
            var expectedOutput = "2DA V1.0";
            var plugin = new TwoDAPlugin(null);

            var getSignatureMethod = plugin.GetType().GetMethod("GetSignature", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = getSignatureMethod.Invoke(plugin, new[] { expectedOutput.AsBytes() });

            Assert.That(result, Is.EqualTo(expectedOutput));
        }
示例#2
0
        public void should_correctly_convert_default_value()
        {
            var expectedValue = "12345";
            var plugin = new TwoDAPlugin(null);

            var convertDefaultValueMethod = plugin.GetType().GetMethod("ConvertToDefaultValue", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = convertDefaultValueMethod.Invoke(plugin, new[] { " 12345 ".AsBytes() });

            Assert.That(result, Is.EqualTo(expectedValue));
        }
示例#3
0
        public void should_correctly_convert_columns()
        {
            var expectedList = new List<string> {"col1", "col2", "col3"};
            var plugin = new TwoDAPlugin(null);

            var convertToColumnMethod = plugin.GetType().GetMethod("ConvertToColumns", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = convertToColumnMethod.Invoke(plugin, new[] {"col1 col2 col3".AsBytes() });

            Assert.That(result, Is.EqualTo(expectedList));
        }
示例#4
0
        public TwoDAViewerForm(TwoDAPlugin twoDAPlugin)
        {
            InitializeComponent();

            m_FileDialog = new OpenFileDialog();
            m_TwoDAPlugin = twoDAPlugin;

            SetupEvents();
            SetupFileDialogs();
            SetupGrid();
        }
示例#5
0
        public void should_correctly_convert_rows()
        {
            var expectedName = "row1";
            var expectedData = new List<string> { "1", "2", "3" };
            var plugin = new TwoDAPlugin(null);

            var convertToRowMethod = plugin.GetType().GetMethod("ConvertToRow", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = convertToRowMethod.Invoke(plugin, new[] { "row1 1 2 3 ".AsBytes() });

            Assert.That(result, Is.TypeOf(typeof(TwoDARow)));

            var castResult = (result as TwoDARow);
            Assert.That(castResult.RowName, Is.EqualTo(expectedName));
            Assert.That(castResult.RowData, Is.EqualTo(expectedData));
        }
示例#6
0
        public void should_correctly_read_well_structured_encrypted_stream()
        {
            var dummyStream = CreateWellStructured2DAStream(true);
            var plugin = new TwoDAPlugin(m_DummyEncryption);

            var expected2DA = new TwoDAResource();
            expected2DA.DefaultValue = "10";
            expected2DA.Columns = new List<string> { "col1", "col2", "col3", "col4" };
            expected2DA.Rows.Add(new TwoDARow("row1", new List<string> { "1", "2", "3", "4" }));
            expected2DA.Rows.Add(new TwoDARow("row2", new List<string> { "2", "4", "6", "8" }));
            expected2DA.Rows.Add(new TwoDARow("row3", new List<string> { "3", "6", "9", "12" }));

            var result = plugin.Import(dummyStream);

            Assert.That(result, Is.EqualTo(expected2DA));
        }