I understand the basics like unit test, however I often try to find out what meaningful things to experience. I believe that I need to create a fake implementation and introduce a consumer into it. I have a subscription service class (using Exchange Web Services (EWS)). Exchange 2010 requests updates by new mail. To separate my subscription from the service itself, I decided to implement its implementation in the service. The following is what I currently have. I skipped code specifically related to Exchange.
public interface IStreamingNotificationService
{
void Subscribe();
}
public interface IExchangeService
{
void Subscribe();
}
public class StreamingNotificationService : IStreamingNotificationService
{
private readonly IExchangeService _exchangeService;
public StreamingNotificationService(IExchangeService exchangeService)
{
if (exchangeService == null)
{
throw new ArgumentNullException("exchangeService");
}
_exchangeService = exchangeService;
}
public void Subscribe()
{
_exchangeService.Subscribe();
}
}
public class ExchangeServiceImpl : IExchangeService
{
private readonly INetworkConfiguration _networkConfiguration;
private ExchangeService ExchangeService { get; set; }
public ExchangeServiceImpl(INetworkConfiguration networkConfiguration)
{
if (networkConfiguration == null)
{
throw new ArgumentNullException("networkConfiguration");
}
_networkConfiguration = networkConfiguration;
}
public void Subscribe()
{
}
}
In particular, how to create a meaningful unit test to ensure that the subscription works as it should?
source
share