public ThirdPartyImport(IThirdPartyFileProcessUtility usrLoader, ILoggingHelper loggingHelper, IConfigurationHelper configurationHelper) { this.usrLoader = usrLoader; this.loggingHelper = loggingHelper; this.configurationHelper = configurationHelper; this.ServiceName = configurationHelper.ReadAppSettingsConfigurationValues(BatchServiceName); }
/// <summary> /// The main entry point for the application. /// </summary> private static void Main() { IKernel kernel = new StandardKernel(new StartUp()); IThirdPartyFileProcessUtility usrLoader = kernel.Get <IThirdPartyFileProcessUtility>(); ILoggingHelper loggingHelper = kernel.Get <ILoggingHelper>(); IConfigurationHelper configurationHelper = kernel.Get <IConfigurationHelper>(); #if DEBUG using (ThirdPartyImport myService = new ThirdPartyImport(usrLoader, loggingHelper, configurationHelper)) { myService.OnDebug(); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); } #else ServiceBase[] servicesToRun = new ServiceBase[] { new ThirdPartyImport(usrLoader, loggingHelper, configurationHelper) }; ServiceBase.Run(servicesToRun); #endif }
public void Test_InValid_FileData() { msgBrokerMock = CreateMock <IMessageBroker <AddressLocationUSRDTO> >(); fileMoverMock = CreateMock <IFileMover>(); exceptionHelperMock = CreateMock <IExceptionHelper>(); loggingHelperMock = CreateMock <ILoggingHelper>(); configHelperMock = CreateMock <IConfigurationHelper>(); string filepath = Path.Combine(TestContext.CurrentContext.TestDirectory.Replace(@"bin\Debug", string.Empty), @"TestData\InvalidFile\OSABP_E702.xml"); Exception mockException = It.IsAny <Exception>(); fileMoverMock.Setup(x => x.MoveFile(It.IsAny <string[]>(), It.IsAny <string[]>())); msgBrokerMock.Setup(x => x.CreateMessage(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>())).Returns(It.IsAny <IMessage>()); msgBrokerMock.Setup(x => x.SendMessage(It.IsAny <IMessage>())); exceptionHelperMock.Setup(x => x.HandleException(It.IsAny <Exception>(), It.IsAny <ExceptionHandlingPolicy>(), out mockException)); configHelperMock.Setup(x => x.ReadAppSettingsConfigurationValues("XSDLocation")) .Returns(Path.Combine(TestContext.CurrentContext.TestDirectory.Replace(@"bin\Debug", string.Empty), @"TestData\Schemas\USRFileSchema.xsd")); configHelperMock.Setup(x => x.ReadAppSettingsConfigurationValues("TPFProcessedFilePath")).Returns(@"D:\Projects\SourceFiles\TPF\Processed"); configHelperMock.Setup(x => x.ReadAppSettingsConfigurationValues("TPFErrorFilePath")).Returns(@"D:\Projects\SourceFiles\TPF\Error"); testCandidate = new ThirdPartyFileProcessUtility( msgBrokerMock.Object, fileMoverMock.Object, exceptionHelperMock.Object, loggingHelperMock.Object, configHelperMock.Object); var rmTraceManagerMock = new Mock <IRMTraceManager>(); rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>())); loggingHelperMock.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object); testCandidate.LoadUSRDetailsFromXML(filepath); msgBrokerMock.Verify(x => x.CreateMessage(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never); msgBrokerMock.Verify(x => x.SendMessage(It.IsAny <IMessage>()), Times.Never); fileMoverMock.Verify(x => x.MoveFile(It.IsAny <string[]>(), It.IsAny <string[]>()), Times.Exactly(1)); }