コード例 #1
0
        public void Constructor5_ValueAsErrorsArgument_ShouldSetErrorsProperty()
        {
            var expectations = Expectations.GetCompositionErrors();

            foreach (var e in expectations)
            {
                var exception = new CompositionException("Message", new Exception(), e);

                EnumerableAssert.AreSequenceSame(e, exception.Errors);
            }
        }
コード例 #2
0
        public void ToResultOfT_ValueAsErrorsArgument_ShouldReturnResultWithErrorsPropertySet()
        {
            var expectations = Expectations.GetCompositionErrors();

            foreach (var e in expectations)
            {
                var result = CreateCompositionResult <string>(e);

                var copy = result.ToResult <string>();

                EnumerableAssert.AreSequenceSame(result.Errors, copy.Errors);
            }
        }
コード例 #3
0
ファイル: CompositionResultTest.cs プロジェクト: zqb971/mef
        public void MergeErrors_ValueAsErrorArgumentWhenMergedWithResultWithErrors_ShouldReturnResultWithCombinedErrors()
        {
            var result       = CreateCompositionResult(2);
            var expectations = Expectations.GetCompositionErrors();

            foreach (var e in expectations)
            {
                var mergedResult = result.MergeErrors(e);
                var mergedErrors = result.Errors.Concat(e);

                EnumerableAssert.AreSequenceSame(mergedErrors, mergedResult.Errors);
                Assert.IsFalse(mergedResult.Succeeded);
            }
        }
コード例 #4
0
ファイル: CompositionResultTest.cs プロジェクト: zqb971/mef
        public void MergeError_ValueAsErrorArgumentWhenMergedWithResultWithEmptyErrors_ShouldReturnResultWithCombinedErrors()
        {
            var result       = CreateCompositionResult(Enumerable.Empty <CompositionError>());
            var expectations = Expectations.GetEnumValues <CompositionErrorId>();

            foreach (var e in expectations)
            {
                var error = ErrorFactory.Create(e);

                var mergedResult = result.MergeError(error);
                var mergedErrors = result.Errors.Concat(new CompositionError[] { error });

                EnumerableAssert.AreSequenceSame(mergedErrors, mergedResult.Errors);
                Assert.IsFalse(mergedResult.Succeeded);
            }
        }
コード例 #5
0
ファイル: CompositionResultTest.cs プロジェクト: zqb971/mef
        public void MergeResult_ResultWithErrorsAsResultArgument_ShouldReturnResultWithCombinedErrors()
        {
            var expectations = Expectations.GetCompositionErrors();

            foreach (var e in expectations)
            {
                var result1 = CreateCompositionResult(e);
                var result2 = CreateCompositionResult(e);

                var mergedResult = result1.MergeResult(result2);
                var mergedErrors = result1.Errors.Concat(result2.Errors);

                EnumerableAssert.AreSequenceSame(mergedErrors, mergedResult.Errors);
                Assert.AreEqual(mergedResult.Succeeded, result1.Succeeded | result2.Succeeded);
            }
        }