Hi I am trying to Raise an event but I am getting this exception:
System.NotImplementedException: You can't call the original implementation of a method that does not have one (abstract or interface method).
System.NotImplementedException: You can't call the original implementation of a method that does not have one (abstract or interface method).
StorageAndInventoryService is the class that raises the event. BatchManager is the class subscribed to that event My test:I know that the issue is that we are Mocking as CallOriginal the BatchManager, but we are looking for an alternative, because as you can see is the class that we are trying to unit test. This is the callBack that I want to be executed in the BatchManager class:[TestMethod]publicvoidDestinationUnLockUpdatesBatchesStatus(){batchManager = Mock.Create<BatchManager>(Behavior.CallOriginal);batchManager.StorageInventoryService = Mock.Create<StorageInventoryService>();//Mock dataList<DestinationStatus> destinationStatuses =newList<DestinationStatus>{newDestinationStatus("D1",false, 1, 2,newList<string>())};Mock.Arrange(() => batchManager.StorageInventoryService.GetDestinationStatus(Arg.IsAny<List<string>>())).Returns(destinationStatuses).OccursOnce();batchManager.AddLoadCarrierRequestToBatch(materialFlowContext).Wait();DestinationInfo destinationInfo = batchManager.BatchRepository.GetDestination("D1");List<BatchInfo> batchInfos = batchManager.BatchRepository.GetBatchesByDestination(destinationInfo, 99).ToList();batchManager.SelectAndReserveLoadCarrierRequests(newstring[] {"D1"}).Wait();Assert.IsTrue(destinationInfo.IsAvailable ==false);Assert.IsTrue(batchInfos.FirstOrDefault().Status == BatchStatus.Suspended);MfsLocationLockChangedDataEventArgs mfsLocationLockChangedDataEventArgs =newMfsLocationLockChangedDataEventArgs(newMfsLocationLockChangedData("D1",true,string.Empty));Mock.Raise(() => batchManager.StorageInventoryService.LocationLockChanged +=null, mfsLocationLockChangedDataEventArgs);Assert.IsTrue(batchInfos.FirstOrDefault().Status == BatchStatus.InProgress);}privatevoidStorageInventoryServiceOnLocationLockChanged(objectsender, MfsLocationLockChangedDataEventArgs mfsLocationLockChangedDataEventArgs){Log.Debug("** StorageInventoryServiceOnLocationLockChanged has changed**");if(!mfsLocationLockChangedDataEventArgs.MfsLocationLockChangedData.IsLocked){DestinationInfo destinationInfo = BatchRepository.GetDestination(mfsLocationLockChangedDataEventArgs.MfsLocationLockChangedData.AddressName);if(destinationInfo !=null){BatchRepository.UpdateDestinationAvailability(destinationInfo.Address,true);List<BatchInfo> batchInfos = BatchRepository.GetBatchesByDestination(destinationInfo, 99).ToList();foreach(BatchInfo batchinbatchInfos){BatchRepository.UpdateBatchStatus(batch.BatchId, BatchStatus.InProgress);foreach(stringloadCarrierinbatch.LoadCarriers){BatchRepository.UpdateLoadCarrierRequestStatus(loadCarrier, LoadCarrierRequestStatus.New);}}OnDestinationUnLocked(newDestinationStatusChangedEventArgs{Destinations =newList<string>{mfsLocationLockChangedDataEventArgs.MfsLocationLockChangedData.AddressName}});}}}
