Ejemplo n.º 1
0
        public void CreateResource_Invalid_ResourceName_Or_TenantId(string resourceName, int tenantId)
        {
            //Given
            Resource resource = new Resource()
            {
                ResourceName = resourceName
            };

            //When
            var controller = new ResourceController(logger.Object, resourceServiceMoq.Object);
            var response   = controller.CreateResource(resource, tenantId) as BadRequestObjectResult;

            //Then
            Assert.IsType <BadRequestObjectResult>(response);
            Assert.Equal($"Empty Resource name : {resource.ResourceName} or Invalid TenantId : {tenantId}", response.Value);
        }
Ejemplo n.º 2
0
        public void CreateResource_Failure()
        {
            //Given
            Resource resource = new Resource()
            {
                ResourceName = "Database server"
            };
            int tenantId = 1, resourceCreated = 0;

            resourceServiceMoq.Setup(r => r.CreateResource(resource, tenantId)).Returns(resourceCreated);

            //When
            var controller = new ResourceController(logger.Object, resourceServiceMoq.Object);
            var response   = controller.CreateResource(resource, tenantId) as BadRequestObjectResult;

            //Then
            Assert.IsType <BadRequestObjectResult>(response);
            Assert.Equal("Resource Not created", response.Value);
            resourceServiceMoq.Verify(r => r.CreateResource(resource, tenantId), Times.Once);
        }