Ejemplo n.º 1
0
        public void GetAllResourceTypes_Success()
        {
            //Given
            ResourceType resourceType = new ResourceType()
            {
                ResourceTypeName = "VM"
            };
            var resourceTypes = new List <ResourceType>()
            {
                resourceType
            };
            int tenantId = 1;

            resourceServiceMoq.Setup(r => r.GetResourceTypes(tenantId)).Returns(resourceTypes);

            //When
            var controller  = new ResourceController(logger.Object, resourceServiceMoq.Object);
            var response    = controller.GetAllResourceTypes(tenantId) as OkObjectResult;
            var responseObj = response.Value as List <ResourceType>;

            //Then
            Assert.IsType <OkObjectResult>(response);
            Assert.NotNull(response.Value);
            Assert.True(responseObj.Count > 0);
            resourceServiceMoq.Verify(r => r.GetResourceTypes(tenantId), Times.Once);
        }
Ejemplo n.º 2
0
        public void GetAllResourceTypes_Invalid_TenantId()
        {
            //Given
            int tenantId = 0;

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

            //Then
            Assert.IsType <BadRequestObjectResult>(response);
            Assert.Equal($"Invalid TenantId : {tenantId}", response.Value);
        }
Ejemplo n.º 3
0
        public void GetAllResourceTypes_NotFound()
        {
            //Given
            IEnumerable <ResourceType> resourceTypes = null;
            int tenantId = 40;

            resourceServiceMoq.Setup(r => r.GetResourceTypes(tenantId)).Returns(resourceTypes);

            //When
            var controller = new ResourceController(logger.Object, resourceServiceMoq.Object);
            var response   = controller.GetAllResourceTypes(tenantId) as NotFoundObjectResult;

            //Then
            Assert.IsType <NotFoundObjectResult>(response);
            Assert.Equal($"There are no resource types found for tenantId : {tenantId}", response.Value);
            resourceServiceMoq.Verify(r => r.GetResourceTypes(tenantId), Times.Once);
        }