示例#1
0
        public void TestReceivePackage_Successfully()
        {
            MockPackageRepository myMockPackageRepo = new MockPackageRepository();
            PackageService        packageService    = new PackageService(myMockPackageRepo);
            Package            package1             = MockDataAccess.GetPackage(3);
            DistributionCentre myReceiverCentre     = MockDataAccess.GetDistributionCentre(3);
            int newTransitId = InsertMockTransit(package1, 2, 3);                                       // insert transit

            packageService.Receive(package1.BarCode, myReceiverCentre, DateTime.Today);
            PackageTransit finishedTransit = MockDataAccess.GetPackageTransit(newTransitId);

            Debug.WriteLine(finishedTransit.ToString());
            Assert.IsTrue(finishedTransit.IsPastTransit() && finishedTransit.ReceiverCentre == myReceiverCentre);
        }
示例#2
0
        public void TestDistribute_DistributedCurrentLocationError()
        {
            MockPackageRepository packageRepository = new MockPackageRepository();
            PackageService        _packageService   = new PackageService(packageRepository);
            Employee emp = MockDataAccess.GetEmployee(2);
            Package  p   = MockDataAccess.GetPackage(3);

            p.CurrentStatus   = PackageStatus.Distributed;
            p.CurrentLocation = MockDataAccess.GetDistributionCentre(4);
            Result result = _packageService.Distribute(p.BarCode, p.CurrentLocation, emp, p.ExpirationDate, p.PackageType, p.PackageId);

            Assert.AreEqual(false, result.Success);
            //Assert.AreEqual("Package has been already distributed: " + barCode, result.ErrorMessage);
        }
示例#3
0
 public Package GetPackage(int packageId)                                           // (P. 05-04-2015)
 {
     return(MockDataAccess.GetPackage(packageId));
 }