Adding EditCell constructor validation (#301)

* New unit tests!
* New CopyTo method!
* New null validation!

YEAH!!!
This commit is contained in:
Benjamin Russell
2017-04-03 13:20:04 -07:00
committed by GitHub
parent 65456ae35b
commit e548ae67b5
4 changed files with 119 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
//
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.EditData.Contracts
{
@@ -24,11 +25,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.Contracts
/// <param name="isDirty">Whether or not the edit cell is dirty</param>
public EditCell(DbCellValue dbCellValue, bool isDirty)
{
IsDirty = isDirty;
Validate.IsNotNull(nameof(dbCellValue), dbCellValue);
dbCellValue.CopyTo(this);
DisplayValue = dbCellValue.DisplayValue;
IsNull = dbCellValue.IsNull;
RawObject = dbCellValue.RawObject;
IsDirty = isDirty;
}
/// <summary>

View File

@@ -3,6 +3,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
{
/// <summary>
@@ -24,5 +26,18 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
/// The raw object for the cell, for use internally
/// </summary>
internal object RawObject { get; set; }
/// <summary>
/// Copies the values of this DbCellValue into another DbCellValue (or child object)
/// </summary>
/// <param name="other">The DbCellValue (or child) that will receive the values</param>
public virtual void CopyTo(DbCellValue other)
{
Validate.IsNotNull(nameof(other), other);
other.DisplayValue = DisplayValue;
other.IsNull = IsNull;
other.RawObject = RawObject;
}
}
}