public void ValidateSingletonAttribute_ScopeIsHost_ScopeIdEmpty_Throws(SingletonMode mode) { SingletonAttribute attribute = new SingletonAttribute(null, SingletonScope.Host); InvalidOperationException exception = Assert.Throws<InvalidOperationException>(() => { SingletonManager.ValidateSingletonAttribute(attribute, mode); }); Assert.Equal("A ScopeId value must be provided when using scope 'Host'.", exception.Message); }
internal static void ValidateSingletonAttribute(SingletonAttribute attribute, SingletonMode mode) { if (attribute.Scope == SingletonScope.Host && string.IsNullOrEmpty(attribute.ScopeId)) { throw new InvalidOperationException("A ScopeId value must be provided when using scope 'Host'."); } if (mode == SingletonMode.Listener && attribute.Scope == SingletonScope.Host) { throw new InvalidOperationException("Scope 'Host' cannot be used when the mode is set to 'Listener'."); } }