Hi all my invent table has following update method has following code :
super()
if (this.PhysicalDimensionInventoryUnitOfMeasure(this_Orig))
{
this.DimensionInventoryUnitOfMeasure();
}
now we can create 2 test class method in inventtabletest using de detour build the project and run the test method both will get passed.
:
// <summary>
/// Tests shouldUpdatePhysicalDimensionInventoryUnitOfMeasure method returns false if inventory net weight is not updated.
/// </summary>
[SysTestMethod]
public void update_ShouldUpdatePhysicalDimensionInventoryTrue_PhyscialDimUpdated()
{
ttsbegin;
using (var detourContext = SysDetourContext::createContext())
{
// Arrange
detourContext.whenMethodCalled(
UtilElementType::Table,
tableStr(InventTable),
tableMethodStr(InventTable, shouldUpdatePhysicalDimensionInventoryUnitOfMeasure))
.doReturnValue(true);
WHSPhysDimUOM WHSPhysDimUOM;
WHSPhysDimUOM.Width = 0;
WHSPhysDimUOM.UOM = InventTableModule::find(inventTable.ItemId, ModuleInventPurchSales::Invent).UnitId;
WHSPhysDimUOM.ItemId = inventTable.ItemId;
WHSPhysDimUOM.Depth = 0;
WHSPhysDimUOM.Height = 0;
WHSPhysDimUOM.doInsert();
inventTable.selectForUpdate(true);
inventTable.grossDepth = 10;
inventTable.grossHeight = 20;
inventTable.grossWidth = 30;
inventTable.TaraWeight = 10;
inventTable.NetWeight = 20;
//inventTable.update();
// Act
inventtable.update();
WHSPhysDimUOM.reread();
// Assert
this.assertEquals(inventTable.grossDepth, WHSPhysDimUOM.Depth, 'The depth value of physical dimension table should match with grossDepth of inventory table.');
this.assertEquals(inventTable.grossHeight, WHSPhysDimUOM.Height, 'The height value of physical dimension table should match with grossHeight of inventory table.');
this.assertEquals(inventTable.grossWidth, WHSPhysDimUOM.Width, 'The width value of physical dimension table should match with grossWidth of inventory table.');
this.assertEquals(inventTable.grossWeight(), WHSPhysDimUOM.Weight, 'The weight value of physical dimension table should match with grossWeight of inventory table.');
}
ttsabort;
}
// <summary>
/// Tests shouldUpdatePhysicalDimensionInventoryUnitOfMeasure method returns false if inventory net weight is not updated.
/// </summary>
[SysTestMethod]
public void update_ShouldUpdatePhysicalDimensionInventoryTrue_PhyscialDimNotUpdated()
{
ttsbegin;
using (var detourContext = SysDetourContext::createContext())
{
// Arrange
detourContext.whenMethodCalled(
UtilElementType::Table,
tableStr(InventTable),
tableMethodStr(InventTable, shouldUpdatePhysicalDimensionInventoryUnitOfMeasure))
.doReturnValue(false);
WHSPhysDimUOM WHSPhysDimUOM;
WHSPhysDimUOM.Width = 0;
WHSPhysDimUOM.UOM = InventTableModule::find(inventTable.ItemId, ModuleInventPurchSales::Invent).UnitId;
WHSPhysDimUOM.ItemId = inventTable.ItemId;
WHSPhysDimUOM.Depth = 0;
WHSPhysDimUOM.Height = 0;
WHSPhysDimUOM.doInsert();
inventTable.selectForUpdate(true);
inventTable.grossDepth = 10;
inventTable.grossHeight = 20;
inventTable.grossWidth = 30;
inventTable.TaraWeight = 10;
inventTable.NetWeight = 20;
// Act
inventtable.update();
WHSPhysDimUOM.reread();
// Assert
this.assertNotEqual(inventTable.grossDepth, WHSPhysDimUOM.Depth, 'The depth value of physical dimension table should not match with grossDepth of inventory table.');
this.assertNotEqual(inventTable.grossHeight, WHSPhysDimUOM.Height, 'The height value of physical dimension table should not match with grossHeight of inventory table.');
this.assertNotEqual(inventTable.grossWidth, WHSPhysDimUOM.Width, 'The width value of physical dimension table should not match with grossWidth of inventory table.');
this.assertNotEqual(inventTable.grossWeight(), WHSPhysDimUOM.Weight, 'The weight value of physical dimension table should not match with grossWeight of inventory table.');
}
ttsabort;
}
super()
if (this.PhysicalDimensionInventoryUnitOfMeasure(this_Orig))
{
this.DimensionInventoryUnitOfMeasure();
}
now we can create 2 test class method in inventtabletest using de detour build the project and run the test method both will get passed.
:
// <summary>
/// Tests shouldUpdatePhysicalDimensionInventoryUnitOfMeasure method returns false if inventory net weight is not updated.
/// </summary>
[SysTestMethod]
public void update_ShouldUpdatePhysicalDimensionInventoryTrue_PhyscialDimUpdated()
{
ttsbegin;
using (var detourContext = SysDetourContext::createContext())
{
// Arrange
detourContext.whenMethodCalled(
UtilElementType::Table,
tableStr(InventTable),
tableMethodStr(InventTable, shouldUpdatePhysicalDimensionInventoryUnitOfMeasure))
.doReturnValue(true);
WHSPhysDimUOM WHSPhysDimUOM;
WHSPhysDimUOM.Width = 0;
WHSPhysDimUOM.UOM = InventTableModule::find(inventTable.ItemId, ModuleInventPurchSales::Invent).UnitId;
WHSPhysDimUOM.ItemId = inventTable.ItemId;
WHSPhysDimUOM.Depth = 0;
WHSPhysDimUOM.Height = 0;
WHSPhysDimUOM.doInsert();
inventTable.selectForUpdate(true);
inventTable.grossDepth = 10;
inventTable.grossHeight = 20;
inventTable.grossWidth = 30;
inventTable.TaraWeight = 10;
inventTable.NetWeight = 20;
//inventTable.update();
// Act
inventtable.update();
WHSPhysDimUOM.reread();
// Assert
this.assertEquals(inventTable.grossDepth, WHSPhysDimUOM.Depth, 'The depth value of physical dimension table should match with grossDepth of inventory table.');
this.assertEquals(inventTable.grossHeight, WHSPhysDimUOM.Height, 'The height value of physical dimension table should match with grossHeight of inventory table.');
this.assertEquals(inventTable.grossWidth, WHSPhysDimUOM.Width, 'The width value of physical dimension table should match with grossWidth of inventory table.');
this.assertEquals(inventTable.grossWeight(), WHSPhysDimUOM.Weight, 'The weight value of physical dimension table should match with grossWeight of inventory table.');
}
ttsabort;
}
// <summary>
/// Tests shouldUpdatePhysicalDimensionInventoryUnitOfMeasure method returns false if inventory net weight is not updated.
/// </summary>
[SysTestMethod]
public void update_ShouldUpdatePhysicalDimensionInventoryTrue_PhyscialDimNotUpdated()
{
ttsbegin;
using (var detourContext = SysDetourContext::createContext())
{
// Arrange
detourContext.whenMethodCalled(
UtilElementType::Table,
tableStr(InventTable),
tableMethodStr(InventTable, shouldUpdatePhysicalDimensionInventoryUnitOfMeasure))
.doReturnValue(false);
WHSPhysDimUOM WHSPhysDimUOM;
WHSPhysDimUOM.Width = 0;
WHSPhysDimUOM.UOM = InventTableModule::find(inventTable.ItemId, ModuleInventPurchSales::Invent).UnitId;
WHSPhysDimUOM.ItemId = inventTable.ItemId;
WHSPhysDimUOM.Depth = 0;
WHSPhysDimUOM.Height = 0;
WHSPhysDimUOM.doInsert();
inventTable.selectForUpdate(true);
inventTable.grossDepth = 10;
inventTable.grossHeight = 20;
inventTable.grossWidth = 30;
inventTable.TaraWeight = 10;
inventTable.NetWeight = 20;
// Act
inventtable.update();
WHSPhysDimUOM.reread();
// Assert
this.assertNotEqual(inventTable.grossDepth, WHSPhysDimUOM.Depth, 'The depth value of physical dimension table should not match with grossDepth of inventory table.');
this.assertNotEqual(inventTable.grossHeight, WHSPhysDimUOM.Height, 'The height value of physical dimension table should not match with grossHeight of inventory table.');
this.assertNotEqual(inventTable.grossWidth, WHSPhysDimUOM.Width, 'The width value of physical dimension table should not match with grossWidth of inventory table.');
this.assertNotEqual(inventTable.grossWeight(), WHSPhysDimUOM.Weight, 'The weight value of physical dimension table should not match with grossWeight of inventory table.');
}
ttsabort;
}
No comments:
Post a Comment