public void RegistersListener() { ALListener.Set(null); var listener = new SingleListener(); Assert.Equal(ALListener.Get(), listener); }
/// <summary> /// Initializes a new instance of the <see cref="T:Bearded.Audio.SingleListener"/> class. /// </summary> public SingleListener() { if (ALListener.Get() != null) { throw new InvalidOperationException("Only one single listener can be created and registered."); } ALListener.Set(this); }
public void ForbidsMultipleListeners() { ALListener.Set(new Mock <IListener>().Object); Assert.Throws <InvalidOperationException>(() => new SingleListener()); }