public async Task StandardDataModel_GetComponents_ReturnsComponents() { var dataModel = new StandardDataModel(databaseSubstitute); var components = await dataModel.GetHardwareComponents(); Assert.AreEqual(2, components.Count); }
public async Task StandardDataModel_AddComponent_AddsComponentToDictionaryWithoutNewRead() { var dataModel = new StandardDataModel(databaseSubstitute); var components = await dataModel.GetHardwareComponents(); await dataModel.CreateNewComponent(new HardwareComponent("#1", 10, 5, 100, "B", "empty", 60)); Assert.AreEqual(3, components.Count); }
public async Task StandardDataModel_AddComponentAlreadyExists_OverwritesComponent() { var dataModel = new StandardDataModel(databaseSubstitute); var components = await dataModel.GetHardwareComponents(); await dataModel.CreateNewComponent(new HardwareComponent("#2", 10, 5, 100, "B", "empty", 60)); components.TryGetValue("#2", out var component); Assert.AreEqual("B", component.componentName); }
public async Task StandardDataModel_CreateUID_ReturnsDifferentUids() { IDataModel dataModel = new StandardDataModel(databaseSubstitute); var hashOne = await dataModel.CreateUID(); await Task.Delay(10); var hashTwo = await dataModel.CreateUID(); Assert.AreNotEqual(hashOne, hashTwo, $"Hash one: {hashOne}, hash two: {hashTwo}\n"); }
public static string ToSQLParameter(StandardDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case StandardDataModel.StandardDataColumns.Name: if (!string.IsNullOrEmpty(data.Name)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, StandardDataModel.StandardDataColumns.Name, data.Name); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, StandardDataModel.StandardDataColumns.Name); } break; case StandardDataModel.StandardDataColumns.Description: if (!string.IsNullOrEmpty(data.Description)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, StandardDataModel.StandardDataColumns.Description, data.Description); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, StandardDataModel.StandardDataColumns.Description); } break; case StandardDataModel.StandardDataColumns.SortOrder: if (data.SortOrder != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, StandardDataModel.StandardDataColumns.SortOrder, data.SortOrder); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, StandardDataModel.StandardDataColumns.SortOrder); } break; default: returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public virtual void SetData(StandardDataModel data) { Description = data.Description; Name = data.Name; SortOrder = data.SortOrder; if (CoreControlApplicationId != null) { ApplicationId = data.ApplicationId; } CoreUpdateInfo.LoadText(data.UpdatedDate, data.UpdatedBy, data.LastAction); }
protected static void SetStandardInfo(StandardDataModel dataItem, DataRow dataRow) { dataItem.Name = dataRow[StandardDataModel.StandardDataColumns.Name].ToString(); dataItem.Description = dataRow[StandardDataModel.StandardDataColumns.Description].ToString(); dataItem.SortOrder = (int)dataRow[StandardDataModel.StandardDataColumns.SortOrder]; }