Example #1
0
        /// <summary>
        /// Resolves whether the write operation can be performed on a <see cref="Thing"/> of <see cref="Type"/>
        /// <paramref name="thingType"/> based on the superclass of <paramref name="thingType"/>
        /// </summary>
        /// <param name="containerThing">The container of the <see cref="Thing"/> that the write operation
        /// needs to be performed on.</param>
        /// <param name="thingType">The <see cref="Type"/> of the <see cref="Thing"/> that will be write to.</param>
        /// <returns>True if the permissions of the superclass allow it.</returns>
        private bool CanWriteBasedOnSuperclassClassKind(Thing containerThing, ClassKind thingType)
        {
            var baseType = StaticMetadataProvider.BaseType(thingType.ToString());

            if (string.IsNullOrWhiteSpace(baseType))
            {
                return(false);
            }

            return(Enum.TryParse(baseType, out ClassKind superClassKind) && this.CanWrite(superClassKind, containerThing));
        }
Example #2
0
        public void StaticProviderPreservesStateAcrossInstances()
        {
            // Arrange
            StaticMetadataProvider staticMetadataProvider1 = new StaticMetadataProvider();
            StaticMetadataProvider staticMetadataProvider2 = new StaticMetadataProvider();

            staticMetadataProvider1.AddMetadata("env", new InstanceDiscoveryMetadataEntry());

            // Act
            var result = staticMetadataProvider2.GetMetadata("env");

            staticMetadataProvider2.Clear();
            var result2 = staticMetadataProvider2.GetMetadata("env");

            // Assert
            Assert.IsNotNull(result);
            Assert.IsNull(result2);
        }