Beispiel #1
0
        public void TestUpdate()
        {
            IEmployeeRepository employeeRepository = new MockEmployeeRepository();
            EmployeeService     employeeService    = new EmployeeService(employeeRepository);

            DistributionCentre locationCentre = new DistributionCentre
            {
                CentreId = 1,
                Name     = "North Centre"
            };

            var result = employeeService.Update("fsmith", "Fred Smith", "*****@*****.**", locationCentre, EmployeeType.Doctor);

            Assert.AreEqual <bool>(true, result.Success);
        }
Beispiel #2
0
        public void TestUpdate_EmailAddressEmpty()
        {
            IEmployeeRepository employeeRepository = new MockEmployeeRepository();
            EmployeeService     employeeService    = new EmployeeService(employeeRepository);

            DistributionCentre locationCentre = new DistributionCentre
            {
                CentreId = 1,
                Name     = "North Centre"
            };

            var result = employeeService.Update("fsmith", "Fred Smith", string.Empty, locationCentre, EmployeeType.Doctor);

            Assert.AreEqual <bool>(false, result.Success);
            Assert.AreEqual <string>(EmployeeResult.EmailAddressCannotByEmpty, result.ErrorMessage);
        }
Beispiel #3
0
        public void TestUpdate_UsernameNotFound()
        {
            IEmployeeRepository employeeRepository = new MockEmployeeRepository();
            EmployeeService     employeeService    = new EmployeeService(employeeRepository);

            DistributionCentre locationCentre = new DistributionCentre
            {
                CentreId = 1,
                Name     = "North Centre"
            };

            var result = employeeService.Update("badusername", "Fred Smith", "*****@*****.**", locationCentre, EmployeeType.Doctor);

            Assert.AreEqual <bool>(false, result.Success);
            Assert.AreEqual <string>(EmployeeResult.UserNameCannotBeFound, result.ErrorMessage);
        }
Beispiel #4
0
        private Result DistributePackage(int currentCentreId, string userName, string barCode)
        {
            DistributionCentre centre = new DistributionCentre();

            centre.CentreId = currentCentreId;
            MockPackageRepository  packageRepository = new MockPackageRepository();
            PackageService         _packageService   = new PackageService(packageRepository);
            MockEmployeeRepository repository        = new MockEmployeeRepository();
            var                 employeeService      = new EmployeeService(repository);
            Employee            authEmployee         = employeeService.Retrieve(userName);
            DateTime            expirationDate       = DateTime.Now;
            Package             package = _packageService.Retrieve(barCode);
            StandardPackageType spt2    = _packageService.GetStandardPackageType(package.PackageType.PackageTypeId);

            return(_packageService.Distribute(package.BarCode, centre, authEmployee, expirationDate, spt2, package.PackageId));
        }
Beispiel #5
0
        public void TestDiscard_HandleCentreNullReference()
        {
            DistributionCentre centre = new DistributionCentre();

            centre = null;
            MockPackageRepository  packageRepository = new MockPackageRepository();
            PackageService         _packageService   = new PackageService(packageRepository);
            MockEmployeeRepository repository        = new MockEmployeeRepository();
            var                 employeeService      = new EmployeeService(repository);
            Employee            authEmployee         = employeeService.Retrieve("rsmith");
            DateTime            expirationDate       = DateTime.Now;
            Package             package = _packageService.Retrieve("1232655456");
            StandardPackageType spt2    = _packageService.GetStandardPackageType(package.PackageType.PackageTypeId);
            var                 result  = _packageService.Discard(package.BarCode, centre, authEmployee, expirationDate, spt2, package.PackageId);

            Assert.IsNotNull(result);
        }