I have code that I want to test that looks similar to this:
I want to test this method, but I am getting stuck when I try to return an object when the static method is called. Here is the test method:
The last assert statement always returns an error saying that 2000999 does not equal 0. Which implies that the Job property is not getting set the the new instance I am trying to return in the Arrange section.
What am I doing wrong? Is this something that can't be done as it is written? Please help, I am new to the JustMock framework.
01.public class Manager02.{03. public Job Job {get;set;}04. 05. public void RunCompleteJob(int arg1, int arg2, int arg3, string arg4) 06. {07. Job = MyStaticClass.CreateCompleteJob(arg1, arg2, arg3, arg4);08. Job.Submit();09. ExecuteJobStates();10. }11.}I want to test this method, but I am getting stuck when I try to return an object when the static method is called. Here is the test method:
01.[Test]02.public void RunCompleteJob_Success()03.{04. var arg1 = 2000999;05. var arg2 = 12345;06. var arg3 = 9999;07. var arg4 = "filepath;08. 09. var manager = Mock.Create<Manager>(Behavior.CallOriginal);10. Mock.SetupStatic(typeof(MyStaticClass), Behavior.Strict, StaticConstructor.Mocked);11. Mock.Arrange(() => MyStaticClass.CreateCompleteJob(arg1, arg2, arg3, arg4))12. .Returns(new Job13. {14. JobProcessTypeParameters = new JobParameters(),15. JobType = JobType.Complete,16. MediaId = arg117. });18. Mock.Arrange(() => manager.Job.Submit()).MustBeCalled();19. Mock.NonPublic.Arrange(manager, "ExecuteJobStates").MustBeCalled();20. 21. manager.RunCompleteJob(arg1, arg2, arg3, arg4);22. 23. Mock.Assert(manager);24. Assert.AreEqual(arg1, manager.Job.MediaId);25.}The last assert statement always returns an error saying that 2000999 does not equal 0. Which implies that the Job property is not getting set the the new instance I am trying to return in the Arrange section.
What am I doing wrong? Is this something that can't be done as it is written? Please help, I am new to the JustMock framework.
