Beispiel #1
0
        public void TestSetup()
        {
            AppContext = new TraceLabTestApplication(TestContext);

            //set current location
            currentLocation = AppContext.BaseTestDirectory;

            //create config definition using createwrapper method of the ComponentMetadataDefinition class
            var configDef = ComponentScannerHelper_Accessor.CreateConfigWrapperDefinition(typeof(MockConfig));

            testConfig = new ConfigWrapper(configDef);

            //set the values of MockConfig
            mockFileAbsolutePath = Path.Combine(currentLocation, mockFile);
            Stream file = File.Create(mockFileAbsolutePath);

            file.Close(); //close file so that it is not being used by this process anymore

            configFilePath = new FilePath();
            configFilePath.Init(mockFileAbsolutePath, currentLocation);
            //the key matches property name in the MockConfig
            testConfig.ConfigValues["MockFile"].Value = configFilePath;

            mockDirAbsolutePath = Path.Combine(currentLocation, mockDir);
            Directory.CreateDirectory(mockDirAbsolutePath);
            Assert.IsTrue(Directory.Exists(mockDirAbsolutePath));

            configDirPath = new DirectoryPath();
            configDirPath.Init(mockDirAbsolutePath, currentLocation);
            //the key matches property name in the MockConfig
            testConfig.ConfigValues["MockDirectory"].Value = configDirPath;
        }
        public void CreateComponentIdTestNullFailure()
        {
            string                  componentName          = null;
            IOSpecDefinition        componentIOSpec        = null;
            string                  version                = null;
            ConfigWrapperDefinition componentConfiguration = null;

            //should throw exception, as there has to be at least name provided that is not null
            string id = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);
        }
        public void CreateComponentIdTestNameAndVersion()
        {
            string                  componentName          = "Mock component";
            IOSpecDefinition        componentIOSpec        = null;
            string                  version                = "1.0";
            ConfigWrapperDefinition componentConfiguration = null;

            string id = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            //repeat with the same data - ids should be the same
            string id2 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            Assert.AreEqual(id, id2);

            //change version
            version = "2.0";
            string id3 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            Assert.AreNotEqual(id, id3);
        }
        public void CreateComponentIdTestIOSpec()
        {
            string           componentName   = "Mock component";
            IOSpecDefinition componentIOSpec = new IOSpecDefinition();

            componentIOSpec.Input.Add("mockinput", new IOItemDefinition("mockinput", "mocktype", "mockdescription", TraceLabSDK.IOSpecType.Input));
            componentIOSpec.Output.Add("mockoutput", new IOItemDefinition("mockoutput", "mocktype", "mockdescription", TraceLabSDK.IOSpecType.Output));

            string version = "1.0";
            ConfigWrapperDefinition componentConfiguration = null;

            string id = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            //repeat with the same data - ids should be the same
            string id2 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            Assert.AreEqual(id, id2);

            //copy original iospec and add input to it
            IOSpecDefinition componentIOSpec2 = new IOSpecDefinition(componentIOSpec);

            componentIOSpec2.Input.Add("mockinput2", new IOItemDefinition("mockinput2", "mock.type", "mockdescription", TraceLabSDK.IOSpecType.Input));
            string id3 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec2, version, componentConfiguration);

            Assert.AreNotEqual(id, id3);

            //copy original iospec and add output to it
            IOSpecDefinition componentIOSpec3 = new IOSpecDefinition(componentIOSpec);

            componentIOSpec3.Output.Add("mockoutput2", new IOItemDefinition("mockoutput2", "mock.type", "mockdescription", TraceLabSDK.IOSpecType.Output));
            string id4 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec3, version, componentConfiguration);

            Assert.AreNotEqual(id, id4);

            //finally compare with empty iospec
            IOSpecDefinition componentIOSpec5 = new IOSpecDefinition();
            string           id6 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec5, version, componentConfiguration);

            Assert.AreNotEqual(id, id6);
        }
        public void CreateComponentIdTestConfig()
        {
            string           componentName   = "Mock component";
            IOSpecDefinition componentIOSpec = null;
            string           version         = "1.0";

            //create config definition using createwrapper method of the ComponentMetadataDefinition class
            ConfigWrapperDefinition componentConfiguration = ComponentScannerHelper_Accessor.CreateConfigWrapperDefinition(typeof(MockConfig));

            string id = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            //repeat with the same data - ids should be the same
            string id2 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            Assert.AreEqual(id, id2);

            //change configuration
            componentConfiguration = ComponentScannerHelper_Accessor.CreateConfigWrapperDefinition(typeof(MockConfigWithAdditionalProperty));
            string id3 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration);

            Assert.AreNotEqual(id, id3);
        }