public void FindResourceItemByKeyWithEmptyModel(AzureIntegrationServicesModel model, ResourceItem resource) { "Given an empty source model" .x(() => model = new AzureIntegrationServicesModel()); "When finding a resource" .x(() => resource = model.FindResourceByKey("key does not exist")); "Then resource definition should be null" .x(() => resource.Should().BeNull()); }
public void FindResourceItemByKeyWithTwoLevels(AzureIntegrationServicesModel model, ResourceItem resource) { var resourceKeyToFind = "nameTofind"; var resourceNameToFind = "nameToFind"; "Given a source model with resource definitions with resources" .x(() => { model = new AzureIntegrationServicesModel(); model.MigrationSource.ResourceContainers.Add(new ResourceContainer() { Key = "containerkey1", Name = "containerName1" }); model.MigrationSource.ResourceContainers[0].ResourceDefinitions.Add(new ResourceDefinition() { Key = "containerkey1-1", Name = "definitionName1-1" }); model.MigrationSource.ResourceContainers[0].ResourceDefinitions[0].Resources.Add(new ResourceItem() { Key = "containerkey1-1-1", Name = "resourceName1-1-1" }); model.MigrationSource.ResourceContainers[0].ResourceDefinitions[0].Resources.Add(new ResourceItem() { Key = "containerkey1-1-2", Name = "resourceName1-1-2" }); model.MigrationSource.ResourceContainers[0].ResourceDefinitions[0].Resources[0].Resources.Add(new ResourceItem() { Key = "containerkey1-1-1-1", Name = "resourceName1-1-1-1" }); model.MigrationSource.ResourceContainers[0].ResourceDefinitions[0].Resources[0].Resources.Add(new ResourceItem() { Key = "containerkey1-1-1-2", Name = "resourceName1-1-1-2" }); model.MigrationSource.ResourceContainers[0].ResourceDefinitions[0].Resources[0].Resources.Add(new ResourceItem() { Key = resourceKeyToFind, Name = resourceNameToFind }); }); "When finding a resource" .x(() => resource = model.FindResourceByKey(resourceKeyToFind)); "Then resource definition should be found" .x(() => { resource.Should().NotBeNull(); resource.Key.Should().Be(resourceKeyToFind); resource.Name.Should().Be(resourceNameToFind); }); }