Exemple #1
0
        public void SetWorkFlowMappingSameValues()
        {
            m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress, true);
            m_Utils.ActivateContext(0);

            GetStatusMappingsResponse getResp = m_Utils.GetStatusMappings(0, StackHashMappingType.WorkFlow);

            Assert.AreEqual(StackHashMappingType.WorkFlow, getResp.MappingType);
            Assert.AreEqual(16, getResp.StatusMappings.Count);

            SetStatusMappingsResponse setResp = m_Utils.SetStatusMappings(0, StackHashMappingType.WorkFlow, getResp.StatusMappings);

            Assert.AreEqual(StackHashMappingType.WorkFlow, setResp.MappingType);

            GetStatusMappingsResponse getResp2 = m_Utils.GetStatusMappings(0, StackHashMappingType.WorkFlow);

            Assert.AreEqual(StackHashMappingType.WorkFlow, getResp2.MappingType);
            Assert.AreEqual(16, getResp2.StatusMappings.Count);

            foreach (StackHashMapping mapping in getResp.StatusMappings)
            {
                StackHashMapping matchMapping = findMapping(getResp2.StatusMappings, mapping.MappingType, mapping.Id);
                Assert.AreNotEqual(null, matchMapping);

                Assert.AreEqual(mapping.MappingType, matchMapping.MappingType);
                Assert.AreEqual(mapping.Id, matchMapping.Id);
                Assert.AreEqual(mapping.Name, matchMapping.Name);
            }
        }
Exemple #2
0
        public void SetGroupNotImplemented()
        {
            m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress, true);
            m_Utils.ActivateContext(0);

            GetStatusMappingsResponse resp = m_Utils.GetStatusMappings(0, StackHashMappingType.Group);

            Assert.AreEqual(StackHashMappingType.Group, resp.MappingType);
            Assert.AreEqual(0, resp.StatusMappings.Count);

            StackHashMapping mapping = new StackHashMapping();

            mapping.MappingType = StackHashMappingType.Group;
            mapping.Id          = 0;
            mapping.Name        = "Hello";

            resp.StatusMappings.Add(mapping);
            try
            {
                SetStatusMappingsResponse setResp = m_Utils.SetStatusMappings(0, StackHashMappingType.Group, resp.StatusMappings);
            }
            catch (FaultException <ReceiverFaultDetail> ex)
            {
                Assert.AreEqual(true, ex.Detail.Message.Contains("Groups are not currently implemented"));
                throw;
            }
        }
Exemple #3
0
        public void SetMappingMixedTypes()
        {
            m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress, true);
            m_Utils.ActivateContext(0);

            GetStatusMappingsResponse resp = m_Utils.GetStatusMappings(0, StackHashMappingType.WorkFlow);

            Assert.AreEqual(StackHashMappingType.WorkFlow, resp.MappingType);
            Assert.AreEqual(16, resp.StatusMappings.Count);

            StackHashMapping mapping = new StackHashMapping();

            mapping.Id          = 12;
            mapping.MappingType = StackHashMappingType.WorkFlow;
            mapping.Name        = "Fred";

            resp.StatusMappings.Add(mapping);

            try
            {
                SetStatusMappingsResponse setResp = m_Utils.SetStatusMappings(0, StackHashMappingType.Group, resp.StatusMappings);
            }
            catch (FaultException <ReceiverFaultDetail> ex)
            {
                Assert.AreEqual(true, ex.Detail.Message.Contains("Mapping types don't match"));
                throw;
            }
        }
Exemple #4
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// Adds the specified number of Mappings to the MappingsTable.
        /// </summary>
        public void addMappings(StackHashMappingType mappingType, StackHashMappingCollection mappings, int expectedCount)
        {
            // Create a clean index.
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            StackHashMappingCollection currentMappings = m_Index.GetMappings(mappingType);

            if (mappingType == StackHashMappingType.WorkFlow)
            {
                Assert.AreEqual(16, currentMappings.Count);
            }
            else
            {
                Assert.AreEqual(0, currentMappings.Count);
            }

            m_Index.AddMappings(mappings);

            currentMappings = m_Index.GetMappings(mappingType);
            Assert.AreEqual(expectedCount, currentMappings.Count);


            foreach (StackHashMapping mapping in mappings)
            {
                StackHashMapping matchingMapping = mappings.FindMapping(mapping.MappingType, mapping.Id);
                Assert.AreNotEqual(null, matchingMapping);

                Assert.AreEqual(0, mapping.CompareTo(matchingMapping));
            }
        }
Exemple #5
0
        /// <summary>
        /// Updates the DisplayMapping from a StackHashMapping
        /// </summary>
        /// <param name="stackHashMapping">StackHashMapping</param>
        public void UpdateMapping(StackHashMapping stackHashMapping)
        {
            if (stackHashMapping == null)
            {
                throw new ArgumentNullException("stackHashMapping");
            }
            if (_stackHashMapping.Id != stackHashMapping.Id)
            {
                throw new InvalidOperationException("Cannot update from a StackHashMapping with a different ID");
            }
            if (_stackHashMapping.MappingType != stackHashMapping.MappingType)
            {
                throw new InvalidOperationException("Cannot update from a StackHashMapping with a different MappingType");
            }

            // save the new mapping
            StackHashMapping oldMapping = _stackHashMapping;

            _stackHashMapping = stackHashMapping;

            // check for updates
            if (oldMapping.Name != _stackHashMapping.Name)
            {
                RaisePropertyChanged("Name");
            }
        }
Exemple #6
0
        /// <summary>
        /// StackHashMapping wrapper class
        /// </summary>
        /// <param name="stackHashMapping">Underlying StackHashMapping object</param>
        public DisplayMapping(StackHashMapping stackHashMapping)
        {
            if (stackHashMapping == null)
            {
                throw new ArgumentNullException("stackHashMapping");
            }

            _stackHashMapping = stackHashMapping;
        }