Beispiel #1
0
        public void Create_with_item_parameters_internal_list_contains_items()
        {
            var sut = ListBuilder <string> .Create(new [] { "meow", "bah" });

            Assert.Contains("meow", sut);
            Assert.Contains("bah", sut);
        }
Beispiel #2
0
        public void Create_PropertyTypeMissmatch_Exception()
        {
            var          subject   = new ListBuilder();
            PropertyInfo missmatch = this.Property(nameof(TypeMismatch));

            Assert.That(() => subject.Create(missmatch, null), Throws.InstanceOf <FormatException>());
        }
Beispiel #3
0
        public void Create_Array_NoOp()
        {
            var          subject = new ListBuilder();
            PropertyInfo array   = this.Property(nameof(Array));
            object       noOp    = subject.Create(array, null);

            Assert.That(noOp, Is.InstanceOf <NoSpecimen>());
        }
Beispiel #4
0
        public void Create_NoValues_EmptyInstance()
        {
            var          subject  = new ListBuilder();
            PropertyInfo empty    = this.Property(nameof(Empty));
            object       instance = subject.Create(empty, null);

            Assert.That(instance, Is.InstanceOf(empty.PropertyType).And.Empty);
        }
Beispiel #5
0
        public void Create_NotAProperty_NoOp()
        {
            var    subject      = new ListBuilder();
            object notAProperty = typeof(int);
            var    noOp         = subject.Create(notAProperty, null);

            Assert.That(noOp, Is.InstanceOf <NoSpecimen>());
        }
Beispiel #6
0
        public void Create_CompatibleMultiConversion_Instance()
        {
            var          subject    = new ListBuilder();
            PropertyInfo compatible = this.Property(nameof(CompatibleMultiConversion));
            object       instance   = subject.Create(compatible, null);

            Assert.That(instance, Is.InstanceOf(compatible.PropertyType));
        }
Beispiel #7
0
        public void Create_MultipleItems_Instance()
        {
            var          subject       = new ListBuilder();
            PropertyInfo multipleItems = this.Property(nameof(MultipleItems));
            object       instance      = subject.Create(multipleItems, null);

            Assert.That(instance, Is.InstanceOf(multipleItems.PropertyType).And.Count.GreaterThan(1));
        }
Beispiel #8
0
        public void Create_SingleItem_Instance()
        {
            var          subject    = new ListBuilder();
            PropertyInfo singleItem = this.Property(nameof(SingleItem));
            object       instance   = subject.Create(singleItem, null);

            Assert.That(instance, Is.InstanceOf(singleItem.PropertyType).And.Count.EqualTo(1));
        }
Beispiel #9
0
        public void Create_PropertyOfUnsupportedType_NoOp()
        {
            var          subject       = new ListBuilder();
            PropertyInfo unhandledType = this.Property(nameof(Unhandled));

            var noOp = subject.Create(unhandledType, null);

            Assert.That(noOp, Is.InstanceOf <NoSpecimen>());
        }
Beispiel #10
0
        public void Create_PropertyNotDecorated_NoOp()
        {
            var subject = new ListBuilder();

            PropertyInfo notDecorated = this.Property(nameof(NotDecorated));
            var          noOp         = subject.Create(notDecorated, null);

            Assert.That(noOp, Is.InstanceOf <NoSpecimen>());
        }
Beispiel #11
0
        public void Contains_calls_internal_List_Contains()
        {
            _listMock = SetupMockList();
            _listMock.Setup(a => a.Contains(It.IsAny <string>())).Verifiable();
            var sut = ListBuilder <string> .Create(_listMock.Object);

            sut.Contains("Strut");
            _listMock.Verify(a => a.Contains(It.IsAny <string>()), Times.Once);
        }
Beispiel #12
0
        public void AddRange_calls_internal_List_Add()
        {
            _listMock = SetupMockList();
            _listMock.Setup(a => a.Add(It.IsAny <string>())).Verifiable();
            var sut = ListBuilder <string> .Create(_listMock.Object);

            sut.AddRange(new [] { "Strut", "Meow", "Woof" });
            _listMock.Verify(a => a.Add(It.IsAny <string>()), Times.Exactly(3));
        }
Beispiel #13
0
        public void Indexer_returns()
        {
            _listMock = SetupMockList();
            _listMock.Setup(a => a[It.IsAny <int>()]).Verifiable();
            var sut = ListBuilder <string> .Create(_listMock.Object);

            var result = sut[1];

            _listMock.Verify(a => a[It.IsAny <int>()], Times.Once);
        }
Beispiel #14
0
        public void ToList_returns()
        {
            var sut = ListBuilder <string> .Create(new [] { "meow", "bah" });

            Assert.Contains("meow", sut.ToList());
        }
Beispiel #15
0
        public void Create_with_empty_parameter_internal_List_is_empty()
        {
            var sut = ListBuilder <string> .Create();

            Assert.Empty(sut);
        }