示例#1
0
        public void TestArgumentFields()
        {
            using (MockCommandLine command = new MockCommandLine())
            {
                CommandLineExternal external = new CommandLineExternal();
                external.Command   = command.ScriptFilename;
                external.Arguments = "$$ \"$filename$\"";

                using (MockDicomPresentationImage image = new MockDicomPresentationImage())
                {
                    Assert.IsFalse(external.CanLaunch(image), "Fields are case sensitive - unresolved field should fail the launch");

                    external.Arguments = "$$ \"$FILENAME$\"";

                    Assert.IsTrue(external.CanLaunch(image), "Fields are case sensitive - unresolved field should fail the launch");

                    external.Launch(image);

                    Thread.Sleep(_processEndWaitDelay);                     // wait for the external to finish
                    command.Refresh();

                    Trace.WriteLine(string.Format("Command Execution Report"));
                    Trace.WriteLine(command.ExecutionReport);

                    AssertAreEqualIgnoreCase("$", command.ExecutedArguments[0], "Wrong argument passed at index {0}", 0);

                    // these file paths may or may not have spaces in them, but we don't care either way for this test
                    AssertAreEqualIgnoreCase(image.Filename, command.ExecutedArguments[1].Trim('"'), "Wrong argument passed at index {0}", 1);
                }
            }
        }
示例#2
0
        public void TestBasic()
        {
            string workingDirectory = Environment.CurrentDirectory;

            using (MockCommandLine command = new MockCommandLine())
            {
                CommandLineExternal external = new CommandLineExternal();
                external.Command = command.ScriptFilename;

                Assert.IsTrue(external.IsValid, "Minimum parameters for Command Line External should be just the command itself");

                using (MockDicomPresentationImage image = new MockDicomPresentationImage())
                {
                    Assert.IsTrue(external.CanLaunch(image), "Check that external can launch the dummy image");

                    external.Launch(image);

                    Thread.Sleep(_processEndWaitDelay);                     // wait for the external to finish
                    command.Refresh();

                    Trace.WriteLine(string.Format("Command Execution Report"));
                    Trace.WriteLine(command.ExecutionReport);

                    AssertAreEqualIgnoreCase(external.Command, command.ExecutedCommand, "Wrong command was executed");
                    AssertAreEqualIgnoreCase(workingDirectory, command.ExecutedWorkingDirectory, "Command executed in wrong working directory.");
                }
            }
        }
示例#3
0
		public void TestBasic()
		{
			string workingDirectory = Environment.CurrentDirectory;
			using (MockCommandLine command = new MockCommandLine())
			{
				CommandLineExternal external = new CommandLineExternal();
				external.Command = command.ScriptFilename;

				Assert.IsTrue(external.IsValid, "Minimum parameters for Command Line External should be just the command itself");

				using (MockDicomPresentationImage image = new MockDicomPresentationImage())
				{
					Assert.IsTrue(external.CanLaunch(image), "Check that external can launch the dummy image");

					external.Launch(image);

					Thread.Sleep(_processEndWaitDelay); // wait for the external to finish
					command.Refresh();

					Trace.WriteLine(string.Format("Command Execution Report"));
					Trace.WriteLine(command.ExecutionReport);

					AssertAreEqualIgnoreCase(external.Command, command.ExecutedCommand, "Wrong command was executed");
					AssertAreEqualIgnoreCase(workingDirectory, command.ExecutedWorkingDirectory, "Command executed in wrong working directory.");
				}
			}
		}
示例#4
0
        public void TestDicomFieldsWithMultipleImages()
        {
            using (MockCommandLine command = new MockCommandLine())
            {
                CommandLineExternal external = new CommandLineExternal();
                external.Command = command.ScriptFilename;
                external.AllowMultiValueFields    = true;
                external.MultiValueFieldSeparator = " ";
                external.Arguments = "\"$00100020$\" \"$00100021$\"";

                using (MockDicomPresentationImage image = new MockDicomPresentationImage())
                {
                    using (MockDicomPresentationImage otherImage = new MockDicomPresentationImage())
                    {
                        using (MockDicomPresentationImage thirdImage = new MockDicomPresentationImage())
                        {
                            using (MockDicomPresentationImage fourthImage = new MockDicomPresentationImage())
                            {
                                using (MockDicomPresentationImage anotherImage = new MockDicomPresentationImage())
                                {
                                    image[0x00100020].SetStringValue("The cake is a lie");
                                    otherImage[0x00100020].SetStringValue("The cake is a lie");
                                    thirdImage[0x00100020].SetStringValue("The cake is a lie");
                                    fourthImage[0x00100020].SetStringValue("The cake is a lie");
                                    anotherImage[0x00100020].SetStringValue("The cake is a lie");

                                    image[0x00100021].SetStringValue("Look, my liege!");
                                    otherImage[0x00100021].SetStringValue("Camelot!");
                                    thirdImage[0x00100021].SetStringValue("Camelot!");
                                    fourthImage[0x00100021].SetStringValue("Camelot!");
                                    anotherImage[0x00100021].SetStringValue("It's only a model");

                                    IPresentationImage[] images = new IPresentationImage[] { image, otherImage, thirdImage, fourthImage, anotherImage };
                                    Assert.IsTrue(external.CanLaunch(images));
                                    external.Launch(images);

                                    Thread.Sleep(_processEndWaitDelay);                                     // wait for the external to finish
                                    command.Refresh();

                                    Trace.WriteLine(string.Format("Command Execution Report"));
                                    Trace.WriteLine(command.ExecutionReport);

                                    // these file paths may or may not have spaces in them, but we don't care either way for this test
                                    Assert.AreEqual("\"The cake is a lie\"", command.ExecutedArguments[0], "Wrong argument for 00100020 field of first image");
                                    Assert.AreEqual("\"Look, my liege!\"", command.ExecutedArguments[1], "Wrong argument for 00100021 field of first image");
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        public void TestSingleImage()
        {
            using (MockCommandLine command = new MockCommandLine())
            {
                CommandLineExternal external = new CommandLineExternal();
                external.Command = command.ScriptFilename;
                external.AllowMultiValueFields = false;
                external.Arguments             = "\"$FILENAME$\" \"$DIRECTORY$\" \"$EXTENSIONONLY$\" \"$FILENAMEONLY$\" \"$00100020$\" \"$00100021$\"";

                using (MockDicomPresentationImage image = new MockDicomPresentationImage())
                {
                    using (MockDicomPresentationImage otherImage = new MockDicomPresentationImage())
                    {
                        image[0x00100020].SetStringValue("I've got a lovely bunch of coconuts");
                        image[0x00100021].SetStringValue("Here they are all standing in a row");
                        otherImage[0x00100020].SetStringValue("Big ones, small ones, some as big as your head");

                        Assert.IsFalse(external.CanLaunch(new IPresentationImage[] { image, otherImage }));
                        Assert.IsTrue(external.CanLaunch(image));

                        external.Launch(image);

                        Thread.Sleep(_processEndWaitDelay);                         // wait for the external to finish
                        command.Refresh();

                        Trace.WriteLine(string.Format("Command Execution Report"));
                        Trace.WriteLine(command.ExecutionReport);

                        // these file paths may or may not have spaces in them, but we don't care either way for this test
                        AssertAreEqualIgnoreCase(image.Filename, command.ExecutedArguments[0].Trim('"'), "Wrong argument for filename field");
                        AssertAreEqualIgnoreCase(Path.GetDirectoryName(image.Filename), command.ExecutedArguments[1].Trim('"'), "Wrong argument for directory field");
                        AssertAreEqualIgnoreCase(Path.GetExtension(image.Filename), command.ExecutedArguments[2].Trim('"'), "Wrong argument for extension field");
                        AssertAreEqualIgnoreCase(Path.GetFileName(image.Filename), command.ExecutedArguments[3].Trim('"'), "Wrong argument for filename only field");
                        Assert.AreEqual("I've got a lovely bunch of coconuts", command.ExecutedArguments[4].Trim('"'), "Wrong argument for 00100020 field");
                        Assert.AreEqual("Here they are all standing in a row", command.ExecutedArguments[5].Trim('"'), "Wrong argument for 00100021 field");
                    }
                }
            }
        }
示例#6
0
        public void TestMultipleImages()
        {
            using (MockCommandLine command = new MockCommandLine())
            {
                CommandLineExternal external = new CommandLineExternal();
                external.Command = command.ScriptFilename;
                external.AllowMultiValueFields    = true;
                external.MultiValueFieldSeparator = "\" \"";
                external.Arguments = "\"$FILENAME$\" \"$DIRECTORY$\" \"$EXTENSIONONLY$\" \"$FILENAMEONLY$\"";

                using (MockDicomPresentationImage image = new MockDicomPresentationImage())
                {
                    using (MockDicomPresentationImage otherImage = new MockDicomPresentationImage())
                    {
                        using (MockDicomPresentationImage thirdImage = new MockDicomPresentationImage())
                        {
                            IPresentationImage[] images = new IPresentationImage[] { image, otherImage, thirdImage };
                            Assert.IsTrue(external.CanLaunch(images));
                            external.Launch(images);

                            Thread.Sleep(_processEndWaitDelay);                             // wait for the external to finish
                            command.Refresh();

                            Trace.WriteLine(string.Format("Command Execution Report"));
                            Trace.WriteLine(command.ExecutionReport);

                            // these file paths may or may not have spaces in them, but we don't care either way for this test
                            AssertAreEqualIgnoreCase(image.Filename, command.ExecutedArguments[0].Replace("\"", ""), "Wrong argument for 1st filename field");
                            AssertAreEqualIgnoreCase(otherImage.Filename, command.ExecutedArguments[1].Replace("\"", ""), "Wrong argument for 2nd filename field");
                            AssertAreEqualIgnoreCase(thirdImage.Filename, command.ExecutedArguments[2].Replace("\"", ""), "Wrong argument for 3rd filename field");
                            AssertAreEqualIgnoreCase(Path.GetDirectoryName(image.Filename), command.ExecutedArguments[3].Replace("\"", ""), "Wrong argument for directory field");
                            AssertAreEqualIgnoreCase(Path.GetExtension(image.Filename), command.ExecutedArguments[4].Replace("\"", ""), "Wrong argument for extension field");
                            AssertAreEqualIgnoreCase(Path.GetFileName(image.Filename), command.ExecutedArguments[5].Replace("\"", ""), "Wrong argument for 1st filename only field");
                            AssertAreEqualIgnoreCase(Path.GetFileName(otherImage.Filename), command.ExecutedArguments[6].Replace("\"", ""), "Wrong argument for 2nd filename only field");
                            AssertAreEqualIgnoreCase(Path.GetFileName(thirdImage.Filename), command.ExecutedArguments[7].Replace("\"", ""), "Wrong argument for 3rd filename only field");
                        }
                    }
                }
            }
        }
示例#7
0
		public void TestDicomFieldsWithMultipleImages()
		{
			using (MockCommandLine command = new MockCommandLine())
			{
				CommandLineExternal external = new CommandLineExternal();
				external.Command = command.ScriptFilename;
				external.AllowMultiValueFields = true;
				external.MultiValueFieldSeparator = " ";
				external.Arguments = "\"$00100020$\" \"$00100021$\"";

				using (MockDicomPresentationImage image = new MockDicomPresentationImage())
				{
					using (MockDicomPresentationImage otherImage = new MockDicomPresentationImage())
					{
						using (MockDicomPresentationImage thirdImage = new MockDicomPresentationImage())
						{
							using (MockDicomPresentationImage fourthImage = new MockDicomPresentationImage())
							{
								using (MockDicomPresentationImage anotherImage = new MockDicomPresentationImage())
								{
									image[0x00100020].SetStringValue("The cake is a lie");
									otherImage[0x00100020].SetStringValue("The cake is a lie");
									thirdImage[0x00100020].SetStringValue("The cake is a lie");
									fourthImage[0x00100020].SetStringValue("The cake is a lie");
									anotherImage[0x00100020].SetStringValue("The cake is a lie");

									image[0x00100021].SetStringValue("Look, my liege!");
									otherImage[0x00100021].SetStringValue("Camelot!");
									thirdImage[0x00100021].SetStringValue("Camelot!");
									fourthImage[0x00100021].SetStringValue("Camelot!");
									anotherImage[0x00100021].SetStringValue("It's only a model");

									IPresentationImage[] images = new IPresentationImage[] {image, otherImage, thirdImage, fourthImage, anotherImage};
									Assert.IsTrue(external.CanLaunch(images));
									external.Launch(images);

									Thread.Sleep(_processEndWaitDelay); // wait for the external to finish
									command.Refresh();

									Trace.WriteLine(string.Format("Command Execution Report"));
									Trace.WriteLine(command.ExecutionReport);

									// these file paths may or may not have spaces in them, but we don't care either way for this test
									Assert.AreEqual("\"The cake is a lie\"", command.ExecutedArguments[0], "Wrong argument for 00100020 field of first image");
									Assert.AreEqual("\"Look, my liege!\"", command.ExecutedArguments[1], "Wrong argument for 00100021 field of first image");
								}
							}
						}
					}
				}
			}
		}
示例#8
0
		public void TestMultipleImages()
		{
			using (MockCommandLine command = new MockCommandLine())
			{
				CommandLineExternal external = new CommandLineExternal();
				external.Command = command.ScriptFilename;
				external.AllowMultiValueFields = true;
				external.MultiValueFieldSeparator = "\" \"";
				external.Arguments = "\"$FILENAME$\" \"$DIRECTORY$\" \"$EXTENSIONONLY$\" \"$FILENAMEONLY$\"";

				using (MockDicomPresentationImage image = new MockDicomPresentationImage())
				{
					using (MockDicomPresentationImage otherImage = new MockDicomPresentationImage())
					{
						using (MockDicomPresentationImage thirdImage = new MockDicomPresentationImage())
						{
							IPresentationImage[] images = new IPresentationImage[] {image, otherImage, thirdImage};
							Assert.IsTrue(external.CanLaunch(images));
							external.Launch(images);

							Thread.Sleep(_processEndWaitDelay); // wait for the external to finish
							command.Refresh();

							Trace.WriteLine(string.Format("Command Execution Report"));
							Trace.WriteLine(command.ExecutionReport);

							// these file paths may or may not have spaces in them, but we don't care either way for this test
							AssertAreEqualIgnoreCase(image.Filename, command.ExecutedArguments[0].Replace("\"", ""), "Wrong argument for 1st filename field");
							AssertAreEqualIgnoreCase(otherImage.Filename, command.ExecutedArguments[1].Replace("\"", ""), "Wrong argument for 2nd filename field");
							AssertAreEqualIgnoreCase(thirdImage.Filename, command.ExecutedArguments[2].Replace("\"", ""), "Wrong argument for 3rd filename field");
							AssertAreEqualIgnoreCase(Path.GetDirectoryName(image.Filename), command.ExecutedArguments[3].Replace("\"", ""), "Wrong argument for directory field");
							AssertAreEqualIgnoreCase(Path.GetExtension(image.Filename), command.ExecutedArguments[4].Replace("\"", ""), "Wrong argument for extension field");
							AssertAreEqualIgnoreCase(Path.GetFileName(image.Filename), command.ExecutedArguments[5].Replace("\"", ""), "Wrong argument for 1st filename only field");
							AssertAreEqualIgnoreCase(Path.GetFileName(otherImage.Filename), command.ExecutedArguments[6].Replace("\"", ""), "Wrong argument for 2nd filename only field");
							AssertAreEqualIgnoreCase(Path.GetFileName(thirdImage.Filename), command.ExecutedArguments[7].Replace("\"", ""), "Wrong argument for 3rd filename only field");
						}
					}
				}
			}
		}
示例#9
0
		public void TestSingleImage()
		{
			using (MockCommandLine command = new MockCommandLine())
			{
				CommandLineExternal external = new CommandLineExternal();
				external.Command = command.ScriptFilename;
				external.AllowMultiValueFields = false;
				external.Arguments = "\"$FILENAME$\" \"$DIRECTORY$\" \"$EXTENSIONONLY$\" \"$FILENAMEONLY$\" \"$00100020$\" \"$00100021$\"";

				using (MockDicomPresentationImage image = new MockDicomPresentationImage())
				{
					using (MockDicomPresentationImage otherImage = new MockDicomPresentationImage())
					{
						image[0x00100020].SetStringValue("I've got a lovely bunch of coconuts");
						image[0x00100021].SetStringValue("Here they are all standing in a row");
						otherImage[0x00100020].SetStringValue("Big ones, small ones, some as big as your head");

						Assert.IsFalse(external.CanLaunch(new IPresentationImage[] {image, otherImage}));
						Assert.IsTrue(external.CanLaunch(image));

						external.Launch(image);

						Thread.Sleep(_processEndWaitDelay); // wait for the external to finish
						command.Refresh();

						Trace.WriteLine(string.Format("Command Execution Report"));
						Trace.WriteLine(command.ExecutionReport);

						// these file paths may or may not have spaces in them, but we don't care either way for this test
						AssertAreEqualIgnoreCase(image.Filename, command.ExecutedArguments[0].Trim('"'), "Wrong argument for filename field");
						AssertAreEqualIgnoreCase(Path.GetDirectoryName(image.Filename), command.ExecutedArguments[1].Trim('"'), "Wrong argument for directory field");
						AssertAreEqualIgnoreCase(Path.GetExtension(image.Filename), command.ExecutedArguments[2].Trim('"'), "Wrong argument for extension field");
						AssertAreEqualIgnoreCase(Path.GetFileName(image.Filename), command.ExecutedArguments[3].Trim('"'), "Wrong argument for filename only field");
						Assert.AreEqual("I've got a lovely bunch of coconuts", command.ExecutedArguments[4].Trim('"'), "Wrong argument for 00100020 field");
						Assert.AreEqual("Here they are all standing in a row", command.ExecutedArguments[5].Trim('"'), "Wrong argument for 00100021 field");
					}
				}
			}
		}
示例#10
0
		public void TestArgumentFields()
		{
			using (MockCommandLine command = new MockCommandLine())
			{
				CommandLineExternal external = new CommandLineExternal();
				external.Command = command.ScriptFilename;
				external.Arguments = "$$ \"$filename$\"";

				using (MockDicomPresentationImage image = new MockDicomPresentationImage())
				{
					Assert.IsFalse(external.CanLaunch(image), "Fields are case sensitive - unresolved field should fail the launch");

					external.Arguments = "$$ \"$FILENAME$\"";

					Assert.IsTrue(external.CanLaunch(image), "Fields are case sensitive - unresolved field should fail the launch");

					external.Launch(image);

					Thread.Sleep(_processEndWaitDelay); // wait for the external to finish
					command.Refresh();

					Trace.WriteLine(string.Format("Command Execution Report"));
					Trace.WriteLine(command.ExecutionReport);

					AssertAreEqualIgnoreCase("$", command.ExecutedArguments[0], "Wrong argument passed at index {0}", 0);

					// these file paths may or may not have spaces in them, but we don't care either way for this test
					AssertAreEqualIgnoreCase(image.Filename, command.ExecutedArguments[1].Trim('"'), "Wrong argument passed at index {0}", 1);
				}
			}
		}