Consecutive calls on the same send port problem?

Developer
Aug 21, 2009 at 8:18 PM

Maybe it is a problem, maybe this is my misunderstanding of the framework. Here is the case:

I modified the sample to add an second operation (that returns a different type) on the weather service and I do two consecutive calls, one on each operation. I received an error in Biztalk saying that the first operation type is returned when I call the second operation. Does somebody ever tried it?

Here is my test:

[TestMethod]

[DeploymentItem("FileInstances")]

public void OrchestrationTest()

{

Expectation.WeatherServiceRequest.City = "Barcelona";

Expectation.Response.Report = "partially cloudy";

Expectation.Response.City = "Barcelona";

At.ReceiveLocation(Port.InboundPort).Send(FileInstance.Request.ChangePostalCodeTo("08001")).Then

(

At.SolicitResponsePort(Port.WeatherService).Expect.One.MessageLike(Expectation.WeatherServiceRequest).Then

(

At.SolicitResponsePort(Port.WeatherService).Return(FileInstance.WeatherServiceResp.ChangeWeatherReportTo("partially cloudy")).Then

(

At.SolicitResponsePort(Port.WeatherService).Expect.One.MessageLike(Expectation.WeatherServiceRequest).Then

(

At.SolicitResponsePort(Port.WeatherService).Return(FileInstance.WeatherServiceResp2.ChangeWeatherReportTo("partially cloudy")).Then

(

At.SendPort( Port.Outbound ).Expect.One.MessageLike( Expectation.Response ),

At.EventLog( EventLog.BizMock ).Expect.Nothing

)

)

)

)

).Execute();

string errors;

Assert.IsTrue( BizMockery.Instance.VerifyAllExpectationsHaveBeenMet(10, out errors), errors );

}

 

<font size="2">

 

</font>

 

 

 

 Thanks

 

 

Coordinator
Aug 27, 2009 at 9:26 AM

Actually you found a bug in the transmitter, that I have just resolved.
The problem was that when using more than one operation, the transmitter was taking the first operation response twice.

Thank you for the feedback

Developer
Aug 28, 2009 at 2:52 PM

I've just tried the latest version and it worked great.

 

Thanks a lot for the quick resolution!

Developer
Sep 3, 2009 at 2:17 PM

After more tests, I found some strange behavior with the 25166 version.  The bug in the transmitter is effectively fixed but I have problems when I run multiple tests in row (multiple TestFixture). I do not have the same result everytime I run my tests. It is always timeouts that expire when looking for request file. If I re-run the tests that failed individually they pass.  When I re-install the previous version I have everything works fine (except for the tests where I call multiple operation on the same port obiviously).

One thing I do between each test is to cleanup the remaining instances and I restart the orchestration that is currently tested.

I'm sorry to not have more details for the moment.  Maybe you have an idea why this could happen.

 

Thanks

Coordinator
Sep 4, 2009 at 9:39 AM

Have you test code initilization code like this in all your test classes?

[TestInitialize()]

public void MyTestInitialize()

{

BizMockery.Reset();

Artifact.Reset();

}

You can override the Artifact .Reset method to reset your artifact default values in case in you test you have modified them, like in the weatherreport sample.

Developer
Sep 4, 2009 at 1:37 PM

Yes I do resest my expectations. And it was working well with the previous version ...

Here is my tests init/finalize code:

 

       [TestFixtureSetUp]
        public void Setup()
        {
            BiztalkHelper.StopAllOrchestrations();
            BiztalkHelper.DeleteAllInstances();
            var orchestrations = new ArrayList { _orchestrationName };
            BiztalkHelper.StartOrchestration(orchestrations);

        }

        [TestFixtureTearDown]
        public void Cleanup()
        {
            BiztalkHelper.DeleteAllInstances();
            BiztalkHelper.StopAllOrchestrations();

            ArtifactsHelper.TryDeleteTempFiles();
        }

        [SetUp]
        public void TestSetup()
        {
            
            Expectation.Reset();
            BizMockery.Reset();

        }
        
        [TearDown]
        public void TestTeardown()
        {
            BiztalkHelper.DeleteAllInstances();
            BiztalkHelper.StopAllOrchestrations();
            ArtifactsHelper.TryDeleteTempFiles();
            var orchestrations = new ArrayList { _orchestrationName };
            BiztalkHelper.StartOrchestration(orchestrations);
            
        }

Coordinator
Sep 7, 2009 at 8:35 AM

I did reproduce the behavior you mention, but once a call the BizMockery.Reset method before each call all tests pass. Do you have a sample solution to reproduce this behavior, so i can test it on my machine?

Do you want  I add you as contributor?

Developer
Sep 8, 2009 at 7:48 PM

First, I tried with the latest version and I found some obvious mistake I did using wrong schema type in my Expectations. But it was not the source of the error. I'm still reproducing it. 

I think the way my tests are designed can be the cause. I'm using an Internal schema in my orchestrations with inbound/outbound maps in the ports. I also use a lot of direct port that listen the message box for those Internal types. In my tests, I use only the Internal types (I removed the maps in my tests bindings) and I have some situations where a loop is created because the message type that is send to a port is the same as the orchestration is listening (because I removed the maps in the ports).

Then, I kill all instances remainning after each test. Maybe the Bizmock adapter is left in a unknown state. I realized that this is always the same tests that failed when I run them in batch.

I'll try to create a sample solution with that kind of behavior.

Yes you can add me as a contributor, thanks for asking.