Exemplo n.º 1
0
        public void startShouldInitializeChannelsWithConfigurationSettings()
        {
            var iConfigurationSettingsMock = factory.CreateMock <IConfigurationSettings>();
            var iMessagingFacilityMock     = factory.CreateMock <IMessagingFacility <Invoice, ProcessingResult> >();
            var iExceptionHandlerMock      = factory.CreateMock <IExceptionHandler>();
            var iInvoiceProcessorMock      = factory.CreateMock <IInvoiceProcessor>();

            var worker = new WorkerImpl
                         (
                iConfigurationSettingsMock.MockObject,
                iMessagingFacilityMock.MockObject,
                iExceptionHandlerMock.MockObject,
                iInvoiceProcessorMock.MockObject
                         );

            iConfigurationSettingsMock.Expects.One.
            MethodWith(_ => _.GetSettingsByKey("inputQueue")).
            Will(Return.Value("foo"));
            iConfigurationSettingsMock.Expects.One.
            MethodWith(_ => _.GetSettingsByKey("outputQueue")).
            Will(Return.Value("bar"));

            iMessagingFacilityMock.Expects.One.
            MethodWith(_ => _.InitializeInputChannel("foo"));
            iMessagingFacilityMock.Expects.One.
            MethodWith(_ => _.InitializeOutputChannel("bar"));

            worker.Start();
        }
Exemplo n.º 2
0
        public void doJobShouldThrowNullReferenceException()
        {
            var iExceptionHandlerMock = factory.CreateMock <IExceptionHandler>();

            var worker = new WorkerImpl
                         (
                null,
                null,
                iExceptionHandlerMock.MockObject,
                null
                         );

            iExceptionHandlerMock.Expects.One.
            Method(_ => _.HandleException(null)).
            With(Is.TypeOf <NullReferenceException>());

            worker.DoJob();
        }
Exemplo n.º 3
0
        public void stopShouldDisposeMessagingFacility()
        {
            var iConfigurationSettingsMock = factory.CreateMock <IConfigurationSettings>();
            var iMessagingFacilityMock     = factory.CreateMock <IMessagingFacility <Invoice, ProcessingResult> >();
            var iExceptionHandlerMock      = factory.CreateMock <IExceptionHandler>();
            var iInvoiceProcessorMock      = factory.CreateMock <IInvoiceProcessor>();

            var worker = new WorkerImpl
                         (
                iConfigurationSettingsMock.MockObject,
                iMessagingFacilityMock.MockObject,
                iExceptionHandlerMock.MockObject,
                iInvoiceProcessorMock.MockObject
                         );

            iMessagingFacilityMock.Expects.One.
            Method(_ => _.Dispose());

            worker.Stop();
        }