Exemple #1
0
        public void OnPremiseResponseReceiver_ReceiveResponse_FaultMessage()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            AzureResponseReceiver receiver = new AzureResponseReceiver(dispatcher);

            Message emptyMessage = Message.CreateMessage(MessageVersion.Default, string.Empty);

            MessageFault fault = MessageFault.CreateFault(FaultCode.CreateReceiverFaultCode("Error", Constant.HpcHeaderNS), string.Empty);

            DispatchData data = new DispatchData("1", 0, "1")
            {
                BrokerQueueItem = new BrokerQueueItem(null, emptyMessage, null),

                Client = new MockClient()
                {
                    Response = Message.CreateMessage(MessageVersion.Default, fault, string.Empty)
                }
            };

            receiver.ReceiveResponse(data);

            Assert.AreEqual(data.Exception, null, "Exception is not expected to happen in ReceiveResponse method.");

            Assert.AreEqual(data.ReplyMessage.IsFault, true, "Expected to receive fault message ReceiveResponse method.");
        }
Exemple #2
0
        public void OnPremiseResponseReceiver_ReceiveResponse_PreemptionMessage()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            AzureResponseReceiver receiver = new AzureResponseReceiver(dispatcher);

            Message emptyMessage = Message.CreateMessage(MessageVersion.Default, string.Empty);

            Message preemption = Message.CreateMessage(MessageVersion.Default, Constant.HpcHeaderNS);

            preemption.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderPreemption, Constant.HpcHeaderNS, 1));

            DispatchData data = new DispatchData("1", 0, "1")
            {
                BrokerQueueItem = new BrokerQueueItem(null, emptyMessage, null),

                Client = new MockClient()
                {
                    Response = preemption
                }
            };

            receiver.ReceiveResponse(data);

            Assert.AreEqual(data.Exception, null, "Exception is not expected to happen in ReceiveResponse method.");

            Assert.AreEqual(data.ReplyMessage.IsFault, false, "Expected to receive non-fault message ReceiveResponse method.");

            Assert.AreEqual(data.ServicePreempted, true, "Expected to get ServicePreemption notice.");
        }
Exemple #3
0
        public void OnPremiseResponseReceiver_ReceiveResponse_Exception()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            AzureResponseReceiver receiver = new AzureResponseReceiver(dispatcher);

            Message emptyMessage = Message.CreateMessage(MessageVersion.Default, string.Empty);

            DispatchData data = new DispatchData("1", 0, "1")
            {
                BrokerQueueItem = new BrokerQueueItem(null, emptyMessage, null),

                Client = new MockClient()
                {
                    Action = delegate()
                    {
                        throw new EndpointNotFoundException();
                    }
                }
            };

            receiver.ReceiveResponse(data);

            Assert.AreEqual(
                data.Exception.GetType(),
                typeof(EndpointNotFoundException),
                "EndpointNotFoundException is expected to happen in ReceiveResponse method.");
        }