Пример #1
0
        public void DbServices_TestService_NestedTransactions_DoesNotThrowException()
        {
            //------------Setup for test--------------------------
            var dbService = new DbService
            {
                Recordset = new Recordset(),
                Method    = new ServiceMethod
                {
                    Name          = "dbo.Pr_GeneralTestNestedTransaction",
                    ExecuteAction = "dbo.Pr_GeneralTestNestedTransaction"
                },
                Source = SqlServerTests.CreateDev2TestingDbSource()
            };
            var args = JsonConvert.SerializeObject(dbService);

            Mock <IResourceCatalog> mockedResourceCatelog = new Mock <IResourceCatalog>();

            mockedResourceCatelog.Setup(a => a.GetResource <DbSource>(Guid.Empty, dbService.Source.ResourceID)).Returns(dbService.Source as DbSource);

            var dbServices = new TestDbServices(mockedResourceCatelog.Object, new Mock <IAuthorizationService>().Object);

            //------------Execute Test---------------------------
            var result = dbServices.DbTest(args, Guid.Empty, Guid.Empty);

            //------------Assert Results-------------------------
            Assert.IsNotNull(result, "DbTest returned null when it was expected to return an error free object.");
            Assert.IsFalse(result.HasErrors, result.ErrorMessage);
        }
Пример #2
0
        public void ServiceInvoker_Invoke_WhenDbTest_ExpectValidDbRecordsetDataWithCommasReplacedForUIParsing()
        {
            //------------Setup for test--------------------------


            const string args    = @"{""resourceID"":""00000000-0000-0000-0000-000000000000"",""resourceType"":""DbService"",""resourceName"":null,""resourcePath"":null,""source"":{""ServerType"":""SqlDatabase"",""Server"":""RSAKLFSVRGENDEV"",""DatabaseName"":""Dev2TestingDB"",""Port"":1433,""AuthenticationType"":""User"",""UserID"":""testUser"",""Password"":""test123"",""ConnectionString"":""Data Source=RSAKLFSVRGENDEV,1433;Initial Catalog=Dev2TestingDB;User ID=testUser;Password=test123;"",""ResourceID"":""eb2de0a3-4814-40b8-b825-f4601bfdb155"",""ResourceType"":""DbSource"",""ResourceName"":""TU Greenpoint DB"",""ResourcePath"":""SQL SRC"",""IsValid"":false,""Errors"":null,""ReloadActions"":false},""method"":{""Name"":""dbo.pr_MapLocationsGetAll"",""ExecuteAction"":""dbo.pr_MapLocationsGetAll"",""SourceCode"":""-- =============================================\r<br />-- Author:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Author,,Name>\r<br />-- Create date: <Create Date,,>\r<br />-- Description:&nbsp;&nbsp;&nbsp;&nbsp;<Description,,>\r<br />-- =============================================\r<br />CREATE PROCEDURE dbo.proc_GetAllMapLocations \r<br />&nbsp;&nbsp;&nbsp;&nbsp;\r<br />AS\r<br />BEGIN\r<br />&nbsp;&nbsp;&nbsp;&nbsp;SET NOCOUNT ON;\r<br />\r<br />    SELECT MapLocationID, StreetAddress,Latitude,Longitude FROM dbo.MapLocation ORDER BY MapLocationID ASC\r<br />END\r<br />"",""Parameters"":[]},""recordset"":{""Name"":""dbo_proc_GetAllMapLocations"",""Fields"":[],""Records"":[],""HasErrors"":false,""ErrorMessage"":""""}}";
            var          service = JsonConvert.DeserializeObject <DbService>(args);

            Mock <IResourceCatalog> mockedResourceCatelog = new Mock <IResourceCatalog>();

            mockedResourceCatelog.Setup(a => a.GetResource <DbSource>(It.IsAny <Guid>(), service.Source.ResourceID)).Returns(service.Source as DbSource);

            //------------Execute Test---------------------------
            var services = new TestDbServices(mockedResourceCatelog.Object);
            var result   = services.DbTest(args, Guid.NewGuid(), Guid.Empty);

            // __COMMA__ is expected as this means sample has been delimited properly by the server.
            // It also means there is an implicit contract between the UI and server to handle __COMMA__ back into ,

            //
            // 2013.12.11 - COMMUNITY BUG - 341463 - Fixed expected to include empty cells
            //
            const string expected = "{\"Name\":\"dbo_proc_GetAllMapLocations\",\"HasErrors\":false,\"ErrorMessage\":\"\",\"Fields\":[{\"Name\":\"MapLocationID\",\"Alias\":\"MapLocationID\",\"RecordsetAlias\":null,\"Path\":{\"$type\":\"Dev2.Converters.Graph.DataTable.DataTablePath, Dev2.Core\",\"ActualPath\":\"MapLocationID\",\"DisplayPath\":\"MapLocationID\",\"SampleData\":\"1__COMMA__2__COMMA__3__COMMA__4__COMMA__5__COMMA__7__COMMA__8__COMMA__9__COMMA__10__COMMA__11__COMMA__\",\"OutputExpression\":\"\"}},{\"Name\":\"StreetAddress\",\"Alias\":\"StreetAddress\",\"RecordsetAlias\":null,\"Path\":{\"$type\":\"Dev2.Converters.Graph.DataTable.DataTablePath, Dev2.Core\",\"ActualPath\":\"StreetAddress\",\"DisplayPath\":\"StreetAddress\",\"SampleData\":\"19 Pineside Road, New Germany__COMMA__1244 Old North Coast Rd, Redhill__COMMA__Westmead Road, Westmead__COMMA__Turquoise Road, Queensmead__COMMA__Old Main Road, Isipingo__COMMA__2 Brook Street North, Warwick Junction__COMMA__Bellair Road, Corner Bellair & Edwin Swales/Sarnia Arterial__COMMA__Riverside Road, Durban North__COMMA__Malacca Road, Durban North__COMMA__Glanville Road, Woodlands__COMMA__\",\"OutputExpression\":\"\"}},{\"Name\":\"Latitude\",\"Alias\":\"Latitude\",\"RecordsetAlias\":null,\"Path\":{\"$type\":\"Dev2.Converters.Graph.DataTable.DataTablePath, Dev2.Core\",\"ActualPath\":\"Latitude\",\"DisplayPath\":\"Latitude\",\"SampleData\":\"99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__99.99__COMMA__\",\"OutputExpression\":\"\"}},{\"Name\":\"Longitude\",\"Alias\":\"Longitude\",\"RecordsetAlias\":null,\"Path\":{\"$type\":\"Dev2.Converters.Graph.DataTable.DataTablePath, Dev2.Core\",\"ActualPath\":\"Longitude\",\"DisplayPath\":\"Longitude\",\"SampleData\":\"66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__66.6__COMMA__\",\"OutputExpression\":\"\"}}],\"Records\":[{\"Label\":\"dbo_proc_GetAllMapLocations(1)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(1).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"1\"},{\"Name\":\"dbo_proc_GetAllMapLocations(1).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"19 Pineside Road, New Germany\"},{\"Name\":\"dbo_proc_GetAllMapLocations(1).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(1).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(2)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(2).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"2\"},{\"Name\":\"dbo_proc_GetAllMapLocations(2).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"1244 Old North Coast Rd, Redhill\"},{\"Name\":\"dbo_proc_GetAllMapLocations(2).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(2).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(3)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(3).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"3\"},{\"Name\":\"dbo_proc_GetAllMapLocations(3).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Westmead Road, Westmead\"},{\"Name\":\"dbo_proc_GetAllMapLocations(3).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(3).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(4)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(4).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"4\"},{\"Name\":\"dbo_proc_GetAllMapLocations(4).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Turquoise Road, Queensmead\"},{\"Name\":\"dbo_proc_GetAllMapLocations(4).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(4).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(5)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(5).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"5\"},{\"Name\":\"dbo_proc_GetAllMapLocations(5).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Old Main Road, Isipingo\"},{\"Name\":\"dbo_proc_GetAllMapLocations(5).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(5).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(6)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(6).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"7\"},{\"Name\":\"dbo_proc_GetAllMapLocations(6).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"2 Brook Street North, Warwick Junction\"},{\"Name\":\"dbo_proc_GetAllMapLocations(6).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(6).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(7)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(7).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"8\"},{\"Name\":\"dbo_proc_GetAllMapLocations(7).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Bellair Road, Corner Bellair & Edwin Swales/Sarnia Arterial\"},{\"Name\":\"dbo_proc_GetAllMapLocations(7).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(7).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(8)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(8).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"9\"},{\"Name\":\"dbo_proc_GetAllMapLocations(8).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Riverside Road, Durban North\"},{\"Name\":\"dbo_proc_GetAllMapLocations(8).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(8).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(9)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(9).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"10\"},{\"Name\":\"dbo_proc_GetAllMapLocations(9).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Malacca Road, Durban North\"},{\"Name\":\"dbo_proc_GetAllMapLocations(9).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(9).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(10)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(10).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"11\"},{\"Name\":\"dbo_proc_GetAllMapLocations(10).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"Glanville Road, Woodlands\"},{\"Name\":\"dbo_proc_GetAllMapLocations(10).Latitude\",\"Label\":\"Latitude\",\"Value\":\"99.99\"},{\"Name\":\"dbo_proc_GetAllMapLocations(10).Longitude\",\"Label\":\"Longitude\",\"Value\":\"66.6\"}]},{\"Label\":\"dbo_proc_GetAllMapLocations(11)\",\"Name\":\"dbo_proc_GetAllMapLocations\",\"Count\":4,\"Cells\":[{\"Name\":\"dbo_proc_GetAllMapLocations(11).MapLocationID\",\"Label\":\"MapLocationID\",\"Value\":\"\"},{\"Name\":\"dbo_proc_GetAllMapLocations(11).StreetAddress\",\"Label\":\"StreetAddress\",\"Value\":\"\"},{\"Name\":\"dbo_proc_GetAllMapLocations(11).Latitude\",\"Label\":\"Latitude\",\"Value\":\"\"},{\"Name\":\"dbo_proc_GetAllMapLocations(11).Longitude\",\"Label\":\"Longitude\",\"Value\":\"\"}]}]}";

            //------------Assert Results-------------------------
            var res = result.ToString();

            Assert.AreEqual(expected, res);
        }
Пример #3
0
        public void DbServices_TestService_InvokesDatabaseBrokerTestServiceMethod_Done()
        {
            //------------Setup for test--------------------------
            var dbService = new DbService
            {
                Recordset = new Recordset(),
                Method    = new ServiceMethod(),
                Source    = SqlServerTests.CreateDev2TestingDbSource()
            };
            var args = JsonConvert.SerializeObject(dbService);

            var outputDescription = new Mock <IOutputDescription>();

            outputDescription.Setup(d => d.DataSourceShapes).Returns(new List <IDataSourceShape> {
                new DataSourceShape()
            });

            var dbBroker = new Mock <SqlDatabaseBroker>();

            dbBroker.Setup(b => b.TestService(It.IsAny <DbService>())).Returns(outputDescription.Object).Verifiable();

            var dbServices = new TestDbServices(dbBroker.Object);

            //------------Execute Test---------------------------
            var result = dbServices.DbTest(args, Guid.Empty, Guid.Empty);

            //------------Assert Results-------------------------
            dbBroker.Verify(b => b.TestService(It.IsAny <DbService>()));

            Assert.IsNotNull(result);
        }
Пример #4
0
        public void DbServices_TestService_InvalidArgs_RecordsetWithError()
        {
            var services = new TestDbServices();

            //------------Execute Test---------------------------
            var result = services.DbTest("xxx", Guid.Empty, Guid.Empty);

            // Assert Recordset With Error
            Assert.IsTrue(result.HasErrors);
        }
Пример #5
0
        public void DbServices_TestService_ValidArgsAndValidRecordsetName_UpdatesRecordsetNameToServiceMethodName()
        {
            var service = CreateDev2TestingDbService();

            service.Recordset.Name = "MyCities";
            var args        = service.ToString();
            var workspaceID = Guid.NewGuid();

            Mock <IResourceCatalog> mockedResourceCatelog = new Mock <IResourceCatalog>();

            mockedResourceCatelog.Setup(a => a.GetResource <DbSource>(workspaceID, service.Source.ResourceID)).Returns(service.Source as DbSource);

            var services = new TestDbServices(mockedResourceCatelog.Object, new Mock <IAuthorizationService>().Object);

            //------------Execute Test---------------------------
            var result = services.DbTest(args, workspaceID, Guid.Empty);

            //Assert Updates Recordset Name To Service Method Name
            Assert.AreEqual(service.Recordset.Name, result.Name, "Recordset name is defaulting to service method name when not null");
            Assert.IsFalse(result.HasErrors, "Valid DB service returned error on test");
        }