private static void InitInputValues(object dbSessionProvider) { var inputAttributes = InputAttribute.Resolve(dbSessionProvider.GetType()); if (inputAttributes == null || inputAttributes.Length == 0) { return; } for (int i = 0; i < inputAttributes.Length; i++) { InitInputValue(dbSessionProvider, inputAttributes[i]); } }
public void InputAttributes() { var obj = new TestObject(); var attributes = InputAttribute.Resolve(obj.GetType()); Assert.AreEqual(2, attributes.Length); Assert.AreEqual("User Name", attributes[0].Title); Assert.AreEqual("DbInit_UserName", attributes[0].EnvironmentVariableName); Assert.AreEqual(false, attributes[0].IsPassword); Assert.AreEqual(nameof(TestObject.Password), attributes[1].Title); Assert.AreEqual(nameof(TestObject.Password), attributes[1].EnvironmentVariableName); Assert.AreEqual(true, attributes[1].IsPassword); attributes[0].SetValue(obj, "TestUserName"); attributes[1].SetValue(obj, "TestPassword"); Assert.AreEqual("TestUserName", obj.UserName); Assert.AreEqual("TestPassword", obj.Password); }