RadWhereCOM Wrapper - Unit Testable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Commissure.PACSConnector; | |
namespace Romiko | |
{ | |
public interface IMyRadWhereCom | |
{ | |
event RWC_AccessionNumbersChangedHandler AccessionNumbersChanged; | |
event RWC_AudioTranscribedHandler AudioTranscribed; | |
event RWC_DictationStartedHandler DictationStarted; | |
event RWC_DictationStoppedHandler DictationStopped; | |
event RWC_PrefetchRequestedHandler PrefetchRequested; | |
event RWC_ReportChangedHandler ReportChanged; | |
event RWC_ReportClosedHandler ReportClosed; | |
event ReportFinishedHandler ReportFinished; | |
event RWC_ReportOpenedHandler ReportOpened; | |
event RWC_TerminatedHandler Terminated; | |
event RWC_UserLoggedInHandler UserLoggedIn; | |
event RWC_UserLoggedOutHandler UserLoggedOut; | |
string AccessionNumbers { get; } | |
bool AlwaysOnTop { get; set; } | |
bool LoggedIn { get; } | |
bool Minimized { get; set; } | |
bool RestrictedSession { get; set; } | |
bool RestrictedWorkflow { get; set; } | |
string SiteName { get; } | |
string Username { get; } | |
bool Visible { get; set; } | |
int AssociateOrders(string accessionNumbers); | |
int AssociateOrdersEx(string siteName, string currentAccessionNumber, string newAccessionNumbers); | |
bool CancelReport(bool discard); | |
bool CloseReport(bool sign, bool preliminary); | |
void CreateNewReport(string accession, bool bStartDictation); | |
bool DissociateOrders(string accessionNumbers); | |
object InitializeLifetimeService(); | |
bool InsertAutoText(string name, bool replace); | |
void Log(string message); | |
void Login(string user, string password, string server); | |
bool LoginEx(string user, string password); | |
void Logout(); | |
bool LogoutEx(); | |
bool OpenReport(string siteName, string accessionNumbers); | |
bool OpenReportEx(string siteName, string accessionNumbers, string MRN); | |
bool PreviewOrders(string siteName, string accessionNumbers); | |
bool SaveReport(bool close); | |
void SetConfiguration(int numX, int numY, int showOnMonitor); | |
void SetLocation(int X, int Y); | |
void Stop(); | |
bool Terminate(); | |
void Start(ref bool started); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Commissure.PACSConnector; | |
namespace Romiko | |
{ | |
public class MyRadWhereCom : RadWhereCOM, IMyRadWhereCom | |
{ | |
public MyRadWhereCom () | |
{ | |
base.AccessionNumbersChanged += OnAccessionNumbersChanged; | |
base.AudioTranscribed += OnAudioTranscribed; | |
base.DictationStarted += OnDictationStarted; | |
base.DictationStopped += OnDictationStopped; | |
base.PrefetchRequested += OnPrefetchRequested; | |
base.ReportChanged += OnReportChanged; | |
base.ReportClosed += OnReportClosed; | |
base.ReportFinished += OnReportFinished; | |
base.ReportOpened += OnReportOpened; | |
base.Terminated += OnTerminated; | |
base.UserLoggedIn += OnUserLoggedIn; | |
base.UserLoggedOut += OnUserLoggedOut; | |
} | |
protected virtual void OnAccessionNumbersChanged(string sitename, string accessionnumbers, int status, bool isaddendum, string plaintext, string richtext) | |
{ | |
var handler = AccessionNumbersChanged; | |
if (handler != null) handler(sitename, accessionnumbers, status, isaddendum, plaintext, richtext); | |
} | |
protected virtual void OnAudioTranscribed(bool textrecognized) | |
{ | |
var handler = AudioTranscribed; | |
if (handler != null) handler(textrecognized); | |
} | |
protected virtual void OnDictationStarted() | |
{ | |
var handler = DictationStarted; | |
if (handler != null) handler(); | |
} | |
protected virtual void OnDictationStopped() | |
{ | |
var handler = DictationStopped; | |
if (handler != null) handler(); | |
} | |
protected virtual void OnPrefetchRequested(string sitename, string accessionnumbers) | |
{ | |
var handler = PrefetchRequested; | |
if (handler != null) handler(sitename, accessionnumbers); | |
} | |
protected virtual void OnReportChanged(string sitename, string accessionnumbers, int status, bool isaddendum, string plaintext, string richtext) | |
{ | |
var handler = ReportChanged; | |
if (handler != null) handler(sitename, accessionnumbers, status, isaddendum, plaintext, richtext); | |
} | |
protected virtual void OnReportClosed(string sitename, string accessionnumbers, int status, bool isaddendum, string plaintext, string richtext) | |
{ | |
var handler = ReportClosed; | |
if (handler != null) handler(sitename, accessionnumbers, status, isaddendum, plaintext, richtext); | |
} | |
protected virtual void OnReportFinished(int reportstatus) | |
{ | |
var handler = ReportFinished; | |
if (handler != null) handler(reportstatus); | |
} | |
protected virtual void OnReportOpened(string sitename, string accessionnumbers, int status, bool isaddendum, string plaintext, string richtext) | |
{ | |
var handler = ReportOpened; | |
if (handler != null) handler(sitename, accessionnumbers, status, isaddendum, plaintext, richtext); | |
} | |
protected virtual void OnTerminated() | |
{ | |
var handler = Terminated; | |
if (handler != null) handler(); | |
} | |
protected virtual void OnUserLoggedIn(string username) | |
{ | |
var handler = UserLoggedIn; | |
if (handler != null) handler(username); | |
} | |
protected virtual void OnUserLoggedOut(string username) | |
{ | |
var handler = UserLoggedOut; | |
if (handler != null) handler(username); | |
} | |
public new event RWC_AccessionNumbersChangedHandler AccessionNumbersChanged; | |
public new event RWC_AudioTranscribedHandler AudioTranscribed; | |
public new event RWC_DictationStartedHandler DictationStarted; | |
public new event RWC_DictationStoppedHandler DictationStopped; | |
public new event RWC_PrefetchRequestedHandler PrefetchRequested; | |
public new event RWC_ReportChangedHandler ReportChanged; | |
public new event RWC_ReportClosedHandler ReportClosed; | |
public new event ReportFinishedHandler ReportFinished; | |
public new event RWC_ReportOpenedHandler ReportOpened; | |
public new event RWC_TerminatedHandler Terminated; | |
public new event RWC_UserLoggedInHandler UserLoggedIn; | |
public new event RWC_UserLoggedOutHandler UserLoggedOut; | |
public new string AccessionNumbers { get { return base.AccessionNumbers; } } | |
public new bool AlwaysOnTop { get { return base.AlwaysOnTop; } set { base.AlwaysOnTop = value; }} | |
public new bool LoggedIn { get { return base.LoggedIn; } } | |
public new bool Minimized { get { return base.Minimized; } set { base.Minimized = value; } } | |
public new bool RestrictedSession { get { return base.RestrictedSession; } set { base.RestrictedSession = value; } } | |
public new bool RestrictedWorkflow { get { return base.RestrictedWorkflow; } set { base.RestrictedWorkflow = value; } } | |
public new string SiteName { get { return base.SiteName; } } | |
public new string Username { get { return base.Username; } } | |
public new bool Visible { get { return base.Visible; } set { base.Visible = value; } } | |
public new void Stop() | |
{ | |
base.Stop(); | |
} | |
public new bool Terminate() | |
{ | |
return base.Terminate(); | |
} | |
public new void Start(ref bool started) | |
{ | |
base.Start(ref started); | |
} | |
public new int AssociateOrders(string accessionNumbers) | |
{ | |
return base.AssociateOrders(accessionNumbers); | |
} | |
public new int AssociateOrdersEx(string siteName, string currentAccessionNumber, string newAccessionNumbers) | |
{ | |
return base.AssociateOrdersEx(siteName, currentAccessionNumber, newAccessionNumbers); | |
} | |
public new bool CancelReport(bool discard) | |
{ | |
return base.CancelReport(discard); | |
} | |
public new bool CloseReport(bool sign, bool preliminary) | |
{ | |
return base.CloseReport(sign, preliminary); | |
} | |
public new void CreateNewReport(string accession, bool bStartDictation) | |
{ | |
base.CreateNewReport(accession, bStartDictation); | |
} | |
public new bool DissociateOrders(string accessionNumbers) | |
{ | |
return base.DissociateOrders(accessionNumbers); | |
} | |
public new object InitializeLifetimeService() | |
{ | |
return base.InitializeLifetimeService(); | |
} | |
public new bool InsertAutoText(string name, bool replace) | |
{ | |
return base.InsertAutoText(name, replace); | |
} | |
public new void Log(string message) | |
{ | |
RadWhereCOM.Log(message); | |
} | |
public new void Login(string user, string password, string server) | |
{ | |
base.Login(user, password, server); | |
} | |
public new bool LoginEx(string user, string password) | |
{ | |
return base.LoginEx(user, password); | |
} | |
public new void Logout() | |
{ | |
base.Logout(); | |
} | |
public new bool LogoutEx() | |
{ | |
return base.LogoutEx(); | |
} | |
public new bool OpenReport(string siteName, string accessionNumbers) | |
{ | |
return base.OpenReport(siteName, accessionNumbers); | |
} | |
public new bool OpenReportEx(string siteName, string accessionNumbers, string MRN) | |
{ | |
return base.OpenReportEx(siteName, accessionNumbers, MRN); | |
} | |
public new bool PreviewOrders(string siteName, string accessionNumbers) | |
{ | |
return base.PreviewOrders(siteName, accessionNumbers); | |
} | |
public new bool SaveReport(bool close) | |
{ | |
return base.SaveReport(close); | |
} | |
public new void SetConfiguration(int numX, int numY, int showOnMonitor) | |
{ | |
base.SetConfiguration(numX, numY, showOnMonitor); | |
} | |
public new void SetLocation(int X, int Y) | |
{ | |
base.SetLocation(X,Y); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Powerscribe360 | |
{ | |
public IMyRadWhereCom radWhereCom; | |
public Powerscribe360(IMyRadWhereCom myRadWhereCom) | |
{ | |
radWhereCom = myRadWhereCom; | |
WireUpEvents(); | |
} | |
private void WireUpEvents() | |
{ | |
radWhereCom.UserLoggedIn += UserLoggedIn; | |
radWhereCom.UserLoggedOut += UserLoggedOut; | |
radWhereCom.AudioTranscribed += AudioTranscribed; | |
radWhereCom.AccessionNumbersChanged += AccessionNumbersChanged; | |
radWhereCom.ReportFinished += ReportFinished; | |
radWhereCom.ReportClosed += ReportClosed; | |
radWhereCom.ReportOpened += ReportOpened; | |
radWhereCom.ReportChanged += ReportChanged; | |
radWhereCom.DictationStarted += DictationStarted; | |
radWhereCom.DictationStopped += DictationStopped; | |
radWhereCom.Terminated += Terminated; | |
} | |
public void UserLoggedIn(string userName) | |
{ | |
Hub.Publish(HubEvents.DictationSystem.LoginCompleted); | |
} | |
public void UserLoggedOut(string userName) | |
{ | |
radWhereCom.Terminate(); | |
Hub.Publish(HubEvents.DictationSystem.PSInterop.LoggedOff); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using IPO.Shared; | |
using NSubstitute; | |
using NUnit.Framework; | |
using Romiko; | |
namespace Reporting.Tests | |
{ | |
[TestFixture] | |
public partial class Powerscribe360Tests | |
{ | |
[Test] | |
public void ShouldRaiseUserLoggedInEvent() | |
{ | |
// arrange | |
var wasCalled = false; | |
Hub.Subscribe(HubEvents.DictationSystem.LoginCompleted, () => | |
{ | |
wasCalled = true; | |
}, "Foo"); | |
var radWhereCom = Substitute.For<IMyRadWhereCom>(); | |
var ps = new Powerscribe360(radWhereCom); | |
// act | |
ps.radWhereCom.UserLoggedIn += Raise.Event<RWC_UserLoggedInHandler>("Foo"); | |
// Assert | |
Assert.IsTrue(wasCalled); | |
} | |
[Test] | |
public void ShouldRaiseUserLoggedOffEvent() | |
{ | |
// arrange | |
var wasCalled = false; | |
Hub.Subscribe(HubEvents.DictationSystem.PSInterop.LoggedOff, () => | |
{ | |
wasCalled = true; | |
}, "Foo"); | |
var radWhereCom = Substitute.For<IMyRadWhereCom>(); | |
radWhereCom.Terminate().ReturnsForAnyArgs(true); | |
var ps = new Powerscribe360(radWhereCom); | |
// act | |
ps.radWhereCom.UserLoggedOut += Raise.Event<RWC_UserLoggedOutHandler>("Foo"); | |
// assert | |
Assert.IsTrue(wasCalled); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment