コード例 #1
0
ファイル: MockRangeTest.cs プロジェクト: TzarIvan/ratel
        public void TestTwoDimensionRangeFromArray()
        {
            var range = new MockRange(new[] { "One", "two" }, 1, 1, true);

            var value = range.Value2;

            Assert.IsNotNull(value);
            Assert.IsTrue(typeof(object[, ]) == value.GetType());
            Assert.AreEqual(2, range.Count);
            Assert.AreEqual(1, range.Row);

            Assert.AreEqual(1, range.Column);

            Assert.AreEqual(1, range.Rows.Count);
            Assert.IsTrue(typeof(object[, ]) == range.Rows.Value2.GetType());
            Assert.AreEqual(2, range.Columns.Count);
            Assert.IsTrue(typeof(object[, ]) == range.Columns.Value2.GetType());
            Assert.AreEqual(2, range.Cells.Count);

            var getValue = range.get_Value(XlRangeValueDataType.xlRangeValueDefault);

            Assert.IsNotNull(getValue);
            Assert.IsTrue(typeof(object[, ]) == getValue.GetType());
            var asObjectArray = (object[, ])getValue;

            Assert.AreEqual(1, asObjectArray.GetLength(0));
            Assert.AreEqual(2, asObjectArray.GetLength(1));
            Assert.AreEqual(1, asObjectArray.GetLowerBound(0));
            Assert.AreEqual(1, asObjectArray.GetLowerBound(1));
        }
コード例 #2
0
        public void TestServerPublish()
        {
            _receivedMessage = null;

            var config = new AppConfiguration {
                MarketDataBrokerUrl = BrokerFactoryTest.Nyws802
            };
            var temp = AppConfiguration.AssemblyPath;

            var publisher = new ActiveMQPublisher(config);

            var testMessageConsumer = StartTestListener(BrokerFactory.Broker(config.MarketDataBrokerUrl), "Test.Topic.Publish");
            var publisherResult     = publisher.AMQPub("Test.Topic.Publish", "FieldName", "FieldValue");

            Assert.IsNotNull(publisherResult);
            Assert.IsTrue(publisherResult.ToString().StartsWith("Submitted"));

            WaitFor(HasMessageArrived, this, 10 * 1000);
            Assert.IsNotNull(_receivedMessage);
            Assert.AreEqual(true, _receivedMessage.Contains("FieldName"));
            _receivedMessage = null;

            var fieldNameRange  = new MockRange("FieldName", 1, 1);
            var fieldValueRange = new MockRange("FieldValueUpdate", 2, 1);

            publisherResult = publisher.AMQPub("Test.Topic.Publish", fieldNameRange, fieldValueRange);
            Assert.IsNotNull(publisherResult);
            Assert.IsTrue(publisherResult.ToString().StartsWith("Submitted"));

            WaitFor(HasMessageArrived, this, 10 * 1000);
            Assert.IsNotNull(_receivedMessage);
            Assert.AreEqual(true, _receivedMessage.Contains("FieldValueUpdate"));


            var fieldNameRange2 = new MockRange(new[] { "FieldName1", "FieldName2" }, 1, 1, true);

            var fieldValueRange2 = new MockRange(new[] { "FieldValueUpdate1", "FieldValueUpdate2" }, 1, 1, true);

            publisherResult = publisher.AMQPub("Test.Topic.Publish", fieldNameRange2, fieldValueRange2);
            Assert.IsNotNull(publisherResult);
            Assert.IsTrue(publisherResult.ToString().StartsWith("Submitted"));

            WaitFor(HasMessageArrived, this, 10 * 1000);
            Assert.IsNotNull(_receivedMessage);
            Assert.AreEqual(true, _receivedMessage.Contains("FieldValueUpdate"));


            StopTestListener(testMessageConsumer);
        }
コード例 #3
0
ファイル: MockRangeTest.cs プロジェクト: TzarIvan/ratel
        public void TestTwoDimensionRangeCreate()
        {
            var lengths     = new[] { 1, 2 };
            var lowerBounds = new[] { 1, 1 };

            // create the array in Excel format and convert to what we need
            var myArray = Array.CreateInstance(typeof(object), lengths, lowerBounds);
            var value2  = (object[, ])myArray;

            value2[1, 1] = "one";
            value2[1, 2] = "two";

            var range = new MockRange(value2, 1, 1);

            var value = range.Value2;

            Assert.IsNotNull(value);
            Assert.IsTrue(typeof(object[, ]) == value.GetType());
            Assert.AreEqual(2, range.Count);
            Assert.AreEqual(1, range.Row);

            Assert.AreEqual(1, range.Column);

            Assert.AreEqual(1, range.Rows.Count);
            Assert.IsTrue(typeof(object[, ]) == range.Rows.Value2.GetType());
            Assert.AreEqual(2, range.Columns.Count);
            Assert.IsTrue(typeof(object[, ]) == range.Columns.Value2.GetType());
            Assert.AreEqual(2, range.Cells.Count);

            var getValue = range.get_Value(XlRangeValueDataType.xlRangeValueDefault);

            Assert.IsNotNull(getValue);
            Assert.IsTrue(typeof(object[, ]) == getValue.GetType());
            var asObjectArray = (object[, ])getValue;

            Assert.AreEqual(1, asObjectArray.GetLength(0));
            Assert.AreEqual(2, asObjectArray.GetLength(1));
            Assert.AreEqual(1, asObjectArray.GetLowerBound(0));
            Assert.AreEqual(1, asObjectArray.GetLowerBound(1));
        }
コード例 #4
0
ファイル: MockRangeTest.cs プロジェクト: TzarIvan/ratel
        public void TestCellRange()
        {
            var range = new MockRange("simple_string", 1, 1);

            var value = range.Value2;

            Assert.IsNotNull(value);
            Assert.IsTrue(typeof(string) == value.GetType());
            Assert.AreEqual(1, range.Count);

            Assert.AreEqual(1, range.Row);
            Assert.AreEqual(1, range.Column);

            Assert.AreEqual(1, range.Rows.Count);
            Assert.IsTrue(typeof(string) == range.Rows.Value2.GetType());
            Assert.AreEqual(1, range.Columns.Count);
            Assert.IsTrue(typeof(string) == range.Columns.Value2.GetType());
            Assert.AreEqual(1, range.Cells.Count);

            var getValue = range.get_Value(XlRangeValueDataType.xlRangeValueDefault);

            Assert.IsNotNull(getValue);
            Assert.IsTrue(typeof(string) == getValue.GetType());
        }