コード例 #1
0
        public void DbServices_Save_ValidArgsAndEmptyResourceID_AssignsNewResourceID()
        {
            var svc = CreateDev2TestingDbService();

            svc.ResourceID = Guid.Empty;
            var args = svc.ToString();

            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                var services = new TestDbServices();

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

                //Assert Assigns New Resource ID
                var service = JsonConvert.DeserializeObject <Service>(result);
                Assert.AreNotEqual(Guid.Empty, service.ResourceID);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #2
0
        public void DbServices_Save_ValidArgs_SavesXmlToDisk()
        {
            var svc           = CreateDev2TestingDbService();
            var args          = svc.ToString();
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var path          = workspacePath;
            var fileName      = String.Format("{0}\\{1}.xml", path, svc.ResourcePath);

            try
            {
                var services = new TestDbServices();

                //------------Execute Test---------------------------
                services.Save(args, workspaceID, Guid.Empty);

                //Assert Saves Xml To Disk
                var exists = File.Exists(fileName);
                Assert.IsTrue(exists);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #3
0
        public void DbServices_Save_InvalidArgs_ReturnsErrorValidationResult()
        {
            var services = new TestDbServices();

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

            //Assert Returns Error Validation Result
            var validationResult = JsonConvert.DeserializeObject <ValidationResult>(result);

            Assert.IsFalse(validationResult.IsValid);
        }