Exemple #1
0
        public void GetResourceById_ThrowsEntityNotFound_WhenResourceDoesNotExist()
        {
            var nonExistingId    = Guid.NewGuid();
            var resourcesService = new ResourcesService(resourceRepoMock.Object);

            Assert.ThrowsException <EntityNotFoundException>(() =>
            {
                resourcesService.GetResourceById(nonExistingId.ToString());
            });
        }
Exemple #2
0
        public void GetResourceById_ThrowsException_WhenResourceIdHasInvalidValue()
        {
            var resourcesService = new ResourcesService(resourceRepoMock.Object);

            var badId = "ljkhgfgd fhjlikh jguygf";

            Assert.ThrowsException <Exception>(() =>
            {
                resourcesService.GetResourceById(badId);
            });
        }
Exemple #3
0
        public void GetResourceById_Returns_ResourceWhenExists()
        {
            Exception throwException   = null;
            var       resourcesService = new ResourcesService(resourceRepoMock.Object);
            Resource  resource         = null;

            try
            {
                resource = resourcesService.GetResourceById(existingResourceGuid.ToString());
            }
            catch (Exception e)
            {
                throwException = e;
            }

            Assert.IsNull(throwException, $"Exception was thrown");
            Assert.IsNotNull(resource);
        }