public void SutIsSpecimenBuilder() { // Fixture setup // Exercise system var sut = new UriGenerator(); // Verify outcome Assert.IsAssignableFrom<ISpecimenBuilder>(sut); // Teardown }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }