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); }
public void GivenNullableIntInDictionaryWhenGetNullableIntIsCalledThenValueIsReturned() { 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); int?readValue = attributes.GetNullableInt(memberName); Assert.IsTrue(readValue.HasValue); Assert.AreEqual(7, readValue.Value); }
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); } }