public void GetDebugInputs_GivenEnvironmentIsNull_ShouldReturnZeroDebugInputs() { //---------------Set up test pack------------------- var dsfWebPostActivity = new TestDsfWebPostActivity(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var debugInputs = dsfWebPostActivity.GetDebugInputs(null, 0); //---------------Test Result ----------------------- Assert.AreEqual(0, debugInputs.Count); }
public void GetDebugInputs_GivenMockEnvironment_ShouldAddDebugInputItems() { //---------------Set up test pack------------------- const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," + "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," + "\"Visibility\": \"greater than 7 mile(s):0\"," + "\"Temperature\": \"59 F (15 C)\"," + "\"DewPoint\": \"41 F (5 C)\"," + "\"RelativeHumidity\": \"51%\"," + "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," + "\"Status\": \"Success\"" + "}"; var environment = new ExecutionEnvironment(); environment.Assign("[[City]]", "PMB", 0); environment.Assign("[[CountryName]]", "South Africa", 0); environment.Assign("[[Post]]", "Some data", 0); var dsfWebPostActivity = new TestDsfWebPostActivity { Headers = new List <INameValue> { new NameValue("Header 1", "[[City]]") }, QueryString = "http://www.testing.com/[[CountryName]]", PostData = "This is post:[[Post]]" }; var serviceOutputs = new List <IServiceOutputMapping> { new ServiceOutputMapping("Location", "[[weather().Location]]", "weather"), new ServiceOutputMapping("Time", "[[weather().Time]]", "weather"), new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather"), new ServiceOutputMapping("Visibility", "[[Visibility]]", "") }; dsfWebPostActivity.Outputs = serviceOutputs; var serviceXml = XmlResource.Fetch("WebService"); var service = new WebService(serviceXml) { RequestResponse = response }; dsfWebPostActivity.OutputDescription = service.GetOutputDescription(); dsfWebPostActivity.ResponseFromWeb = response; var dataObjectMock = new Mock <IDSFDataObject>(); dataObjectMock.Setup(o => o.Environment).Returns(environment); dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object); dsfWebPostActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty); var cat = new Mock <IResourceCatalog>(); var src = new WebSource { Address = "www.example.com" }; cat.Setup(a => a.GetResource <WebSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(src); dsfWebPostActivity.ResourceCatalog = cat.Object; //---------------Assert Precondition---------------- Assert.IsNotNull(environment); Assert.IsNotNull(dsfWebPostActivity); //---------------Execute Test ---------------------- var debugInputs = dsfWebPostActivity.GetDebugInputs(environment, 0); //---------------Test Result ----------------------- Assert.IsNotNull(debugInputs); Assert.AreEqual(4, debugInputs.Count); }