コード例 #1
0
        public void GivenNullableIntNotInDictionaryWhenGetNullableIntIsCalledThenNullValueIsReturned()
        {
            Mock <IDsmModel>            model = new Mock <IDsmModel>();
            Dictionary <string, string> data  = new Dictionary <string, string>();

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

            Assert.IsFalse(readValue.HasValue);
        }
コード例 #2
0
        public ElementMoveDownAction(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);

            _element = attributes.GetElement(nameof(_element));
            Debug.Assert(_element != null);
        }
コード例 #3
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));
        }
コード例 #4
0
        public MakeSnapshotAction(object[] args)
        {
            Debug.Assert(args.Length == 2);
            IDsmModel 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);

            _name = attributes.GetString(nameof(_name));
        }
コード例 #5
0
        public RelationDeleteAction(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);
        }
コード例 #6
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));
        }
コード例 #7
0
        public ElementCreateAction(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);

            _element = attributes.GetElement(nameof(_element));
            Debug.Assert(_element != null);

            _name = attributes.GetString(nameof(_name));
            _type = attributes.GetString(nameof(_type));

            int?parentId = attributes.GetNullableInt(nameof(_parent));

            if (parentId.HasValue)
            {
                _parent = _model.GetElementById(parentId.Value);
            }
        }