public void ChangeSrcExpectSomethingChanged()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };
            var Evt = false;
            var s2  = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            region.SomethingChanged += (a, b) => { Evt = true; };
            region.SelectedSource    = s2;
            Assert.IsTrue(Evt);
        }
        public void CloneRegionExpectClone()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };
            var s2 = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));
            var cloned = region.CloneRegion();

            Assert.AreEqual(((WebSourceRegion)cloned).SelectedSource, region.SelectedSource);
        }
Exemple #3
0
        public void WebServiceSourceDefinition_Equals_Object_GetType_Expected_False()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedDefaultQuery       = "testDefaultQuery";
            var          expectedId       = Guid.NewGuid();
            const string expectedName     = "testResourceName";
            const string expectedPassword = "******";
            const string expectedHostName = "testHost";
            const string expectedPath     = "testPath";
            const string expectedUserName = "******";

            var mockWebSource = new Mock <IWebSource>();

            mockWebSource.Setup(webSource => webSource.AuthenticationType).Returns(expectedAuthenticationType);
            mockWebSource.Setup(webSource => webSource.DefaultQuery).Returns(expectedDefaultQuery);
            mockWebSource.Setup(webSource => webSource.ResourceID).Returns(expectedId);
            mockWebSource.Setup(webSource => webSource.ResourceName).Returns(expectedName);
            mockWebSource.Setup(webSource => webSource.Password).Returns(expectedPassword);
            mockWebSource.Setup(webSource => webSource.Address).Returns(expectedHostName);
            mockWebSource.Setup(webSource => webSource.GetSavePath()).Returns(expectedPath);
            mockWebSource.Setup(webSource => webSource.UserName).Returns(expectedUserName);

            var webServiceSourceDefinition = new WebServiceSourceDefinition(mockWebSource.Object);

            var webSourceObj = new object();

            var isEqual = webServiceSourceDefinition.Equals(webSourceObj);

            Assert.IsFalse(isEqual);
        }
Exemple #4
0
        public void WebServiceSourceDefinition_GetHashCode_Not_Equal_To_Zero()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedDefaultQuery       = "testDefaultQuery";
            var          expectedId       = Guid.NewGuid();
            const string expectedName     = "testResourceName";
            const string expectedPassword = "******";
            const string expectedHostName = "testHost";
            const string expectedPath     = "testPath";
            const string expectedUserName = "******";

            var mockWebSource = new Mock <IWebSource>();

            mockWebSource.Setup(webSource => webSource.AuthenticationType).Returns(expectedAuthenticationType);
            mockWebSource.Setup(webSource => webSource.DefaultQuery).Returns(expectedDefaultQuery);
            mockWebSource.Setup(webSource => webSource.ResourceID).Returns(expectedId);
            mockWebSource.Setup(webSource => webSource.ResourceName).Returns(expectedName);
            mockWebSource.Setup(webSource => webSource.Password).Returns(expectedPassword);
            mockWebSource.Setup(webSource => webSource.Address).Returns(expectedHostName);
            mockWebSource.Setup(webSource => webSource.GetSavePath()).Returns(expectedPath);
            mockWebSource.Setup(webSource => webSource.UserName).Returns(expectedUserName);

            var webServiceSourceDefinition = new WebServiceSourceDefinition(mockWebSource.Object);

            var hashCode = webServiceSourceDefinition.GetHashCode();

            Assert.AreNotEqual(0, hashCode);
        }
        public void Restore_Region_ExpectRestore()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };
            var s2 = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            var regionToRestore = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            regionToRestore.SelectedSource = s2;

            region.RestoreRegion(regionToRestore);

            Assert.AreEqual(region.SelectedSource, s2);
        }
Exemple #6
0
        public void WebServiceSourceDefinition_ReferenceEquals_WebServiceSource_Expected_True()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedDefaultQuery       = "testDefaultQuery";
            var          expectedId       = Guid.NewGuid();
            const string expectedName     = "testResourceName";
            const string expectedPassword = "******";
            const string expectedHostName = "testHost";
            const string expectedUserName = "******";

            var mockWebSource = new Mock <IWebSource>();

            mockWebSource.Setup(webSource => webSource.Address).Returns(expectedHostName);
            mockWebSource.Setup(webSource => webSource.ResourceID).Returns(expectedId);
            mockWebSource.Setup(webSource => webSource.ResourceName).Returns(expectedName);
            mockWebSource.Setup(webSource => webSource.UserName).Returns(expectedUserName);
            mockWebSource.Setup(webSource => webSource.Password).Returns(expectedPassword);
            mockWebSource.Setup(webSource => webSource.AuthenticationType).Returns(expectedAuthenticationType);
            mockWebSource.Setup(webSource => webSource.DefaultQuery).Returns(expectedDefaultQuery);

            IWebServiceSource webServiceSourceDefinition = new WebServiceSourceDefinition(mockWebSource.Object);

            var isEqual = webServiceSourceDefinition.Equals(webServiceSourceDefinition);

            Assert.IsTrue(isEqual);
        }
        public void GivenIOpenWebSource(string resourceName)
        {
            var manageWebserviceSourceControl = scenarioContext.Get <ManageWebserviceSourceControl>(Utils.ViewNameKey);
            var mockStudioUpdateManager       = new Mock <IManageWebServiceSourceModel>();

            mockStudioUpdateManager.Setup(model => model.ServerName).Returns("localhost");
            var mockEventAggregator = new Mock <IEventAggregator>();
            var mockExecutor        = new Mock <IExternalProcessExecutor>();

            var username = @"dev2\IntegrationTester";
            var password = TestEnvironmentVariables.GetVar(username);
            var webServiceSourceDefinition = new WebServiceSourceDefinition
            {
                Name         = "Test",
                HostName     = "http://RSAKLFSVRTFSBLD/IntegrationTestSite",
                DefaultQuery = "/GetCountries.ashx?extension=json&prefix=a",
                UserName     = "******",
                Password     = password
            };

            mockStudioUpdateManager.Setup(model => model.FetchSource(It.IsAny <Guid>()))
            .Returns(webServiceSourceDefinition);
            var manageWebserviceSourceViewModel = new ManageWebserviceSourceViewModel(mockStudioUpdateManager.Object, mockEventAggregator.Object, webServiceSourceDefinition, new SynchronousAsyncWorker(), mockExecutor.Object);

            manageWebserviceSourceControl.DataContext = manageWebserviceSourceViewModel;
            scenarioContext.Remove("viewModel");
            scenarioContext.Add("viewModel", manageWebserviceSourceViewModel);
        }
        public IWebServiceSource FetchSource(Guid id)
        {
            var xaml = _queryProxy.FetchResourceXaml(id);
            var db   = new WebSource(xaml.ToXElement());

            var def = new WebServiceSourceDefinition(db);

            return(def);
        }
Exemple #9
0
        public void WebServiceSourceDefinition_Equals_WebServiceSource_Null_Expected_False()
        {
            var webServiceSourceDefinition = new WebServiceSourceDefinition();

            const IWebServiceSource webServiceSource = null;

            var isEqual = webServiceSourceDefinition.Equals(webServiceSource);

            Assert.IsFalse(isEqual);
        }
Exemple #10
0
        public void WebServiceSourceDefinition_GetHashCode_Expect_Zero()
        {
            var mockWebSource = new Mock <IWebSource>();

            var webServiceSourceDefinition = new WebServiceSourceDefinition(mockWebSource.Object);

            var hashCode = webServiceSourceDefinition.GetHashCode();

            Assert.AreEqual(0, hashCode);
        }
        public void NotEqualsOperator_WithNotEqualObjects_AreNotEqual()
        {
            var firstWebServiceSourceDefinition = new WebServiceSourceDefinition {
                Name = "bravo"
            };
            var secondWebServiceSourceDefinition = new WebServiceSourceDefinition {
                Name = "charlie"
            };

            Assert.IsTrue(firstWebServiceSourceDefinition != secondWebServiceSourceDefinition, "Not equals operator doesnt work.");
        }
        public void EqualsOperator_WithEqualObjects_AreEqual()
        {
            var firstWebServiceSourceDefinition = new WebServiceSourceDefinition {
                Name = "bravo"
            };
            var secondWebServiceSourceDefinition = new WebServiceSourceDefinition {
                Name = "bravo"
            };

            Assert.IsTrue(firstWebServiceSourceDefinition == secondWebServiceSourceDefinition, "Equals operator doesnt work.");
        }
        public void SavedSource_Itself_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var webServiceSourceDefinition = new WebServiceSourceDefinition
            {
                Id   = Guid.NewGuid(),
                Path = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsTrue(webServiceSourceDefinition.Equals(webServiceSourceDefinition), "Equals operator can't compare to itself.");
        }
        public void SavedSource_Null_Object_Is_NotEqual()
        {
            //---------------Set up test pack-------------------
            var webServiceSourceDefinition = new WebServiceSourceDefinition
            {
                Id   = Guid.NewGuid(),
                Path = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(webServiceSourceDefinition.Equals(null), "Equals operator can't compare to null.");
        }
        public void SavedSource_DifferentType_Is_NotEqual()
        {
            //---------------Set up test pack-------------------
            var webServiceSourceDefinition = new WebServiceSourceDefinition {
                Name = "bravo"
            };
            object differentObject = new DsfWebGetActivity
            {
                SourceId   = Guid.NewGuid(),
                ActionName = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(webServiceSourceDefinition.Equals(differentObject), "Equals operator can't compare to differently typed object.");
        }
        public void GivenIDragWebDeleteRequestConnectorToolOntoTheDesignSurface()
        {
            var activity  = new DsfWebDeleteActivity();
            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://rsaklfsvrtfsbld/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 WebServiceDeleteViewModel(modelItem, mockServiceModel.Object);


            scenarioContext.Add("viewModel", viewModel);
            scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            scenarioContext.Add("mockServiceModel", mockServiceModel);
        }
        public void CtorWitSelectedSrc()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            Assert.AreEqual(websrc, region.SelectedSource);
            Assert.IsTrue(region.CanEditSource());
        }
        public void ChangeSelectedSource_ExpectRegionsRestored()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id, HostName = "bob"
            };

            var s2 = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid(), HostName = "bob"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            var clone1 = new Mock <IToolRegion>();
            var clone2 = new Mock <IToolRegion>();
            var dep1   = new Mock <IToolRegion>();

            dep1.Setup(a => a.CloneRegion()).Returns(clone1.Object);

            var dep2 = new Mock <IToolRegion>();

            dep2.Setup(a => a.CloneRegion()).Returns(clone2.Object);
            region.Dependants = new List <IToolRegion> {
                dep1.Object, dep2.Object
            };
            region.SelectedSource = s2;
            region.SelectedSource = websrc;
            dep1.Verify(a => a.RestoreRegion(clone1.Object));
            dep2.Verify(a => a.RestoreRegion(clone2.Object));
        }
Exemple #19
0
        public void GivenIDragWebGetRequestConnectorToolOntoTheDesignSurface()
        {
            var activity  = new WebGetActivity();
            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);

            _otherwebsource = new WebServiceSourceDefinition
            {
                Name     = "OtherWebSource",
                HostName = @"http://www.google.com",
                Id       = Guid.NewGuid()
            };

            using (var _dependencyOps = new Depends(Depends.ContainerType.HTTPVerbsApi))
            {
                _weblocalhostsource = new WebServiceSourceDefinition
                {
                    Name     = "LocalhostSource",
                    HostName = $"http://{_dependencyOps.Container.IP}:{_dependencyOps.Container.Port}/api/products/Get",
                    Id       = Guid.NewGuid()
                };
            }

            var webService = new WebService
            {
                RequestResponse = "[{\"Category\":\"Electronic\",\"Id\":\"1\",\"Name\":\"Television\",\"Price\":\"82000\"},{\"Category\":\"Electronic\",\"Id\":\"2\",\"Name\":\"Refrigerator\",\"Price\":\"23000\"},{\"Category\":\"Electronic\",\"Id\":\"3\",\"Name\":\"Mobiles\",\"Price\":\"20000\"},{\"Category\":\"Electronic\",\"Id\":\"4\",\"Name\":\"Laptops\",\"Price\":\"45000\"},{\"Category\":\"Electronic\",\"Id\":\"5\",\"Name\":\"iPads\",\"Price\":\"67000\"},{\"Category\":\"Gift Items\",\"Id\":\"6\",\"Name\":\"Toys\",\"Price\":\"15000\"}]",
                Recordsets      = new RecordsetList
                {
                    new Dev2.Runtime.ServiceModel.Data.Recordset
                    {
                        Name   = "UnnamedArrayData",
                        Fields = new List <RecordsetField>
                        {
                            new RecordsetField
                            {
                                Alias          = "Id",
                                Name           = "Id",
                                RecordsetAlias = ""
                            },
                            new RecordsetField
                            {
                                Alias          = "Name",
                                Name           = "Name",
                                RecordsetAlias = ""
                            },
                            new RecordsetField
                            {
                                Alias          = "Category",
                                Name           = "Category",
                                RecordsetAlias = ""
                            },
                            new RecordsetField
                            {
                                Alias          = "Price",
                                Name           = "Price",
                                RecordsetAlias = ""
                            }
                        }
                    }
                }
            };
            var serializer = new Dev2JsonSerializer();
            var testResult = serializer.Serialize(webService);

            var sources = new ObservableCollection <IWebServiceSource> {
                _weblocalhostsource, _otherwebsource
            };

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

            _scenarioContext.Add("viewModel", viewModel);
            _scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            _scenarioContext.Add("mockServiceModel", mockServiceModel);
        }