ToServiceDefinition() public method

public ToServiceDefinition ( bool prepairForDeployment = false ) : StringBuilder
prepairForDeployment bool
return StringBuilder
Ejemplo n.º 1
0
        void Verify_ToServiceDefinition_GivenXamlPresent(ResourceType resourceType, string category, string workflowXaml, bool hasWorkflowXaml, Action<XElement> verify)
        {
            //------------Setup for test--------------------------
            Setup();
            var eventPublisher = new EventPublisher();
            var environmentModel = CreateMockEnvironment(eventPublisher);

            var repo = new Mock<IResourceRepository>();
            repo.Setup(r => r.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(MakeMessage(workflowXaml));

            environmentModel.Setup(e => e.ResourceRepository).Returns(repo.Object);

            var instanceID = Guid.NewGuid();
            var model = new ResourceModel(environmentModel.Object)
            {
                ID = instanceID,
                WorkflowXaml = hasWorkflowXaml ? new StringBuilder(workflowXaml) : null,
                ResourceType = resourceType,
                Category = category
            };

            //------------Execute Test---------------------------
            var serviceDefinition = model.ToServiceDefinition();

            //------------Assert Results-------------------------
            var serviceElement = XElement.Parse(serviceDefinition.ToString());
            Assert.IsNotNull(serviceElement);

            verify(serviceElement);
        }
Ejemplo n.º 2
0
        public void ResourceModel_ToServiceDefinition_InvalidResourceType_ThrowsException()
        {
            //------------Setup for test--------------------------
            Setup();
            var eventPublisher = new EventPublisher();
            var environmentModel = CreateMockEnvironment(eventPublisher);

            var repo = new Mock<IResourceRepository>();
            environmentModel.Setup(e => e.ResourceRepository).Returns(repo.Object);

            var instanceID = Guid.NewGuid();
            var model = new ResourceModel(environmentModel.Object)
            {
                ID = instanceID,
                WorkflowXaml = null,
                ResourceType = ResourceType.Server
            };

            //------------Execute Test---------------------------
            var serviceDefinition = model.ToServiceDefinition();

            //------------Assert Results-------------------------
            Assert.AreEqual(string.Empty, serviceDefinition);
        }
Ejemplo n.º 3
0
        void Verify_ToServiceDefinition_GivenXamlNull(ResourceType resourceType)
        {
            //------------Setup for test--------------------------
            Setup();
            var eventPublisher = new EventPublisher();
            var environmentModel = CreateMockEnvironment(eventPublisher);

            var repo = new Mock<IResourceRepository>();
            repo.Setup(r => r.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(MakeMessage("test")).Verifiable();

            environmentModel.Setup(e => e.ResourceRepository).Returns(repo.Object);

            var instanceID = Guid.NewGuid();
            var model = new ResourceModel(environmentModel.Object)
            {
                ID = instanceID,
                WorkflowXaml = null,
                ResourceType = resourceType
            };

            //------------Execute Test---------------------------
            model.ToServiceDefinition();

            //------------Assert Results-------------------------
            repo.Verify(r => r.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>()));
        }