public void ShouldGetEngineerCount()
        {
            var service = new EngineerService(engineerRepository.Object);
            var count   = service.GetEngineerCount();

            Assert.Equal(4, count);
        }
        public void ShouldGetAvailableEngineersFromListOfShifts()
        {
            var service = new EngineerService(engineerRepository.Object);
            var shifts  = new ShiftFixture().GetAllShifts();

            shifts.RemoveAt(0);
            shifts.RemoveAt(1);

            var availableEngineers = service.GetAvailableEngineers(shifts, 2);

            Assert.Equal(2, availableEngineers.Count());
        }
Exemple #3
0
        /// <summary>
        /// Get the current engineer details using engineer Service with identity id and connection string
        /// </summary>
        /// <returns>the current engineer user object</returns>
        public User GetDetail()
        {
            try
            {
                IEngineerService engineerService = new EngineerService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, User.Identity.GetUserId());


                return(engineerService.getDetail());
            }
            catch (Exception)
            {
                Response.Redirect("~/Errors/InternalErrors.aspx", false);
                return(null);
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //if the query string is not null process, else go to the homepage
                if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
                {
                    //Instantiate a new instance of engineer service
                    IEngineerService engineerService = new EngineerService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, User.Identity.GetUserId());
                    //Instantiate a new instance of district service
                    IDistrictService districtService = new DistrictService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);

                    Guid clientId = new Guid(Request.QueryString["Id"]);
                    //get client form engineer service
                    Client client = engineerService.getClientById(clientId);

                    //Data bind UI with client details
                    lblName.Text = client.Name;

                    lblDistrict.Text = districtService.GetDistrictById(client.DistrictId).Name;
                    lblLocation.Text = client.Location;

                    //get a list of interventions for the client
                    List <Intervention> clientIntervention = engineerService.getInterventionsByClient(clientId).ToList();



                    //Data bind UI with intervention details
                    foreach (var intervention in clientIntervention)
                    {
                        intervention.InterventionType = engineerService.getInterventionTypes().Find(it => it.Id == intervention.InterventionTypeId);
                    }

                    InterventionList.DataSource = clientIntervention;
                    InterventionList.DataBind();
                }
                else
                {
                    Response.Redirect("~/Engineer/Welcome.aspx", false);
                }
            }
            catch (Exception)
            {
                Response.Redirect("~/Errors/InternalErrors.aspx", true);
            }
        }
Exemple #5
0
        public void GivenEngineerService_WhenGetAllIsInvoked_ThenShouldReturnAllEngineersInRepository()
        {
            // Arrange
            var engineers = EngineerStub.CreateMultiple(QUANTITY);

            var repository = new Mock <IRepository <Engineer> >();

            repository.Setup(r => r.Get(null, null))
            .Returns(engineers);

            var service = new EngineerService(repository.Object);

            // Act
            var results = service.GetAll();

            // Assert
            results.Should().BeEquivalentTo(engineers);
            repository.Verify(r => r.Get(null, null), Times.Exactly(1));
        }
Exemple #6
0
        /**
         * Get All Engineers
         *
         * */
        public List <EngineerModel> GetAllEngineers()
        {
            EngineerService service = new EngineerService();

            return(service.GetAllEngineers());
        }
 public void SetUp()
 {
     engineerService = new EngineerService("");
 }