예제 #1
0
        public void DsfWebPutActivity_Execute_ErrorResponse_ShouldSetVariables()
        {
            //------------Setup for test--------------------------
            const string response = "{\"Message\":\"Error\"}";
            var dsfWebPutActivity = new DsfWebPutActivity();
            dsfWebPutActivity.ResourceID = InArgument<Guid>.FromValue(Guid.Empty);
            var mockResourceCatalog = new Mock<IResourceCatalog>();
            var webSource = new WebSource
            {
                Address = $"http://{Depends.TFSBLDIP}:9910/api/",
                AuthenticationType = AuthenticationType.Anonymous
            };
            mockResourceCatalog.Setup(resCat => resCat.GetResource<WebSource>(It.IsAny<Guid>(), It.IsAny<Guid>())).Returns(webSource);
            dsfWebPutActivity.ResourceCatalog = mockResourceCatalog.Object;
            var serviceOutputs = new List<IServiceOutputMapping> { new ServiceOutputMapping("Message", "[[Message]]", "") };
            dsfWebPutActivity.Outputs = serviceOutputs;
            var serviceXml = XmlResource.Fetch("WebService");
            var service = new WebService(serviceXml) { RequestResponse = response };
            dsfWebPutActivity.OutputDescription = service.GetOutputDescription();

            dsfWebPutActivity.QueryString = "Error";

            dsfWebPutActivity.SourceId = Guid.Empty;
            dsfWebPutActivity.Headers = new List<INameValue>();
            var dataObject = new DsfDataObject("", Guid.NewGuid());
            dataObject.EsbChannel = new MockEsb();
            //------------Execute Test---------------------------
            dsfWebPutActivity.Execute(dataObject, 0);
            //------------Assert Results-------------------------
            Assert.AreEqual("Error", ExecutionEnvironment.WarewolfEvalResultToString(dataObject.Environment.Eval("[[Message]]", 0)));
        }
        public void DataGridActivityFindMissingStrategy_GetActivityFields_WebPutActivity_ShouldReturnResults_IsObject()
        {
            //------------Setup for test--------------------------
            var fac      = new Dev2FindMissingStrategyFactory();
            var strategy = fac.CreateFindMissingStrategy(enFindMissingType.DataGridActivity);
            var activity = new DsfWebPutActivity
            {
                Inputs = new List <IServiceInput> {
                    new ServiceInput("Input1", "[[InputValue1]]"), new ServiceInput("Input2", "[[InputValue2]]"), new ServiceInput("Input3", "[[InputValue3]]")
                },
                Outputs = new List <IServiceOutputMapping> {
                    new ServiceOutputMapping("Output1", "OutputValue1", "rec"), new ServiceOutputMapping("Output2", "OutputValue2", "rec")
                },
                QueryString = "[[qstring]]",
                Headers     = new List <INameValue> {
                    new NameValue("Content-Type", "[[ctype]]")
                },
                OnErrorVariable = "[[err]]",
                OnErrorWorkflow = "[[errSvc]]",
                PutData         = "[[putdata]]",
                IsObject        = true,
                ObjectName      = "TheObject"
            };
            //------------Execute Test---------------------------
            var fields = strategy.GetActivityFields(activity);

            //------------Assert Results-------------------------
            Assert.IsTrue(fields.Contains("TheObject"));
        }
예제 #3
0
        public void Equals_Given_Same_Headers_DifferentIndexes_IsNotEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var headers  = new List <INameValue> {
                new NameValue("b", "y"), new NameValue("a", "x")
            };
            var headers2 = new List <INameValue> {
                new NameValue("a", "x"), new NameValue("b", "y")
            };
            var webPut = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, Headers = headers
            };
            var webPut1 = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, Headers = headers
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webPut);
            //---------------Execute Test ----------------------
            var @equals = webPut.Equals(webPut1);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
예제 #4
0
        public void WebPutInputRegion_Headers_AddEmptyHeaders()
        {
            //------------Setup for test--------------------------
            var id             = Guid.NewGuid();
            var webPutActivity = new DsfWebPutActivity
            {
                SourceId = id,
                Headers  = new ObservableCollection <INameValue> {
                    new NameValue("a", "b")
                },
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());

            var modelItem = ModelItemUtils.CreateModelItem(webPutActivity);

            var webSourceRegion = new WebSourceRegion(mod.Object, modelItem);
            var region          = new WebPutInputRegion(modelItem, webSourceRegion);

            //------------Execute Test---------------------------

            //------------Assert Results-------------------------

            Assert.AreEqual(2, region.Headers.Count);
            Assert.AreEqual("a", region.Headers[0].Name);
            Assert.AreEqual("b", region.Headers[0].Value);
            Assert.AreEqual("", region.Headers[1].Name);
            Assert.AreEqual("", region.Headers[1].Value);
        }
예제 #5
0
        public void Equals_Given_Different_OutputDescription_IsNOTEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var outDescr = new OutputDescription()
            {
                Format = OutputFormats.Unknown
            };
            var outDescr2 = new OutputDescription()
            {
                Format = OutputFormats.ShapedXML
            };
            var webPut = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, OutputDescription = outDescr
            };
            var webPut1 = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, OutputDescription = outDescr2
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webPut);
            //---------------Execute Test ----------------------
            var @equals = webPut.Equals(webPut1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
예제 #6
0
        public void WebInputRegion_SrcChanged_UpdateValues()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfWebPutActivity()
            {
                SourceId = id
            };
            var src = new Mock <IWebServiceSource>();

            var mod = new Mock <IWebServiceModel>();
            var lst = new List <IWebServiceSource> {
                new WebServiceSourceDefinition()
                {
                    HostName = "bob", DefaultQuery = "Dave"
                }, new WebServiceSourceDefinition()
                {
                    HostName = "f", DefaultQuery = "g"
                }
            };

            mod.Setup(a => a.RetrieveSources()).Returns(lst);
            var srcreg          = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPutActivity()));
            var region          = new WebPutInputRegion(ModelItemUtils.CreateModelItem(act), srcreg);
            var regionToRestore = new WebPutInputRegion(ModelItemUtils.CreateModelItem(act), srcreg);

            srcreg.SelectedSource = lst[0];
            Assert.AreEqual(region.QueryString, "Dave");
            Assert.AreEqual(region.RequestUrl, "bob");
        }
예제 #7
0
        public void TestClone()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebPutActivity
            {
                SourceId = id
            };
            var src = new Mock <IWebServiceSource>();

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var srcreg = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPutActivity()));
            var region = new WebPutInputRegion(ModelItemUtils.CreateModelItem(act), srcreg);

            region.PutData = "bob";
            Assert.AreEqual(region.IsEnabled, false);
            Assert.AreEqual(region.Errors.Count, 0);
            if (region.CloneRegion() is WebPutInputRegion clone)
            {
                Assert.AreEqual(clone.IsEnabled, false);
                Assert.AreEqual(clone.Errors.Count, 0);
                Assert.AreEqual(clone.PutData, "bob");
            }
        }
예제 #8
0
 public void DsfWebPutActivity_Constructed_Correctly_ShouldHaveInheritDsfActivity()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     var DsfWebPutActivity = new DsfWebPutActivity();
     //------------Assert Results-------------------------
     Assert.IsInstanceOfType(DsfWebPutActivity, typeof(DsfActivity));
 }
예제 #9
0
 public void DsfWebPutActivity_Constructor_Correctly_ShouldSetTypeDisplayName()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     var DsfWebPutActivity = new DsfWebPutActivity();
     //------------Assert Results-------------------------
     Assert.AreEqual("PUT Web Method", DsfWebPutActivity.DisplayName);
 }
예제 #10
0
        DsfWebPutActivity CreatePutActivity()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebPutActivity()
            {
                SourceId = id
            };

            return(act);
        }
예제 #11
0
        public void Equals_Given_SameWebPutTool_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId        = Guid.NewGuid().ToString();
            var webputActivity  = new DsfWebPutActivity();
            var webputActivity1 = webputActivity;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webputActivity);
            //---------------Execute Test ----------------------
            var @equals = webputActivity.Equals(webputActivity1);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
예제 #12
0
        public void WebPutInputRegion_TestInputCtor()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebPutActivity {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var webSourceRegion = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPutActivity()));
            var region          = new WebPutInputRegion(ModelItemUtils.CreateModelItem(act), webSourceRegion);

            Assert.AreEqual(false, region.IsEnabled);
            Assert.AreEqual(0, region.Errors.Count);
        }
예제 #13
0
        public void GivenIDragWebPutRequestConnectorToolOntoTheDesignSurface()
        {
            var activity  = new DsfWebPutActivity();
            var modelItem = ModelItemUtils.CreateModelItem(activity);
            var mockServiceInputViewModel = new Mock <IManageWebServiceInputViewModel>();
            var mockServiceModel          = new Mock <IWebServiceModel>();
            var mockEnvironmentRepo       = new Mock <IServerRepository>();
            var mockEnvironmentModel      = new Mock <IServer>();

            mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel.Setup(model => model.IsLocalHost).Returns(true);
            mockEnvironmentModel.Setup(model => model.EnvironmentID).Returns(Guid.Empty);
            mockEnvironmentModel.Setup(model => model.IsLocalHostCheck()).Returns(false);
            mockEnvironmentRepo.Setup(repository => repository.ActiveServer).Returns(mockEnvironmentModel.Object);
            mockEnvironmentRepo.Setup(repository => repository.FindSingle(It.IsAny <Expression <Func <IServer, bool> > >())).Returns(mockEnvironmentModel.Object);

            _webHelooWebSource = new WebServiceSourceDefinition
            {
                Name = "WebHeloo"
            };

            _dev2CountriesWebServiceWebSource = new WebServiceSourceDefinition
            {
                Name     = "Dev2CountriesWebService",
                HostName = "http://TFSBLD.premier.local/integrationTestSite/GetCountries.ashx"
            };

            _googleWebSource = new WebServiceSourceDefinition
            {
                Name = "Google Address Lookup",
            };
            var sources = new ObservableCollection <IWebServiceSource> {
                _dev2CountriesWebServiceWebSource
            };

            mockServiceModel.Setup(model => model.RetrieveSources()).Returns(sources);
            mockServiceModel.Setup(model => model.EditSource(It.IsAny <IWebServiceSource>())).Verifiable();
            mockServiceInputViewModel.SetupAllProperties();
            var viewModel = new WebServicePutViewModel(modelItem, mockServiceModel.Object);


            scenarioContext.Add("viewModel", viewModel);
            scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            scenarioContext.Add("mockServiceModel", mockServiceModel);
        }
예제 #14
0
        public void Equals_Given_Different_QueryString_IsNOTEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var webPut   = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, QueryString = "A"
            };
            var webPut1 = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, QueryString = "B"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webPut);
            //---------------Execute Test ----------------------
            var @equals = webPut.Equals(webPut1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
예제 #15
0
        public void Equals_Given_Same_DisplayName_Value_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var webPut   = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, DisplayName = ""
            };
            var webPut1 = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, DisplayName = ""
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webPut);
            //---------------Execute Test ----------------------
            var @equals = webPut.Equals(webPut1);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
예제 #16
0
        public void Equals_Given_Same_OutputDescription_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var outDescr = new OutputDescription();
            var webPut   = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, OutputDescription = outDescr
            };
            var webPut1 = new DsfWebPutActivity()
            {
                UniqueID = uniqueId, OutputDescription = outDescr
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webPut);
            //---------------Execute Test ----------------------
            var @equals = webPut.Equals(webPut1);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
예제 #17
0
        public void Equals_Given_DifferentWebPutToolIds_AreNotEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId       = Guid.NewGuid().ToString();
            var uniqueId2      = Guid.NewGuid().ToString();
            var webputActivity = new DsfWebPutActivity()
            {
                UniqueID = uniqueId
            };
            var webputActivity1 = new DsfWebPutActivity()
            {
                UniqueID = uniqueId2
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(webputActivity);
            //---------------Execute Test ----------------------
            var @equals = webputActivity.Equals(webputActivity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
예제 #18
0
 static WebServicePutViewModel CreateViewModel(DsfWebPutActivity act, MyWebModel mod)
 {
     return(new WebServicePutViewModel(ModelItemUtils.CreateModelItem(act), mod));
 }