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); }
public void Create_PropertyTypeMissmatch_Exception() { var subject = new ListBuilder(); PropertyInfo missmatch = this.Property(nameof(TypeMismatch)); Assert.That(() => subject.Create(missmatch, null), Throws.InstanceOf <FormatException>()); }
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>()); }
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); }
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>()); }
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)); }
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)); }
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)); }
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>()); }
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>()); }
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); }
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)); }
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); }
public void ToList_returns() { var sut = ListBuilder <string> .Create(new [] { "meow", "bah" }); Assert.Contains("meow", sut.ToList()); }
public void Create_with_empty_parameter_internal_List_is_empty() { var sut = ListBuilder <string> .Create(); Assert.Empty(sut); }