public void DoKrystiana()       //Usuń potem cały ten test. Ten nizej mozesz zostawic.
        {
            string model = "Fiat";
            string owner = "Andrzej Miodek";
            string mark = "126p";
            string description = "Wymiana zderzaka";
            List<Part> parts = new List<Part>()
            {
                new Part("Uszczelka", 40),
                new Part("Kierownica", 400),
                new Part("Opona", 600)
            };

            //Do Krystiana : ja sobie tworze obiekt w ten sposob. Dzieki temu nie mam dostepu do metody SetId()
            IRequest request_1 = new Request(model, owner, mark, description, parts, true);
            //acces1.SetId(34); <- u mnie nie dziala


            //Do Krystiana : i ja wysylam do ciebie obiekt wlasnie w takiej ^ formie. U cibie zaraz
            //na starcie bedzie sie robilo cos takiego:
            IRequestWithIdAcces request_2 = (IRequestWithIdAcces)request_1;
            //dzieki temu zyskujesz dostep do dodatkowe metody: setID(int ID)
            request_2.SetId(34);    // <- u ciebie dziala

            //Jezeli potrzebujesz utworzyc obiekt od zera, a nie na podstawie otrzymanego ode mnie:
            IRequestWithIdAcces request_3 = new Request(model, owner, mark, description, parts, true);

            Assert.IsTrue(1 == 1);
        }
        public bool Equals(Request request)
        {
            if (Model != request.Model)
                return false;
            if (Owner != request.Owner)
                return false;
            if (Description != request.Description)
                return false;

            var firstNotSecond = ListOfParts.Except(request.ListOfParts).ToList();
            var secondNotFirst = request.ListOfParts.Except(ListOfParts).ToList();

            return (firstNotSecond.Count == 0 && secondNotFirst.Count == 0);
        }
        public void SouldSetIDWhenSetID()
        {
            string model = "Fiat";
            string owner = "Andrzej Miodek";
            string mark = "126p";
            string description = "Wymiana zderzaka";
            List<Part> parts = new List<Part>()
            {
                new Part("Uszczelka", 40),
                new Part("Kierownica", 400),
                new Part("Opona", 600)
            };
            Request a = new Request(model, owner, mark, description, parts, true);
                int id = 34;
            a.SetId(id);

            Assert.AreEqual(id, a.ID);
        }
        void generatePDF(Request request)
        {
            //ReportViewer ReportViewer1 = new ReportViewer();
            //ReportViewer1.LocalReport.ReportPath = HttpContext.Current.Server.MapPath(@"\PDFGenerator.rdlc");
            //string owner = request.Owner;
            //DateTime thisDay = DateTime.Today;
            //string pdfNumber = request.ID + "//" + (thisDay.ToString("d"));
            //double totalPrize = request.ListOfParts;
            //ReportParameter data = new ReportParameter("@owner", owner);
            //ReportParameter data = new ReportParameter("@pdf", pdfNumber);
            //byte[] byteViewer = ReportViewer1.LocalReport.Render("PDF");
            //FileStream newFile;

            //string filename = Guid.NewGuid().ToString() + ".pdf";
            //string path = HttpContext.Current.Server.MapPath(@"\") + filename;
            //newFile = new FileStream(path, FileMode.Create);
            //newFile.Write(byteViewer, 0, byteViewer.Length);
            //newFile.Flush();
            //newFile.Close();
        }
        public void PDFGenerate(Request request)
        {
            Stream myStream;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "PDF files (*.pdf)|*.pdf";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = saveFileDialog1.OpenFile()) != null)
                {
                    ReportViewer ReportViewer1 = new ReportViewer();
                    ReportViewer1.LocalReport.ReportEmbeddedResource = "WorkshopManager.PDF.PDF.rdlc";
                    var parts = Request.GetAllParts(request);
                    ReportViewer1.LocalReport.DataSources.Add(new
                    Microsoft.Reporting.WinForms.ReportDataSource()
                    {
                        Name = "DataSetListOfParts",
                        Value = parts
                    });                    
                    DateTime thisDay = DateTime.Today;
                    string numberPDF = thisDay.ToString("dd'/'MM'/'yyyy") + '/' + request.ID;
                    ReportParameter pdfno = new ReportParameter("pdfno", numberPDF);
                    ReportParameter owner = new ReportParameter("owner", request.Owner);                    
                    ReportParameter date = new ReportParameter("date", thisDay.ToString("d"));
                    double tempRepairCost = request.ListOfParts.Count() * 100;
                    string repairCost = Convert.ToString(tempRepairCost);
                    ReportParameter repairprize = new ReportParameter("repaircost", repairCost);
                    string partsCost = request.GetTotalPrize().ToString();
                    double tempTotalCost = Convert.ToDouble(partsCost) + Convert.ToDouble(repairCost);
                    string totalCost = Convert.ToString(tempTotalCost);
                    ReportParameter totalPrize = new ReportParameter("totalprize", totalCost);
                    ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { owner, pdfno, date, repairprize, totalPrize });
                    byte[] byteViewer = ReportViewer1.LocalReport.Render("PDF");
                    myStream.Write(byteViewer, 0, byteViewer.Length);
                    myStream.Close();
                }
            }
        }
        public void ShouldNotChangeFieldsWhenProjectedFromIRequestToIRequestWithAcces()
        {
            string model = "Fiat";
            string owner = "Andrzej Miodek";
            string mark = "126p";
            string description = "Wymiana zderzaka";
            List<Part> parts = new List<Part>()
            {
                new Part("Uszczelka", 40),
                new Part("Kierownica", 400),
                new Part("Opona", 600)
            };

            IRequest request = new Request(model, owner, mark, description, parts, true);

            IRequestWithIdAcces requestWithIdAcces = (IRequestWithIdAcces) request;

            Assert.IsTrue(request.Model == requestWithIdAcces.Model &&
                          request.Owner == requestWithIdAcces.Owner &&
                          request.Description == requestWithIdAcces.Description &&
                          request.ListOfParts.Except(requestWithIdAcces.ListOfParts).Count() == 0 &&        //Asserts, that
                          requestWithIdAcces.ListOfParts.Except(request.ListOfParts).Count() == 0);         //lists are the same.
                                                                                                            //In future change to Equals method
        }
 public static List<Part> GetAllParts(Request request)
 {
     return request.ListOfParts;
 }
 public void ShouldRetrunTrueWhenVariablesAreEquals()
 {
     string model = "Fiat";
     string owner = "Andrzej Miodek";
     string mark = "126p";
     string description = "Wymiana zderzaka";
     List<Part> parts = new List<Part>()
     {
         new Part("Uszczelka", 40),
         new Part("Kierownica", 400),
         new Part("Opona", 600)
     };
     Request a = new Request(model, owner, mark, description, parts, true);
     Request b = new Request(model, owner, mark, description, parts, true);
     Assert.IsTrue(a.Equals(b));
 }
        public void ShouldCountTotalPrize()
        {
            string model = "Fiat";
            string owner = "Andrzej Miodek";
            string mark = "126p";
            string description = "Wymiana zderzaka";
            List<Part> parts = new List<Part>()
            {
                new Part("Uszczelka", 40, 1),
                new Part("Kierownica", 400, 1),
                new Part("Opona", 600, 1)
            };

            double goodPrize = 40 + 400 + 600;
            Request testRequest = new Request(model, owner, mark, description, parts, true);

            Assert.AreEqual(goodPrize, testRequest.GetTotalPrize());
        }
        public void ShoulAddPartToRequest()
        {
            string model = "Fiat";
            string owner = "Andrzej Miodek";
            string mark = "126p";
            string description = "Wymiana zderzaka";
            List<Part> parts = new List<Part>()
            {
                new Part("Uszczelka", 40),
                new Part("Kierownica", 400),
                new Part("Opona", 600)
            };

            Part partToAdd = new Part("Migacz", 24.0);

            Request testRequest = new Request(model, owner, mark, description, parts, true);

            testRequest.AddPartToRequest(partToAdd);

            bool partsListContainsAddedPart = testRequest.ListOfParts.Contains(partToAdd);

            Assert.IsTrue(partsListContainsAddedPart);
        }
 public void ShouldReturnFalseWhenListIsNotEqual()
 {
     string model = "Fiat";
     string owner = "Andrzej Miodek";
     string mark = "126p";
     string description = "Wymiana zderzaka";
     List<Part> parts = new List<Part>()
     {
         new Part("Uszczelka", 40),
         new Part("Kierownica", 400),
         new Part("Opona", 600)
     };
     List<Part> parts2 = new List<Part>()
     {
         new Part("Uszczelka", 40),
         new Part("Lampa przednia", 270),
         new Part("Opona", 600)
     };
     Request a = new Request(model, owner, mark, description, parts, true);
     Request b = new Request(model, owner, mark, description, parts2, true);
     Assert.IsFalse(a.Equals(b));
 }