Exemple #1
0
        public RelationChangeWeightAction(object[] args)
        {
            Debug.Assert(args.Length == 2);
            _model = args[0] as IDsmModel;
            Debug.Assert(_model != null);
            IReadOnlyDictionary <string, string> data = args[1] as IReadOnlyDictionary <string, string>;

            Debug.Assert(data != null);

            ActionReadOnlyAttributes attributes = new ActionReadOnlyAttributes(_model, data);

            _relation = attributes.GetRelation(nameof(_relation));
            Debug.Assert(_relation != null);

            _consumer = attributes.GetRelationConsumer(nameof(_relation));
            Debug.Assert(_consumer != null);

            _provider = attributes.GetRelationProvider(nameof(_relation));
            Debug.Assert(_provider != null);

            _old = attributes.GetInt(nameof(_old));
            _new = attributes.GetInt(nameof(_new));
        }
Exemple #2
0
        public void GivenIntValueInDictionaryWhenGetIntIsCalledThenValueIsReturned()
        {
            Mock <IDsmModel>            model = new Mock <IDsmModel>();
            Dictionary <string, string> data  = new Dictionary <string, string>();

            string key         = "name";
            int    memberValue = 7;

            data[key] = memberValue.ToString();

            string memberName = "_name";
            ActionReadOnlyAttributes attributes = new ActionReadOnlyAttributes(model.Object, data);

            Assert.AreEqual(7, attributes.GetInt(memberName));
        }
Exemple #3
0
        public void GivenMultipleValuesInDictionaryWhenGetValueIsCalledThenAllAreReturned()
        {
            Mock <IDsmModel>            model = new Mock <IDsmModel>();
            Dictionary <string, string> data  = new Dictionary <string, string>();

            string key1         = "name1";
            string memberValue1 = "some_value1";

            data[key1] = memberValue1;

            string key2         = "name2";
            int    memberValue2 = 7;

            data[key2] = memberValue2.ToString();

            string memberName1 = "_name1";
            string memberName2 = "_name2";
            ActionReadOnlyAttributes attributes = new ActionReadOnlyAttributes(model.Object, data);

            Assert.AreEqual(memberValue1, attributes.GetString(memberName1));
            Assert.AreEqual(memberValue2, attributes.GetInt(memberName2));
        }