initialize
This commit is contained in:
@@ -0,0 +1,327 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using www.siplace.com.OIB._2008._05.SetupCenter.Contracts.Data;
|
||||
using System.Globalization;
|
||||
using com.itac.mes.simm;
|
||||
using com.itac.mes.imsapi;
|
||||
using System.Runtime.Remoting.Proxies;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using com.itac.mes.imsapi.domain.container;
|
||||
using com.itac.mes.imsapi.data;
|
||||
using com.itac.mes.imsapi.client.dotnet;
|
||||
|
||||
namespace Itac.Oib.Simm.Tests
|
||||
{
|
||||
|
||||
public class ImsApiMock : RealProxy
|
||||
{
|
||||
|
||||
public ImsApiMock() : base(typeof(IIMSApiDotNet)) { }
|
||||
|
||||
private Dictionary<string, int> callCountDictionary = new Dictionary<string, int>();
|
||||
|
||||
|
||||
public override IMessage Invoke(IMessage message)
|
||||
{
|
||||
// start der Methode
|
||||
IMethodCallMessage methodMsg = (IMethodCallMessage)message;
|
||||
|
||||
if (!callCountDictionary.ContainsKey(methodMsg.MethodName))
|
||||
{
|
||||
callCountDictionary.Add(methodMsg.MethodName, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
callCountDictionary.Add(methodMsg.MethodName, callCountDictionary[methodMsg.MethodName] + 1);
|
||||
}
|
||||
|
||||
object[] args = methodMsg.Args;
|
||||
object returnValue = null;
|
||||
if (methodMsg.MethodName.Equals("mlGetMaterialBinData"))
|
||||
{
|
||||
KeyValue callParam = ((KeyValue[])args[2])[0];
|
||||
// Keys = "MATERIAL_BIN_NUMBER", "EXPIRATION_DATE", "MATERIAL_BIN_STATE", "MSL_STATE", "MSL_LEVEL", "MSL_DRY_END_DATE", "MSL_OPEN_DATE", "MATERIAL_BIN_QTY_ACTUAL"
|
||||
|
||||
if (callParam.value.Equals("000608"))
|
||||
{
|
||||
args[5] = new String[] { "000608", "32535212399000", "R", "C", "2a", "", "", "10.0" };
|
||||
}
|
||||
else if (callParam.value.Equals("000609"))
|
||||
{
|
||||
args[5] = new String[] { "000609", "0", "R", "O", "2a", "", "", "10.0" };
|
||||
}
|
||||
else if (callParam.value.Equals("000610"))
|
||||
{
|
||||
// expiration 2032.12.31
|
||||
args[5] = new String[] { "000610", "1988060400000", "R", "O", "2a", "", "", "10.0" };
|
||||
}
|
||||
}
|
||||
returnValue = 0;//
|
||||
return new ReturnMessage(returnValue, args, 0, methodMsg.LogicalCallContext, methodMsg);
|
||||
}
|
||||
|
||||
public int getCallCount(string methodName)
|
||||
{
|
||||
if (!callCountDictionary.ContainsKey(methodName)) { return 0; }
|
||||
return callCountDictionary[methodName];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TestClass()]
|
||||
public class SetupCenterExternalControlReceiverTests
|
||||
{
|
||||
[TestMethod()]
|
||||
public void GetNewPackagingUnitDataTest()
|
||||
{
|
||||
PackagingUnit pu = new PackagingUnit();
|
||||
pu.UID = "outer";
|
||||
pu.SplicedPackagingUnit = new PackagingUnit();
|
||||
pu.SplicedPackagingUnit.UID = "spliced";
|
||||
|
||||
PackagingUnit spliced = pu.SplicedPackagingUnit;
|
||||
spliced.SplicedPackagingUnit = new PackagingUnit();
|
||||
spliced.SplicedPackagingUnit.UID = "last";
|
||||
|
||||
Dictionary<string, PackagingUnit> packagingUnitMap = new Dictionary<string, PackagingUnit>();
|
||||
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.SIMM, ConfigCode.OFF, ConfigCode.OFF);
|
||||
testee.deepAddUnit(pu, ref packagingUnitMap);
|
||||
|
||||
Assert.IsTrue(packagingUnitMap.ContainsKey("spliced"));
|
||||
Assert.IsTrue(packagingUnitMap.ContainsKey("last"));
|
||||
Assert.IsTrue(packagingUnitMap.ContainsKey("outer"));
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldMapValues()
|
||||
{
|
||||
PackagingUnit pu = new PackagingUnit();
|
||||
pu.UID = "outer";
|
||||
|
||||
string[] materialBinUploadKeys = new String[] { "ERROR_CODE", "MATERIAL_BIN_NUMBER" };
|
||||
string[] result = new string[20];
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
testee.mapValues(pu, materialBinUploadKeys, ref result, 2);
|
||||
|
||||
Assert.AreEqual("0", result[2]);
|
||||
Assert.AreEqual("outer", result[3]);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldParseDoubleLanguageIndependent()
|
||||
{
|
||||
string v = "9950,0";
|
||||
v = v.Replace(",", ".");
|
||||
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
|
||||
Double d = Double.Parse(v, culture);
|
||||
Assert.AreEqual(9950.0, d);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldReturnMaxDateString()
|
||||
{
|
||||
DateTime newDate = new DateTime(4000, 12, 3, 14, 23, 55, DateTimeKind.Utc);
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
Assert.AreEqual("32535212399000", testee.getImsApiDateString(newDate));
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldReturnMinDateString()
|
||||
{
|
||||
DateTime newDate = new DateTime(1969, 12, 3, 02, 23, 55, DateTimeKind.Utc);
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
Assert.AreEqual("0", testee.getImsApiDateString(newDate));
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldReturnCorrectDateString()
|
||||
{
|
||||
// Fri Nov 25 2016 10:46:25
|
||||
DateTime newDate = new DateTime(2016, 11, 25, 09, 46, 25, DateTimeKind.Utc);
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
Assert.AreEqual("1480067185000", testee.getImsApiDateString(newDate));
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldReturnClosedContainer()
|
||||
{
|
||||
//prepare
|
||||
PackagingUnit pu = new PackagingUnit();
|
||||
pu.UID = "000608";
|
||||
pu.ExpiryDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.ConsumptionDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.ManufacturerDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.LastProductionDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.MsdOpenDate = DateTime.MinValue.ToUniversalTime();
|
||||
|
||||
PackagingUnitLocation location = new PackagingUnitLocation();
|
||||
location.PackagingUnit = pu;
|
||||
|
||||
ImsApiMock proxy = new ImsApiMock();
|
||||
IIMSApiDotNet imsApiMock = (IIMSApiDotNet)proxy.GetTransparentProxy();
|
||||
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, imsApiMock, null, "", 201,
|
||||
ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
PackagingUnitLocation[] packagingUnitLocations = new PackagingUnitLocation[] { location };
|
||||
|
||||
// call
|
||||
ExternalControlResult[] result = testee.GetPackagingUnitControlStatus(packagingUnitLocations);
|
||||
|
||||
Assert.AreEqual(DateTime.MinValue, result[0].PackagingUnit.MsdOpenDate);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldReturnOpenedContainer()
|
||||
{
|
||||
//prepare
|
||||
PackagingUnit pu = new PackagingUnit();
|
||||
pu.UID = "000609";
|
||||
pu.ExpiryDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.ConsumptionDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.ManufacturerDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.LastProductionDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.MsdOpenDate = DateTime.MinValue.ToUniversalTime();
|
||||
|
||||
PackagingUnitLocation location = new PackagingUnitLocation();
|
||||
location.PackagingUnit = pu;
|
||||
|
||||
ImsApiMock proxy = new ImsApiMock();
|
||||
IIMSApiDotNet imsApiMock = (IIMSApiDotNet)proxy.GetTransparentProxy();
|
||||
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, imsApiMock, null, "", 201,
|
||||
ConfigCode.OFF, ConfigCode.SIMM, ConfigCode.SIMM);
|
||||
PackagingUnitLocation[] packagingUnitLocations = new PackagingUnitLocation[] { location };
|
||||
|
||||
// call
|
||||
ExternalControlResult[] result = testee.GetPackagingUnitControlStatus(packagingUnitLocations);
|
||||
|
||||
Assert.AreEqual(DateTime.MinValue, result[0].PackagingUnit.MsdOpenDate);
|
||||
Assert.AreEqual(DateTime.MinValue, result[0].PackagingUnit.ExpiryDate);
|
||||
|
||||
// expected is no adjustment of the material bin data in the mes
|
||||
Assert.AreEqual(0, proxy.getCallCount("mlChangeMaterialBinData"));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldAdjustContainerExpirationInMES()
|
||||
{
|
||||
//prepare
|
||||
PackagingUnit pu = new PackagingUnit();
|
||||
pu.UID = "000610";
|
||||
pu.ExpiryDate = new DateTime(2000, 12, 31).ToUniversalTime();
|
||||
pu.ConsumptionDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.ManufacturerDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.LastProductionDate = DateTime.MinValue.ToUniversalTime();
|
||||
pu.MsdOpenDate = DateTime.MinValue.ToUniversalTime();
|
||||
|
||||
PackagingUnitLocation location = new PackagingUnitLocation();
|
||||
location.PackagingUnit = pu;
|
||||
|
||||
ImsApiMock proxy = new ImsApiMock();
|
||||
IIMSApiDotNet imsApiMock = (IIMSApiDotNet)proxy.GetTransparentProxy();
|
||||
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, imsApiMock, null, "", 201,
|
||||
ConfigCode.OFF, ConfigCode.SIMM, ConfigCode.SIMM);
|
||||
PackagingUnitLocation[] packagingUnitLocations = new PackagingUnitLocation[] { location };
|
||||
|
||||
// call
|
||||
ExternalControlResult[] result = testee.GetPackagingUnitControlStatus(packagingUnitLocations);
|
||||
|
||||
Assert.AreEqual(DateTime.MinValue, result[0].PackagingUnit.MsdOpenDate);
|
||||
|
||||
// expected is no adjustment of the material bin data in the mes
|
||||
Assert.AreEqual(1, proxy.getCallCount("mlChangeMaterialBinData"), "mlChangeMaterialBinData nicht aufgerufen");
|
||||
Assert.AreEqual(1, proxy.getCallCount("mslStopObjectExpiration"), "mslStopObjectExpiration nicht aufgerufen");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldNotTakeOverQuantity()
|
||||
{
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
|
||||
SmtContainer container = new SmtContainer();
|
||||
container.materialBinQuantityActual = 100;
|
||||
PackagingUnit packagingUnit = new PackagingUnit();
|
||||
packagingUnit.Quantity = 50;
|
||||
LinkedList<MaterialBinBooking> updateQtyList = new LinkedList<MaterialBinBooking>();
|
||||
testee.adjustQuantity(ConfigCode.OFF, ref container, ref packagingUnit, ref updateQtyList);
|
||||
|
||||
Assert.AreEqual(50, packagingUnit.Quantity);
|
||||
Assert.AreEqual(0, updateQtyList.Count);
|
||||
}
|
||||
|
||||
|
||||
/* [TestMethod()]
|
||||
public void shouldTakeOverMesExpiration()
|
||||
{
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
SmtContainer container = new SmtContainer();
|
||||
container.expirationDate = new DateTime(2017, 01, 14, 12, 34, 55, DateTimeKind.Utc);
|
||||
PackagingUnit packagingUnit = new PackagingUnit();
|
||||
packagingUnit.ExpiryDate = new DateTime(2012, 01, 14, 12, 34, 55, DateTimeKind.Utc);
|
||||
|
||||
LinkedList<MaterialBinBooking> updateQtyList = new LinkedList<MaterialBinBooking>();
|
||||
|
||||
Object p = new object()
|
||||
{ int mlChangeMaterialBinData(IMSApiSessionContextStruct sessionContext, string stationNumber, string materialBinNumber, KeyValue[] materialBinDataUploadValues)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
ExternalControlResult result = new ExternalControlResult();
|
||||
IIMSApi imsapi = (IIMSApi)p;
|
||||
testee.adjustExpiration(ConfigCode.MES, ref container, ref packagingUnit, ref imsapi, ref result);
|
||||
|
||||
Assert.AreEqual(2017, packagingUnit.ExpiryDate.Year);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
[TestMethod()]
|
||||
public void shouldTakeOverQuantity()
|
||||
{
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
|
||||
SmtContainer container = new SmtContainer();
|
||||
container.materialBinQuantityActual = 100;
|
||||
PackagingUnit packagingUnit = new PackagingUnit();
|
||||
packagingUnit.Quantity = 50;
|
||||
LinkedList<MaterialBinBooking> updateQtyList = new LinkedList<MaterialBinBooking>();
|
||||
testee.adjustQuantity(ConfigCode.SIMM, ref container, ref packagingUnit, ref updateQtyList);
|
||||
|
||||
Assert.AreEqual(1, updateQtyList.Count);
|
||||
// mes setzt Gebinde auf Menge 50 (Menge der ASM-Pack-Unit
|
||||
Assert.AreEqual(50, updateQtyList.First.Value.materialBinQuantityActual);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldNotTakeOverQuantity()
|
||||
{
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
|
||||
SmtContainer container = new SmtContainer();
|
||||
container.materialBinQuantityActual = 100;
|
||||
PackagingUnit packagingUnit = new PackagingUnit();
|
||||
packagingUnit.Quantity = 50;
|
||||
LinkedList<MaterialBinBooking> updateQtyList = new LinkedList<MaterialBinBooking>();
|
||||
testee.adjustQuantity(ConfigCode.OFF, ref container, ref packagingUnit, ref updateQtyList);
|
||||
|
||||
Assert.AreEqual(50, packagingUnit.Quantity);
|
||||
Assert.AreEqual(0, updateQtyList.Count);
|
||||
}
|
||||
*/
|
||||
|
||||
[TestMethod()]
|
||||
public void shouldAcceptAsSameExpirationDate()
|
||||
{
|
||||
SetupCenterExternalControlReceiver testee = new SetupCenterExternalControlReceiver(null, null, null, "", 201, ConfigCode.OFF, ConfigCode.OFF, ConfigCode.OFF);
|
||||
Assert.IsFalse(testee.expirationDateDifferent(new DateTime(3000, 12, 30, 4, 0, 0), new DateTime(3000, 12, 31, 0, 0, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user