public void ObservableSubscription_Test() { output.WriteLine("ObservableSubscription_Test"); TestObservable observable = new TestObservable(); TestObserever observer = new TestObserever(); observable.SubscibeObserver(observer); List <IWristbandObserver> observers = observable.SubscribtionList; Assert.True(observers.Count > 0, "observers.Count should return exactly one subscription"); Assert.True(observers.IndexOf(observer) != -1, "observers should contain the observer object"); bool init, deinit, error, connect, debug, disconnect, profile, steps, unknown, write; init = deinit = error = connect = debug = disconnect = profile = steps = unknown = write = false; observer.TestInitResponse = () => { init = true; output.WriteLine("> TestObserever.OnBluetoothDeInitialized() :: called"); }; observer.TestDeInitResponse = () => { deinit = true; output.WriteLine("> TestObserever.OnBluetoothInitialized() :: called"); }; observer.TestOnErrorResponse = (WristbandProtocolError werror, string msg) => { error = true; output.WriteLine("> TestObserever.OnError() :: called - " + msg); }; observer.TestConnectedResponse = (string pheriperalID, string pheriperalName, WristbandProfile wprofile) => { connect = true; output.WriteLine("> TestObserever.OnWristbandConnected() :: called"); }; observer.TestDebugResponse = (string msg) => { debug = true; output.WriteLine("> TestObserever.OnWristbandDebugMessage() :: called"); }; observer.TestDisconnectedResponse = () => { disconnect = true; output.WriteLine("> TestObserever.OnWristbandDisconnected() :: called"); }; observer.TestProfileFoundResponse = (string pheriperalID, string pheriperalName) => { profile = true; output.WriteLine("> TestObserever.OnWristbandProfileFound() :: called"); }; observer.TestStepsCollectedResponse = (StepsData stepsData) => { steps = true; output.WriteLine("> TestObserever.OnWristbandStepsCollected() :: called"); }; observer.TestUnknownProfileResponse = (string pheriperalID, string pheriperalName) => { unknown = true; output.WriteLine("> TestObserever.OnWristbandUnknownProfile() :: called"); }; observer.TestWriteCompleteResponse = () => { write = true; output.WriteLine("> TestObserever.OnWristbandWriteComplete() :: called"); }; observable.OnInitComplete_Test(); observable.OnDeInitComplete_Test(); observable.OnERROR_Test(WristbandProtocolError.INITIALIZATION_FAILED, "Debug Error"); observable.OnConnected_Test("001", "002", BoosthWristbandServices.DebugProfile); observable.OnDebugMSG_Test("Debug Message"); observable.OnDisconnected_Test(); observable.OnMatchingProfile_Test("001", "002"); observable.OnUnknownProfile_Test("001", "002"); observable.OnStepsCollected_Test(new StepsData()); observable.OnWriteComplete_Test(); Assert.True(init); Assert.True(deinit); Assert.True(error); Assert.True(connect); Assert.True(debug); Assert.True(disconnect); Assert.True(profile); Assert.True(steps); Assert.True(unknown); Assert.True(write); observable.UnsubscibeObserver(observer); observers = observable.SubscribtionList; Assert.True(observers.Count == 0, "observers.Count should return exactly zero subscriptions after unsubscribing"); Assert.True(observers.IndexOf(observer) == -1, "observers should not contain the observer object anymore, after unsubscribing"); }