Beispiel #1
0
        public void Constructor2_ValuesAsErrorsArgument_ShouldSetErrorsProperty()
        {
            var errors = Expectations.GetCompositionErrors();

            foreach (var e in errors)
            {
                var result = new CompositionResult(e.ToArray());

                EnumerableAssert.AreEqual(e, result.Errors);
            }
        }
        public void Constructor4_ValuesAsErrorsArgument_ShouldSetErrorsProperty()
        {
            var errors = Expectations.GetCompositionErrors();

            foreach (var e in errors)
            {
                var result = new CompositionResult <string>(e);

                Assert.Equal(e, result.Errors);
            }
        }
        public void Constructor5_ValueAsErrorsArgument_ShouldSetErrorsProperty()
        {
            var expectations = Expectations.GetCompositionErrors();

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

                EqualityExtensions.CheckEquals(e, exception.Errors);
            }
        }
        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);
            }
        }
        public void ToResultOfT_ValueAsErrorsArgument_ShouldReturnResultWithErrorsPropertySet()
        {
            var expectations = Expectations.GetCompositionErrors();

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

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

                EqualityExtensions.CheckEquals(result.Errors, copy.Errors);
            }
        }
        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);
            }
        }
Beispiel #7
0
        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);

                EqualityExtensions.CheckEquals(mergedErrors, mergedResult.Errors);
                Assert.False(mergedResult.Succeeded);
            }
        }
Beispiel #8
0
        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);
            }
        }
Beispiel #9
0
        public void MergeResult_ResultWithEmptyErrorsAsResultArgument_ShouldReturnResultWithSameErrors()
        {
            var emptyResult = CreateCompositionResult(Enumerable.Empty <CompositionError>());

            var expectations = Expectations.GetCompositionErrors();

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

                var mergedResult = result.MergeResult(emptyResult);

                Assert.Equal(result, mergedResult);
            }
        }
Beispiel #10
0
        public void MergeResult_ResultWithNullErrorsAsResultArgument_ShouldReturnResultWithSameErrors()
        {
            var emptyResult = CreateCompositionResult((IEnumerable <CompositionError>)null);

            var expectations = Expectations.GetCompositionErrors();

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

                var mergedResult = result.MergeResult(emptyResult);

                CompositionAssert.AreEqual(result, mergedResult);
            }
        }
Beispiel #11
0
        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);

                EqualityExtensions.CheckEquals(mergedErrors, mergedResult.Errors);
                Assert.Equal(mergedResult.Succeeded, result1.Succeeded | result2.Succeeded);
            }
        }
        public void Errors_CanBeSerialized()
        {
            var expectations = Expectations.GetCompositionErrors();

            foreach (var e in expectations)
            {
                var exception = CreateCompositionException(e);

                var result = SerializationTestServices.RoundTrip(exception);

                EnumerableAssert.AreSequenceEqual(exception.Errors, result.Errors, (index, expected, actual) =>
                {
                    CompositionAssert.AreEqual(expected, actual);
                });
            }
        }
        public void Constructor5_ValuesAsErrorsArgument_ShouldSetSucceededPropertyToTrueIfThereAreErrors()
        {
            var errors = Expectations.GetCompositionErrors();

            foreach (var e in errors)
            {
                var result = new CompositionResult <string>("Value", e);

                if (e.Count() > 0)
                {
                    Assert.False(result.Succeeded);
                }
                else
                {
                    Assert.True(result.Succeeded);
                }
            }
        }