public void IMSLogicSiteEngineer_GetClientDetail()
        {
            Guid guid = new Guid();
            Mock <IClientDataAccess> clients = new Mock <IClientDataAccess>();
            Client clientDetail = new Client("PO", "Hornsby", new Guid());

            clientDetail.Id = guid;
            clients.Setup(c => c.fetchClientById(It.IsAny <Guid>())).Returns(clientDetail);
            engineerService.Clients = clients.Object;

            IMSDBLayer.DataModels.Client client = engineerService.getClientById(guid);

            Assert.IsNotNull(client);
            Assert.AreEqual(guid, client.Id);
        }
示例#2
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);
            }
        }