示例#1
0
        public void SaveSession(string filename)
        {
            // Get root node from current selection
            var indexPath = TestResultController.SelectionIndexPath;

            if (indexPath == null)
            {
                return;
            }

            var index = indexPath.IndexAtPosition(0);

            var internalArray = (NSArray)TestResultController.Content;
            var rootNode      = internalArray.GetItem <TestListNode> (index);

            var model = rootNode as TestResultModel;

            if (model == null)
            {
                return;
            }

            var result  = model.Result;
            var element = TestSerializer.WriteTestResult(result);

            var settings = new XmlWriterSettings {
                Indent = true
            };

            using (var writer = XmlTextWriter.Create(filename, settings)) {
                element.WriteTo(writer);
            }
        }
示例#2
0
        public void UnaryExpressionShouldDeserialize(UnaryExpression unary)
        {
            var serialized   = TestSerializer.GetSerializedFragment <Unary, UnaryExpression>(unary);
            var deserialized = unarySerializer.Deserialize(serialized, new SerializationState());

            Assert.Equal(unary.Type.FullName, deserialized.Type.FullName);
        }
        public void LambdaExpressionShouldDeserialize(LambdaExpression lambda)
        {
            var serialized   = TestSerializer.GetSerializedFragment <Lambda, LambdaExpression>(lambda);
            var deserialized = lambdaSerializer.Deserialize(serialized, new SerializationState());

            Assert.Equal(lambda.Type.FullName, deserialized.Type.FullName);
        }
示例#4
0
 public ReflectionTestAssemblyBuilder(ReflectionTestSuiteBuilder suite, ReflectionTestAssembly assembly)
     : base(TestPathType.Assembly, null, assembly.Name,
            TestSerializer.GetStringParameter(assembly.Assembly.FullName))
 {
     SuiteBuilder = suite;
     Assembly     = assembly;
 }
示例#5
0
        public void LambdaExpressionShouldDeserialize(LambdaExpression lambda)
        {
            var serialized   = lambdaSerializer.Serialize(lambda, TestSerializer.GetDefaultState());
            var deserialized = lambdaSerializer.Deserialize(serialized, TestSerializer.State);

            Assert.Equal(lambda.Type.FullName, deserialized.Type.FullName);
        }
示例#6
0
        public async Task Bind_WithRetryErrorPolicyToHandleDeserializerErrors_RetriedAndReceivedInBatch()
        {
            var testSerializer = new TestSerializer {
                MustFailCount = 3
            };

            _connector.Bind(new TestEndpoint("test")
            {
                Serializer = testSerializer
            },
                            _errorPolicyBuilder.Retry().MaxFailedAttempts(3),
                            new InboundConnectorSettings
            {
                Batch = new BatchSettings
                {
                    Size = 2
                }
            });
            _broker.Connect();

            var consumer = _broker.Consumers.First();
            await consumer.TestPush(new TestEventOne { Content = "Test", Id = Guid.NewGuid() });

            await consumer.TestPush(new TestEventOne { Content = "Test", Id = Guid.NewGuid() });

            testSerializer.FailCount.Should().Be(3);
            _testSubscriber.ReceivedMessages.OfType <BatchCompleteEvent>().Count().Should().Be(4);
            _testSubscriber.ReceivedMessages.OfType <BatchAbortedEvent>().Count().Should().Be(3);
            _testSubscriber.ReceivedMessages.OfType <BatchProcessedEvent>().Count().Should().Be(1);
            _testSubscriber.ReceivedMessages.OfType <TestEventOne>().Count().Should().Be(2);
        }
示例#7
0
        public BaseDocumentBuilderTests()
        {
            var mock = new Mock <IResourceObjectBuilder>();

            mock.Setup(m => m.Build(It.IsAny <IIdentifiable>(), It.IsAny <IReadOnlyCollection <AttrAttribute> >(), It.IsAny <IReadOnlyCollection <RelationshipAttribute> >())).Returns(new ResourceObject());
            _builder = new TestSerializer(mock.Object);
        }
示例#8
0
 public override Task <TestCase> ResolveFromPath(XElement node, CancellationToken cancellationToken)
 {
     return(Task.Run <TestCase> (() => {
         var path = TestSerializer.DeserializePath(suite, RootContext, node);
         return new ReflectionTestCase(path);
     }));
 }
示例#9
0
        public static ResultPrinter Load(TextWriter writer, string filename)
        {
            var doc    = XDocument.Load(filename);
            var result = TestSerializer.ReadTestResult(doc.Root);

            return(new ResultPrinter(writer, result));
        }
示例#10
0
 public static T Read <T> (XElement node)
 {
     if (typeof(T) == typeof(string))
     {
         return((T)(object)TestSerializer.ReadString(node));
     }
     else if (typeof(T) == typeof(XElement))
     {
         return((T)(object)TestSerializer.ReadElement(node));
     }
     else if (typeof(T) == typeof(TestResult))
     {
         return((T)(object)TestSerializer.ReadTestResult(node));
     }
     else if (typeof(T) == typeof(TestLoggerBackend.LogEntry))
     {
         return((T)(object)TestSerializer.ReadLogEntry(node));
     }
     else if (typeof(T) == typeof(TestLoggerBackend.StatisticsEventArgs))
     {
         return((T)(object)TestSerializer.ReadStatisticsEvent(node));
     }
     else
     {
         throw new ServerErrorException();
     }
 }
示例#11
0
 public static XElement Write(object instance)
 {
     if (instance is string)
     {
         return(TestSerializer.WriteString((string)instance));
     }
     else if (instance is XElement)
     {
         return(TestSerializer.WriteElement((XElement)instance));
     }
     else if (instance is TestResult)
     {
         return(TestSerializer.WriteTestResult((TestResult)instance));
     }
     else if (instance is TestLoggerBackend.LogEntry)
     {
         return(TestSerializer.WriteLogEntry((TestLoggerBackend.LogEntry)instance));
     }
     else if (instance is TestLoggerBackend.StatisticsEventArgs)
     {
         return(TestSerializer.WriteStatisticsEvent((TestLoggerBackend.StatisticsEventArgs)instance));
     }
     else if (instance is ObjectProxy)
     {
         return(RemoteObjectManager.WriteProxy((ObjectProxy)instance));
     }
     else
     {
         throw new ServerErrorException();
     }
 }
示例#12
0
        void SaveResult()
        {
            WriteSummary("{0} tests, {1} passed, {2} errors, {3} ignored.", countTests, countSuccess, countErrors, countIgnored);
            WriteSummary("Total time: {0}.", endTime - startTime);

            if (ResultOutput != null)
            {
                var serialized = TestSerializer.WriteTestResult(result);
                var settings   = new XmlWriterSettings();
                settings.Indent = true;
                using (var writer = XmlTextWriter.Create(ResultOutput, settings))
                    serialized.WriteTo(writer);
                Debug("Result writting to {0}.", ResultOutput);
                AddFile(ResultOutput);
            }

            if (!string.IsNullOrWhiteSpace(stdout) && File.Exists(stdout))
            {
                AddFile(stdout);
            }
            if (!string.IsNullOrWhiteSpace(stderr) && File.Exists(stderr))
            {
                AddFile(stderr);
            }

            var printer = new ResultPrinter(global::System.Console.Out, result);

            printer.Print();
        }
示例#13
0
            public override ITestParameter ObjectToParameter(object value)
            {
                var stringValue   = (string)value;
                var friendlyValue = '"' + TestSerializer.Escape(stringValue) + '"';

                return(new ParameterWrapper(value, stringValue, friendlyValue));
            }
        public void ConstantExpressionShouldDeserialize(ConstantExpression constant)
        {
            var serialized   = TestSerializer.GetSerializedFragment <Constant, ConstantExpression>(constant);
            var deserialized = serializer.Deserialize(serialized, new SerializationState());

            Assert.True(ExpressionEquivalency.ValuesAreEquivalent(constant.Value, deserialized.Value));
        }
        public void BinaryExpressionShouldDeserialize(BinaryExpression binary)
        {
            var serialized   = binarySerializer.Serialize(binary, TestSerializer.GetDefaultState());
            var deserialized = binarySerializer.Deserialize(serialized, TestSerializer.State);

            Assert.Equal(binary.Type.FullName, deserialized.Type.FullName);
        }
        public void BinaryExpressionShouldDeserialize(BinaryExpression binary)
        {
            var serialized   = TestSerializer.GetSerializedFragment <Binary, BinaryExpression>(binary);
            var deserialized = binarySerializer.Deserialize(serialized, new SerializationState());

            Assert.Equal(binary.Type.FullName, deserialized.Type.FullName);
        }
示例#17
0
    static void test_serialization()
    {
        Log("test_serialization");
        const int MaxPacketSize = 1024;
        var       serializer    = new TestSerializer();
        var       buffer        = new uint[MaxPacketSize / 4];
        var       writeStream   = new WriteStream();

        writeStream.Start(buffer);
        TestStruct input;

        input.bool_value = true;
        input.int_value  = -5;
        input.uint_value = 215;
        input.bits_value = 12345;
        serializer.WriteTestStruct(writeStream, ref input);
        writeStream.Finish();

        var packet     = writeStream.GetData();
        var readStream = new ReadStream();

        readStream.Start(packet);
        TestStruct output;

        serializer.ReadTestStruct(readStream, out output);
        readStream.Finish();

        AreEqual(input.bool_value, output.bool_value);
        AreEqual(input.int_value, output.int_value);
        AreEqual(input.uint_value, output.uint_value);
        AreEqual(input.bits_value, output.bits_value);
    }
示例#18
0
        void SaveResult()
        {
            WriteSummary("{0} tests, {1} passed, {2} errors, {3} unstable, {4} ignored.",
                         countTests, countSuccess, countErrors, countUnstable, countIgnored);
            WriteSummary("Total time: {0}.", endTime - startTime);

            if (Options.ResultOutput != null)
            {
                var serialized = TestSerializer.WriteTestResult(result);
                var settings   = new XmlWriterSettings();
                settings.Indent = true;
                using (var writer = XmlTextWriter.Create(Options.ResultOutput, settings))
                    serialized.WriteTo(writer);
                Debug("Result written to {0}.", Options.ResultOutput);
            }

            if (Options.JUnitResultOutput != null)
            {
                JUnitResultPrinter.Print(result, Options.JUnitResultOutput);
                Debug("JUnit result written to {0}.", Options.JUnitResultOutput);
            }

            var printer = new ResultPrinter(global::System.Console.Out, result);

            printer.Print();
        }
示例#19
0
        public async Task <TestResult> Run(ReflectionTestSession session, CancellationToken cancellationToken)
        {
            var ctx = session.RootContext;

            TestSerializer.Debug("RUN: {0}", this);

            var result   = new TestResult(Name);
            var childCtx = ctx.CreateChild(Name, Node.Path, result);

            bool        ok;
            TestInvoker invoker;

            try {
                invoker = Node.CreateInvoker(ctx);
                ok      = await invoker.Invoke(childCtx, null, cancellationToken);
            } catch (Exception ex) {
                result.AddError(ex);
                ok = false;
            }

            if (!ok && result.Status == TestStatus.Success)
            {
                result.Status = TestStatus.Error;
            }

            TestSerializer.Debug("RUN DONE: {0} {1}", ok, result);

            return(result);
        }
示例#20
0
        public void ConstantExpressionShouldDeserialize(ConstantExpression constant)
        {
            var serialized   = serializer.Serialize(constant, TestSerializer.GetDefaultState());
            var deserialized = serializer.Deserialize(serialized, TestSerializer.State);

            Assert.True(evaluator.ValuesAreEquivalent(constant.Value, deserialized.Value));
        }
        public void InvocationExpressionShouldDeserialize(InvocationExpression invocation)
        {
            var serialized   = invocationSerializer.Serialize(invocation, TestSerializer.GetDefaultState());
            var deserialized = invocationSerializer.Deserialize(serialized, TestSerializer.State);

            Assert.Equal(invocation.Type.FullName, deserialized.Type.FullName);
        }
示例#22
0
 static SettingsBag LoadSettings(string file)
 {
     Program.Debug("Loading settings from {0}.", file);
     using (var reader = new StreamReader(file)) {
         var doc = XDocument.Load(reader);
         return(TestSerializer.ReadSettings(doc.Root));
     }
 }
示例#23
0
        public void MethodCallExpressionShouldDeserialize(MethodCallExpression method)
        {
            var serialized   = methodSerializer.Serialize(method, TestSerializer.GetDefaultState());
            var deserialized = methodSerializer.Deserialize(serialized, TestSerializer.State);

            Assert.Equal(method.Type.FullName, deserialized.Type.FullName);
            Assert.True(deserialized.IsEquivalentTo(deserialized));
        }
        public void GivenEnumerableQueryWhenQueryRootIsNullThenShouldReturnNullConstant()
        {
            EnumerableQuery <int> query = new EnumerableQuery <int>(Expression.Constant(new int[2]));
            var serialized   = TestSerializer.GetSerializedFragment <Constant, ConstantExpression>(Expression.Constant(query));
            var deserialized = serializer.Deserialize(serialized, new SerializationState());

            Assert.Null(deserialized.Value);
        }
示例#25
0
        public void GivenEnumerableQueryWhenQueryRootIsNullThenShouldReturnNullConstant()
        {
            EnumerableQuery <int> query = new EnumerableQuery <int>(Expression.Constant(new int[2]));
            var serialized   = serializer.Serialize(Expression.Constant(query), TestSerializer.GetDefaultState());
            var deserialized = serializer.Deserialize(serialized, TestSerializer.State);

            Assert.Null(deserialized.Value);
        }
        public ReflectionTestSuiteBuilder(ReflectionTestSuite suite)
            : base(TestSerializer.TestSuiteIdentifier, suite.Framework.Name,
                   TestSerializer.GetStringParameter(suite.Framework.Name))
        {
            Assemblies = suite.Assemblies;

            Resolve();
        }
示例#27
0
        public ReflectionTestSuiteBuilder(ReflectionTestSuite suite)
            : base(TestPathType.Suite, null, suite.Framework.Name,
                   TestSerializer.GetStringParameter(suite.Framework.Name))
        {
            Assemblies = suite.Assemblies;

            Resolve();
        }
示例#28
0
        public static async Task <ITestConfigurationProvider> GetRemoteTestConfiguration(
            TestSessionClient session, CancellationToken cancellationToken)
        {
            var command = new GetRemoteTestConfigurationCommand();
            var result  = await command.Send(session, null, cancellationToken);

            return(TestSerializer.ReadConfiguration(result));
        }
示例#29
0
        public void UpdateSettings(XElement settings)
        {
            var remoteSettings = TestSerializer.ReadSettings(settings);

            Connection.App.Settings.Merge(remoteSettings);
            Configuration.Reload();
            LocalSession.OnConfigurationChanged();
        }
示例#30
0
 public override Task <TestCase> ResolveFromPath(XElement node, CancellationToken cancellationToken)
 {
     System.Diagnostics.Debug.WriteLine("RESOLVE FROM PATH:\n{0}", node);
     return(Task.Run <TestCase> (() => {
         var path = TestSerializer.DeserializePath(suite, RootContext, node);
         return new ReflectionTestCase(path);
     }));
 }