Esempio n. 1
0
        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");
        }
Esempio n. 8
0
        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
        }
Esempio n. 9
0
        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
        }
Esempio n. 10
0
        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
        }
Esempio n. 12
0
        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
        }
Esempio n. 13
0
        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
        }
Esempio n. 14
0
        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)));
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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
        }
Esempio n. 19
0
        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
        }
Esempio n. 20
0
        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
        }
Esempio n. 21
0
            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
        }
Esempio n. 23
0
        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));
        }
Esempio n. 24
0
        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));
        }
Esempio n. 25
0
        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
        }
Esempio n. 26
0
        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
        }
Esempio n. 27
0
 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 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
        }