Пример #1
0
            public void Append_IsLazy()
            {
                var fixture = new BaseFixture();
                var breakingSequence = fixture.Create<BreakingSequence<object>>();
                var objectValue = fixture.Create<object>();

                Assert.That(() => breakingSequence.Append(objectValue), Throws.Nothing);
            }
Пример #2
0
            public void DistinctBy_IsLazy()
            {
                var fixture = new BaseFixture();
                var breakingSequence = fixture.Create<BreakingSequence<object>>();

                var objectFunc = fixture.Create<Func<object, object>>();

                Assert.That(() => breakingSequence.DistinctBy(objectFunc), Throws.Nothing);
            }
Пример #3
0
            public void Replace_OnEmptySequence_WithElement_WithProjection_ReturnsEmptySequence()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();
                var objectFunc = fixture.Create<Func<object, object>>();

                Assert.That(() => emptySequence.Replace(objectValue, objectFunc), Is.Empty);
            }
Пример #4
0
            public void ToEnumerable_OnObject_CreatesEnumerable()
            {
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();

                Assert.That(() => objectValue.ToEnumerable(), Is.InstanceOf<IEnumerable<object>>());
            }
Пример #5
0
            public void NullableMin_OnNullSequence_WithSelector_ThrowsValidationException()
            {
                IEnumerable<GenericComparableStruct> nullSequence = null;
                var fixture = new BaseFixture();
                var selector = fixture.Create<Func<GenericComparableStruct, GenericComparableStruct>>();

                Assert.That(() => nullSequence.NullableMin(selector), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
            }
            public void ContainsExactly_OnEmptySequence_OnZero_MeetsPredicate_ReturnsTrue()
            {
                var fixture = new BaseFixture();
                var emptySequence = Enumerable.Empty<object>();
                var predicate = fixture.Create<Func<object, bool>>();

                Assert.That(() => emptySequence.ContainsExactly(0, predicate), Is.True);
            }
Пример #7
0
            public void Shuffle_OnNullSequence_WithRandom_ThrowsValidationException()
            {
                IEnumerable<object> nullSequence = null;
                var fixture = new BaseFixture();
                var random = fixture.Create<Random>();

                Assert.That(() => nullSequence.Shuffle(random), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
            }
        public void ContainsOnlyOne_OnNullSequence_WithMeetsPredicate_ThrowsValidationException()
        {
            IEnumerable<object> nullSequence = null;
            var fixture = new BaseFixture();
            var predicate = fixture.Create<Func<object, bool>>();

            Assert.That(() => nullSequence.ContainsOnlyOne(predicate), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
        }
        public void ContainsOnlyOne_OnEmptySequence_MeetsPredicate_ReturnsFalse()
        {
            var fixture = new BaseFixture();
            var emptySequence = Enumerable.Empty<object>();
            var predicate = fixture.Create<Func<object, bool>>();

            Assert.That(() => emptySequence.ContainsOnlyOne(predicate), Is.False);
        }
Пример #10
0
            public void ContainsAny_OnCharacter_OnNullString_ThrowsValidationException()
            {
                string nullString = null;
                var fixture = new BaseFixture();
                var charValue = fixture.Create<char>();

                Assert.That(() => nullString.ContainsAny(charValue), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
            }
Пример #11
0
            public void Append_OnNullSequence_WithElelment_ThrowsValidationException()
            {
                IEnumerable<object> nullSequence = null;
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();

                Assert.That(() => nullSequence.Append(objectValue), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
            }
Пример #12
0
            public void Append_OnEmptySequence_WithElement_ReturnsSequenceWithElement()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();

                Assert.That(() => emptySequence.Append(objectValue), Is.EqualTo(objectValue.ToEnumerable()));
            }
Пример #13
0
            public void NullableMin_OnEmptySequence_WithSelector_ReturnsNull()
            {
                var emptySequence = Enumerable.Empty<GenericComparableStruct>();
                var fixture = new BaseFixture();
                var selector = fixture.Create<Func<GenericComparableStruct, GenericComparableStruct>>();

                Assert.That(() => emptySequence.NullableMin(selector), Is.Null);
            }
Пример #14
0
            public void Shuffle_OnEmptySequence_WithRandom_ReturnsEmptySequence()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var random = fixture.Create<Random>();

                Assert.That(() => emptySequence.Shuffle(random), Is.Empty);
            }
Пример #15
0
            public void ContainsAny_OnCharacter_OnEmptyString_ReturnsFalse()
            {
                var emptyString = string.Empty;
                var fixture = new BaseFixture();
                var charValue = fixture.Create<char>();

                Assert.That(() => emptyString.ContainsAny(charValue), Is.False);
            }
Пример #16
0
            public void Exclude_OnEmptySequence_WithPredicate_ReturnsEmptySequence()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var objectFunc = fixture.Create<Func<object, bool>>();

                Assert.That(() => emptySequence.Exclude(objectFunc), Is.Empty);
            }
Пример #17
0
            public void RandomElement_OnEmptySequence_ThrowsValidationException()
            {
                var fixture = new BaseFixture();
                var random = fixture.Create<Random>();
                var emptySequence = Enumerable.Empty<object>();

                Assert.That(() => emptySequence.RandomElement(random), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentException>());
            }
Пример #18
0
            public void Replace_OnEmptySequence_WithElement_WithNullProjection_ThrowsValidationException()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();
                Func<object, object> nullFunc = null;

                Assert.That(() => emptySequence.Replace(objectValue, nullFunc), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
            }
Пример #19
0
            public void Truncate_OnString_LengthIsGreaterThanElpises_ReturnsString()
            {
                var fixture = new BaseFixture();
                var charValue = fixture.Create<char>();
                var maxLength = ValidLength - 1;
                var shortString = new string(charValue, maxLength);

                Assert.That(() => shortString.Truncate(ValidLength + 1), Is.EqualTo(shortString));
            }
Пример #20
0
            public void ToString_OnEmptySequence_WithProjection_WithNullSeparator_ReturnsEmptyString()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var projection = fixture.Create<Func<object, string>>();
                string nullSeparator = null;

                Assert.That(() => emptySequence.ToString(projection, nullSeparator), Is.Empty);
            }
Пример #21
0
            public void Replace_OnEmptySequence_WithElement_WithNullReplacement_ReturnsEmptySequence()
            {
                var emptySequence = Enumerable.Empty<object>();
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();
                object nullObject = null;

                Assert.That(() => emptySequence.Replace(objectValue, nullObject), Is.Empty);
            }
Пример #22
0
            public void ToOrOther_ToObject_OnEmptyStringWithObject_OutStringAsObject()
            {
                var emptyStrying = string.Empty;
                var fixture = new BaseFixture();
                var objectValue = fixture.Create<object>();
                object outParameter;
                emptyStrying.ToOrOther(out outParameter, objectValue);

                Assert.That(() => outParameter, Is.EqualTo(emptyStrying));
            }
Пример #23
0
            public void AddLine_OnGoodStringBuilder_WithEmptyString_NoLineWriter_ReturnsStringBuilder()
            {
                var fixture = new BaseFixture();
                var stringBuilder = fixture.Create<StringBuilder>();
                var emptyString = string.Empty;

                var actual = stringBuilder.AddLine(emptyString);

                Assert.That(() => actual, Is.EqualTo(stringBuilder));
            }
Пример #24
0
            public void AddLine_OnGoodStringBuilder_WithEmptyString_WithLineWriter_CallsWriteLine()
            {
                var mockLineWriter = new Mock<ILineWriter>(MockBehavior.Strict);
                var emptyString = string.Empty;
                var fixture = new BaseFixture();
                var stringBuilder = fixture.Create<StringBuilder>();
                mockLineWriter.Setup(m => m.WriteLine());
                ILineWriter lineWriter = mockLineWriter.Object;
                stringBuilder.AddLine(emptyString, lineWriter);

                mockLineWriter.Verify(m => m.WriteLine(), Times.Once());
            }
            public void AverageOrDefault_OnEmptyIntSequence_WithNullableLongFunc_ReturnsDefaultLong()
            {
                var fixture = new BaseFixture();
                var emptyIntSequence = Enumerable.Empty<int>();
                var nullableLongFunc = fixture.Create<Func<int, long?>>();

                Assert.That(() => emptyIntSequence.AverageOrDefault(nullableLongFunc), Is.EqualTo(default(long)));
            }
Пример #26
0
            public void IsEmpty_OnNonGenericCollectionSingleItem_ReturnsFalse()
            {
                var fixture = new BaseFixture();
                var mock = new Mock<ICollection>();
                mock.Setup(m => m.Count).Returns(1);
                mock.Setup(m => m.GetEnumerator()).Returns(fixture.Create<object>().ToEnumerable().GetEnumerator);
                ICollection singleItemNonGenericCollection = mock.Object;

                Assert.That(() => singleItemNonGenericCollection.IsEmpty(), Is.False);
            }
            public void AverageOrDefault_OnEmptyIntSequence_WithFloatFunc_ReturnsDefaultFloat()
            {
                var fixture = new BaseFixture();
                var emptyIntSequence = Enumerable.Empty<int>();
                var floatFunc = fixture.Create<Func<int, float>>();

                Assert.That(() => emptyIntSequence.AverageOrDefault(floatFunc), Is.EqualTo(default(float)));
            }
Пример #28
0
            public void IsEmpty_OnNonGenericEnumerableSingleItem_ReturnsFalse()
            {
                var fixture = new BaseFixture();
                var mock = fixture.Create<Mock<IEnumerable>>();
                mock.Setup(m => m.GetEnumerator()).Returns(fixture.Create<object>().ToEnumerable().GetEnumerator);
                IEnumerable sequence = mock.Object;

                Assert.That(() => sequence.IsEmpty(), Is.False);
            }
            public void AverageOrDefault_OnEmptyIntSequence_WithDecimalFunc_ReturnsDefaultDecimal()
            {
                var fixture = new BaseFixture();
                var emptyIntSequence = Enumerable.Empty<int>();
                var decimalFunc = fixture.Create<Func<int, decimal>>();

                Assert.That(() => emptyIntSequence.AverageOrDefault(decimalFunc), Is.EqualTo(default(decimal)));
            }
            public void AverageOrDefault_OnNullIntSequence_WithIntFunc_ReturnsDefaultInt()
            {
                IEnumerable<int> nullIntSequence = null;
                var fixture = new BaseFixture();
                var intFunc = fixture.Create<Func<int, int>>();

                Assert.That(() => nullIntSequence.AverageOrDefault(intFunc), Is.EqualTo(default(int)));
            }