コード例 #1
0
ファイル: ManagerControllerTest.cs プロジェクト: yezcozyg/ims
        public void SetUp()
        {
            IMSDBLayer.Models.User db_manager = new IMSDBLayer.Models.User()
            {
                Id              = new Guid(),
                Name            = "John Smith",
                Type            = 1,
                AuthorisedCosts = 40,
                AuthorisedHours = 40,
                IdentityId      = "",
                DistrictId      = new Guid()
            };

            IMSDBLayer.Models.District db_district = new IMSDBLayer.Models.District()
            {
                Id   = new Guid(),
                Name = "NSW"
            };

            manager          = new IMSLogicLayer.Models.User(db_manager);
            manager.District = new IMSLogicLayer.Models.District(db_district);

            managerService = new Mock <IManagerService>();
            managerService.Setup(m => m.GetDetail()).Returns(manager);
            managerService.Setup(m => m.GetApprovedInterventions()).Returns(new List <IMSLogicLayer.Models.Intervention>());
            managerService.Setup(m => m.SendEmailNotification(It.IsAny <IMSLogicLayer.Models.Intervention>(), It.IsAny <string>()));

            controller = new ManagerController(managerService.Object);
        }
コード例 #2
0
        public void SetUp()
        {
            IMSDBLayer.Models.User db_engineer = new IMSDBLayer.Models.User()
            {
                Id              = new Guid(),
                Name            = "John Smith",
                Type            = 1,
                AuthorisedCosts = 40,
                AuthorisedHours = 40,
                IdentityId      = "",
                DistrictId      = new Guid()
            };

            IMSDBLayer.Models.Client db_client = new IMSDBLayer.Models.Client()
            {
                Id         = new Guid(),
                Name       = "John",
                DistrictId = new Guid()
            };

            IMSDBLayer.Models.District db_district = new IMSDBLayer.Models.District()
            {
                Id   = new Guid(),
                Name = "NSW"
            };

            intervention = new IMSLogicLayer.Models.Intervention(40, 40, 4, "comments", IMSLogicLayer.Enums.InterventionState.Approved, new DateTime(), new DateTime(), new DateTime(), new Guid(), new Guid(), new Guid(), new Guid());
            client       = new IMSLogicLayer.Models.Client(db_client);
            IMSLogicLayer.Models.District district = new IMSLogicLayer.Models.District(db_district);

            engineer                      = new IMSLogicLayer.Models.User(db_engineer);
            engineer.District             = district;
            intervention.District         = district;
            intervention.Client           = client;
            intervention.InterventionType = new IMSLogicLayer.Models.InterventionType("", 5, 5);

            engineerService = new Mock <IEngineerService>();
            engineerService.Setup(e => e.getDetail()).Returns(engineer);
            engineerService.Setup(e => e.getInterventionTypes()).Returns(new List <IMSLogicLayer.Models.InterventionType>());
            engineerService.Setup(e => e.createClient(It.IsAny <string>(), It.IsAny <string>())).Returns(new IMSLogicLayer.Models.Client("", "", new Guid()));
            engineerService.Setup(e => e.getClients()).Returns(new List <IMSLogicLayer.Models.Client>());
            engineerService.Setup(e => e.getNonGuidInterventionById(It.IsAny <Guid>())).Returns(intervention);
            engineerService.Setup(e => e.updateInterventionState(new Guid(SUCCESS_TEST_GUID), It.IsAny <IMSLogicLayer.Enums.InterventionState>())).Returns(true);
            engineerService.Setup(e => e.updateInterventionState(new Guid(FAILED_TEST_GUID), It.IsAny <IMSLogicLayer.Enums.InterventionState>())).Returns(false);
            engineerService.Setup(e => e.GetAllInterventions(It.IsAny <Guid>())).Returns(new List <IMSLogicLayer.Models.Intervention>());
            engineerService.Setup(e => e.updateInterventionDetail(new Guid(SUCCESS_TEST_GUID), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <DateTime>())).Returns(true);
            engineerService.Setup(e => e.updateInterventionDetail(new Guid(FAILED_TEST_GUID), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <DateTime>())).Returns(false);
            engineerService.Setup(e => e.getInterventionsByClient(It.IsAny <Guid>())).Returns(new List <IMSLogicLayer.Models.Intervention>());
            engineerService.Setup(e => e.getClientById(It.IsAny <Guid>())).Returns(client);

            controller = new SiteEngineerController(engineerService.Object);
        }
コード例 #3
0
        public void SetUp()
        {
            IMSDBLayer.Models.User db_accountant = new IMSDBLayer.Models.User()
            {
                Id              = new Guid(),
                Name            = "John Smith",
                Type            = 1,
                AuthorisedCosts = 40,
                AuthorisedHours = 40,
                IdentityId      = "",
                DistrictId      = new Guid()
            };
            IMSDBLayer.Models.User db_user = new IMSDBLayer.Models.User()
            {
                Id              = new Guid(),
                Name            = "Mr. Engineer",
                Type            = 1,
                AuthorisedCosts = 20,
                AuthorisedHours = 20,
                IdentityId      = "",
                DistrictId      = new Guid()
            };
            IMSDBLayer.Models.District db_district = new IMSDBLayer.Models.District()
            {
                Id   = new Guid(),
                Name = "NSW"
            };
            IMSLogicLayer.Models.User accountant = new IMSLogicLayer.Models.User(db_accountant);
            user = new IMSLogicLayer.Models.User(db_user);
            IMSLogicLayer.Models.District district = new IMSLogicLayer.Models.District(db_district);

            accountantService = new Mock <IAccountantService>();
            accountantService.Setup(a => a.getDetail()).Returns(accountant);
            accountantService.Setup(a => a.getAllManger()).Returns(new List <IMSLogicLayer.Models.User>());
            accountantService.Setup(a => a.getAllSiteEngineer()).Returns(new List <IMSLogicLayer.Models.User>());
            accountantService.Setup(a => a.getUserById(It.IsAny <Guid>())).Returns(user);
            accountantService.Setup(a => a.getDistrictForUser(It.IsAny <Guid>())).Returns(district);
            accountantService.Setup(a => a.getDistricts()).Returns(new List <IMSLogicLayer.Models.District>());
            accountantService.Setup(a => a.printAverageCostByEngineer()).Returns(new List <IMSLogicLayer.Models.ReportRow>());
            accountantService.Setup(a => a.printMonthlyCostByDistrict(It.IsAny <Guid>())).Returns(new List <IMSLogicLayer.Models.ReportRow>());
            accountantService.Setup(a => a.printTotalCostByDistrict()).Returns(new List <IMSLogicLayer.Models.ReportRow>());
            accountantService.Setup(a => a.printTotalCostByEngineer()).Returns(new List <IMSLogicLayer.Models.ReportRow>());

            controller = new AccountantController(accountantService.Object);
        }