예제 #1
0
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new UriGenerator();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
예제 #2
0
 public void CreateWithNullContextThrows()
 {
     // Fixture setup
     var sut = new UriGenerator();
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => sut.Create(dummyRequest, null));
     // Teardown
 }
예제 #3
0
 public void CreateWithNullRequestReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new UriGenerator();
     // Exercise system
     var dummyContext = new DelegatingSpecimenContext();
     var result = sut.Create(null, dummyContext);
     // Verify outcome
     Assert.Equal(new NoSpecimen(), result);
     // Teardown
 }
예제 #4
0
 public void CreateWithNonUriRequestReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new UriGenerator();
     var dummyRequest = new object();
     // Exercise system
     var dummyContext = new DelegatingSpecimenContext();
     var result = sut.Create(dummyRequest, dummyContext);
     // Verify outcome
     var expectedResult = new NoSpecimen(dummyRequest);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
예제 #5
0
 public void CreateWhenUriSchemeReceivedFromContextIsNullReturnsCorrectResult()
 {
     // Fixture setup
     var request = typeof(Uri);
     object expectedValue = null;
     var context = new DelegatingSpecimenContext
     {
         OnResolve = r => typeof(UriScheme).Equals(r) ? expectedValue : new NoSpecimen(r)
     };
     var sut = new UriGenerator();
     // Exercise system and verify outcome
     var result = sut.Create(request, context);
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
예제 #6
0
        public void CreateWithUriRequestReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(Uri);
            object expectedUriScheme = new UriScheme("ftp");
            object expectedAuthority = Guid.NewGuid().ToString();
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r =>
                {
                    if (typeof(UriScheme).Equals(r))
                    {
                        return expectedUriScheme;
                    }

                    if (typeof(string).Equals(r))
                    {
                        return expectedAuthority;
                    }

                    return new NoSpecimen(r);
                }
            };
            var sut = new UriGenerator();
            // Exercise system
            var result = (Uri)sut.Create(request, context);
            // Verify outcome
            var expectedUri = new Uri(expectedUriScheme + "://" + expectedAuthority);
            Assert.Equal(expectedUri, result);
            // Teardown
        }
예제 #7
0
        public void CreateReturnsUriWithAuthorityReceivedFromContext()
        {
            // Fixture setup
            var request = typeof(Uri);
            object expectedAuthority = Guid.NewGuid().ToString();
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r =>
                {
                    if (typeof(UriScheme).Equals(r))
                    {
                        return new UriScheme();
                    }

                    if (typeof(string).Equals(r))
                    {
                        return expectedAuthority;
                    }

                    return new NoSpecimen(r);
                }
            };
            var sut = new UriGenerator();
            // Exercise system
            var result = (Uri)sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedAuthority, result.Authority);
            // Teardown
        }
예제 #8
0
        public void CreateWhenStringReceivedFromContextIsNullReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(Uri);
            object expectedValue = null;
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r =>
                {
                    if (typeof(UriScheme).Equals(r))
                    {
                        return new UriScheme();
                    }

                    if (typeof(string).Equals(r))
                    {
                        return expectedValue;
                    }

#pragma warning disable 618
                    return new NoSpecimen(r);
#pragma warning restore 618
                }
            };
            var sut = new UriGenerator();
            // Exercise system and verify outcome
            var result = sut.Create(request, context);
#pragma warning disable 618
            var expectedResult = new NoSpecimen(request);
#pragma warning restore 618
            Assert.Equal(expectedResult, result);
            // Teardown
        }
예제 #9
0
        public void CreateReturnsUriWithSchemeReceivedFromContext()
        {
            // Fixture setup
            var request = typeof(Uri);
            string expectedScheme = "https";
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r =>
                {
                    if (typeof(UriScheme).Equals(r))
                    {
                        return new UriScheme(expectedScheme);
                    }
                    
                    if (typeof(string).Equals(r))
                    {
                        return Guid.NewGuid().ToString();
                    }

#pragma warning disable 618
                    return new NoSpecimen(r);
#pragma warning restore 618
                }
            };
            var sut = new UriGenerator();
            // Exercise system
            var result = (Uri)sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedScheme, result.Scheme);
            // Teardown
        }