public void CreateFiltersOmitSpecimenInstances() { // Fixture setup var request = typeof(IEnumerable <int>); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = new object[] { 1, new OmitSpecimen(), 3 }; var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen() }; var sut = new EnumerableRelay(); // Exercise system var actual = sut.Create(request, context); // Verify outcome var iter = Assert.IsAssignableFrom <IEnumerable <int> >(actual); Assert.True( enumerable.OfType <int>().SequenceEqual(iter), "Actual sequence is not equal to expected sequence."); // Teardown }
public void SutDoesNotEqualOtherSutWhenRequestDiffers() { // Arrange var sut = new MultipleRequest(new object()); var other = new MultipleRequest(new object()); // Act var result = sut.Equals(other); // Assert Assert.False(result, "Equals"); }
public void SutDoesNotEqualAnonymousObject() { // Fixture setup var sut = new MultipleRequest(new object()); object anonymousObject = new FileStyleUriParser(); // Exercise system var result = sut.Equals(anonymousObject); // Verify outcome Assert.False(result, "Equals"); // Teardown }
public void SutDoesNotEqualNullSut() { // Fixture setup var sut = new MultipleRequest(new object()); MultipleRequest other = null; // Exercise system var result = sut.Equals(other); // Verify outcome Assert.False(result, "Equals"); // Teardown }
public void SutDoesNotEqualAnonymousObject() { // Arrange var sut = new MultipleRequest(new object()); object anonymousObject = new ConcreteType(); // Act var result = sut.Equals(anonymousObject); // Assert Assert.False(result, "Equals"); }
public void SutDoesNotEqualNullSut() { // Arrange var sut = new MultipleRequest(new object()); MultipleRequest other = null; // Act var result = sut.Equals(other); // Assert Assert.False(result, "Equals"); }
public void SutEqualsOtherSutWhenRequestMatches() { // Arrange var request = new object(); var sut = new MultipleRequest(request); var other = new MultipleRequest(request); // Act var result = sut.Equals(other); // Assert Assert.True(result, "Equals"); }
public void SutDoesNotEqualAnonymousObject() { // Fixture setup var sut = new MultipleRequest(new object()); object anonymousObject = new ConcreteType(); // Exercise system var result = sut.Equals(anonymousObject); // Verify outcome Assert.False(result, "Equals"); // Teardown }
public void SutDoesNotEqualOtherObjectWhenRequestDiffers() { // Fixture setup var sut = new MultipleRequest(new object()); object other = new MultipleRequest(new object()); // Exercise system var result = sut.Equals(other); // Verify outcome Assert.False(result, "Equals"); // Teardown }
public void SutEqualsOtherSutWhenRequestMatches() { // Fixture setup var request = new object(); var sut = new MultipleRequest(request); var other = new MultipleRequest(request); // Exercise system var result = sut.Equals(other); // Verify outcome Assert.True(result, "Equals"); // Teardown }
public void CreateWithEnumerableRequestReturnsCorrectResult(Type request, Type itemType) { // Fixture setup var expectedRequest = new MultipleRequest(itemType); object contextResult = Enumerable.Empty<object>(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen(r) }; var sut = new EnumerableRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.NotNull(result); // Teardown }
public void AddManyFillsDictionary() { // Fixture setup var dictionary = new Dictionary<int, string>(); var expectedRequest = new MultipleRequest(typeof(KeyValuePair<int, string>)); var expectedResult = Enumerable.Range(1, 3).Select(i => new KeyValuePair<int, string>(i, i.ToString())); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)expectedResult : new NoSpecimen(r) }; // Exercise system DictionaryFiller.AddMany(dictionary, context); // Verify outcome Assert.True(expectedResult.SequenceEqual(dictionary)); // Teardown }
public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType) { // Fixture setup var expectedRequest = new MultipleRequest(itemType); object expectedResult = Array.CreateInstance(itemType, 0); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r) }; var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void DoesNotThrowWithDuplicateEntries() { // Arrange var dictionary = new Dictionary <int, string>(); var request = new MultipleRequest(typeof(KeyValuePair <int, string>)); var sequence = Enumerable.Repeat(0, 3).Select(i => new KeyValuePair <int, string>(i, i.ToString())); var context = new DelegatingSpecimenContext { OnResolve = r => request.Equals(r) ? (object)sequence : new NoSpecimen() }; var sut = new DictionaryFiller(); // Act & Assert Assert.Null(Record.Exception(() => sut.Execute(dictionary, context))); }
public void CreateWithEnumerableRequestReturnsCorrectResult(Type request, Type itemType) { // Arrange var expectedRequest = new MultipleRequest(itemType); object contextResult = Enumerable.Empty <object>(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen() }; var sut = new EnumerableRelay(); // Act var result = sut.Create(request, context); // Assert Assert.NotNull(result); }
public void CreateConvertsEnumerableToArray() { // Fixture setup var request = typeof(int[]); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) }; var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome var a = Assert.IsAssignableFrom<int[]>(result); Assert.True(enumerable.SequenceEqual(a)); // Teardown }
public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType) { // Arrange var expectedRequest = new MultipleRequest(itemType); object expectedResult = Array.CreateInstance(itemType, 0); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new ArrayRelay(); // Act var result = sut.Create(request, context); // Assert Assert.Equal(expectedResult, result); }
public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType) { // Fixture setup var expectedRequest = new MultipleRequest(itemType); object expectedResult = Array.CreateInstance(itemType, 0); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void AddManyFillsDictionary() { // Fixture setup var dictionary = new Dictionary <int, string>(); var expectedRequest = new MultipleRequest(typeof(KeyValuePair <int, string>)); var expectedResult = Enumerable.Range(1, 3).Select(i => new KeyValuePair <int, string>(i, i.ToString())); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)expectedResult : new NoSpecimen(r) }; // Exercise system DictionaryFiller.AddMany(dictionary, context); // Verify outcome Assert.True(expectedResult.SequenceEqual(dictionary)); // Teardown }
public void CreateWithEnumerableRequestReturnsCorrectResult(Type request, Type itemType) { // Fixture setup var expectedRequest = new MultipleRequest(itemType); object contextResult = Enumerable.Empty <object>(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen() }; var sut = new EnumerableRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.NotNull(result); // Teardown }
public void AddManyFillsDictionary() { // Arrange var dictionary = new Dictionary <int, string>(); var expectedRequest = new MultipleRequest(typeof(KeyValuePair <int, string>)); var expectedResult = Enumerable.Range(1, 3).Select(i => new KeyValuePair <int, string>(i, i.ToString())); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)expectedResult : new NoSpecimen() }; // Act DictionaryFiller.AddMany(dictionary, context); // Assert Assert.True(expectedResult.SequenceEqual(dictionary)); }
public void DoesNotThrowWithDuplicateEntries() { // Fixture setup var dictionary = new Dictionary <int, string>(); var request = new MultipleRequest(typeof(KeyValuePair <int, string>)); var sequence = Enumerable.Repeat(0, 3).Select(i => new KeyValuePair <int, string>(i, i.ToString())); var context = new DelegatingSpecimenContext { OnResolve = r => request.Equals(r) ? (object)sequence : new NoSpecimen(r) }; var sut = new DictionaryFiller(); // Exercise system & Verify outcome Assert.DoesNotThrow(() => sut.Execute(dictionary, context)); // Teardown }
public void CreateConvertsEnumerableToArray() { // Arrange var request = typeof(int[]); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen() }; var sut = new ArrayRelay(); // Act var result = sut.Create(request, context); // Assert var a = Assert.IsAssignableFrom <int[]>(result); Assert.True(enumerable.SequenceEqual(a)); }
public void CreateConvertsEnumerableToCorrectGenericType() { // Arrange var request = typeof(IEnumerable <int>); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3).Cast <object>(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen() }; var sut = new EnumerableRelay(); // Act var result = sut.Create(request, context); // Assert var e = Assert.IsAssignableFrom <IEnumerable <int> >(result); Assert.True(enumerable.Cast <int>().SequenceEqual(e)); }
public void CreateConvertsEnumerableToArray() { // Fixture setup var request = typeof(int[]); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3); #pragma warning disable 618 var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) }; #pragma warning restore 618 var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome var a = Assert.IsAssignableFrom <int[]>(result); Assert.True(enumerable.SequenceEqual(a)); // Teardown }
public void CreateConvertsEnumerableToCorrectGenericType() { // Fixture setup var request = typeof(IEnumerable<int>); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3).Cast<object>(); #pragma warning disable 618 var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) }; #pragma warning restore 618 var sut = new EnumerableRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome var e = Assert.IsAssignableFrom<IEnumerable<int>>(result); Assert.True(enumerable.Cast<int>().SequenceEqual(e)); // Teardown }
public void CreateFiltersOmitSpecimenInstances() { // Fixture setup var request = typeof(IEnumerable<int>); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = new object[] { 1, new OmitSpecimen(), 3 }; var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) }; var sut = new EnumerableRelay(); // Exercise system var actual = sut.Create(request, context); // Verify outcome var iter = Assert.IsAssignableFrom<IEnumerable<int>>(actual); Assert.True( enumerable.OfType<int>().SequenceEqual(iter), "Actual sequence is not equal to expected sequence."); // Teardown }
public void DoesNotThrowWithDuplicateEntries() { // Fixture setup var dictionary = new Dictionary<int, string>(); var request = new MultipleRequest(typeof(KeyValuePair<int, string>)); var sequence = Enumerable.Repeat(0, 3).Select(i => new KeyValuePair<int, string>(i, i.ToString())); var context = new DelegatingSpecimenContext { OnResolve = r => request.Equals(r) ? (object)sequence : new NoSpecimen(r) }; var sut = new DictionaryFiller(); // Exercise system & Verify outcome Assert.DoesNotThrow(() => sut.Execute(dictionary, context)); // Teardown }