Esempio n. 1
0
        public PartFail Create(PartFail candidate)
        {
            if (candidate.WorksOrder != null)
            {
                var worksOrder = this.worksOrderRepository.FindById(candidate.WorksOrder.OrderNumber)
                                 ?? throw new InvalidWorksOrderException("Invalid Works Order Number supplied.");
                candidate.WorksOrder = worksOrder;
            }

            if (candidate.Part != null)
            {
                var part = this.partRepository.FindById(candidate.Part.PartNumber)
                           ?? throw new InvalidPartNumberException("Invalid Part Number Supplied");
                candidate.Part = part;
            }

            if (candidate.PurchaseOrderNumber != null)
            {
                var purchaseOrder = this.purchaseOrderRepository.FindById((int)candidate.PurchaseOrderNumber)
                                    ?? throw new InvalidPurchaseOrderException("Invalid Purchase Order Number Supplied");

                if (!purchaseOrder.ContainsPart(candidate.Part?.PartNumber))
                {
                    throw new InvalidPurchaseOrderException("Part Number supplied does not match Purchase Order");
                }
            }

            return(candidate);
        }
Esempio n. 2
0
        public void SetUp()
        {
            var a = new PartFail
            {
                Id         = 1,
                WorksOrder = new WorksOrder {
                    OrderNumber = 1, PartNumber = "A", Part = new Part {
                        Description = "desc"
                    }
                },
                EnteredBy = new Employee {
                    Id = 1, FullName = "name"
                },
                Part = new Part {
                    PartNumber = "A", Description = "B"
                },
                StorageLocation = new StorageLocation {
                    LocationId = 1, LocationCode = "LOC"
                },
                ErrorType = new PartFailErrorType {
                    ErrorType = "Error", DateInvalid = null
                },
                FaultCode = new PartFailFaultCode {
                    FaultCode = "F", Description = "Fault"
                }
            };

            this.FacadeService.GetById(1).Returns(new SuccessResult <PartFail>(a));

            this.Response = this.Browser.Get(
                "/production/quality/part-fails/1",
                with => { with.Header("Accept", "application/json"); }).Result;
        }
Esempio n. 3
0
        public void SetUp()
        {
            this.EmployeeRepository.FindById(1).Returns(new Employee {
                Id = 1, FullName = "Colin"
            });

            var partFail = new PartFail
            {
                Id   = 1,
                Part = new Part {
                    PartNumber = "PART"
                },
                Batch     = "BATCH",
                EnteredBy = new Employee {
                    Id = 1, FullName = "Colin"
                },
                DateCreated = new DateTime(),
                ErrorType   = new PartFailErrorType(),
                FaultCode   = new PartFailFaultCode()
            };

            this.resource = new PartFailResource
            {
                Id = 1324,
                WorksOrderNumber = 1,
                PartNumber       = "PART",
                Batch            = "NEW BATCH",
                EnteredBy        = 1,
                EnteredByName    = "Colin",
                DateCreated      = new DateTime().ToString("o"),
                ErrorType        = "Error",
                FaultCode        = "Fault",
                SerialNumber     = 202
            };

            this.PartFailService.Create(Arg.Any <PartFail>())
            .Returns(new PartFail
            {
                Id   = 1,
                Part = new Part {
                    PartNumber = "PART"
                },
                Batch     = "NEW BATCH",
                EnteredBy = new Employee {
                    Id = 1, FullName = "Colin"
                },
                DateCreated = new DateTime(),
                ErrorType   = new PartFailErrorType(),
                FaultCode   = new PartFailFaultCode()
            });

            this.PartFailRepository.FindById(1).Returns(partFail);

            this.result = this.Sut.Update(1, this.resource);
        }
Esempio n. 4
0
        public void SetUp()
        {
            this.requestResource = new PartFailResource
            {
                WorksOrderNumber = 99999999,
                EnteredBy        = 12345678,
                EnteredByName    = "Colin",
                PartNumber       = "PART",
                PartDescription  = "Something"
            };

            var partFail = new PartFail
            {
                Id         = 1,
                WorksOrder = new WorksOrder {
                    OrderNumber = 1, PartNumber = "A", Part = new Part {
                        Description = "desc"
                    }
                },
                EnteredBy = new Employee {
                    Id = 1, FullName = "name"
                },
                Part = new Part {
                    PartNumber = "A", Description = "B"
                },
                StorageLocation = new StorageLocation {
                    LocationId = 1, LocationCode = "LOC"
                },
                ErrorType = new PartFailErrorType {
                    ErrorType = "Error", DateInvalid = null
                },
                FaultCode = new PartFailFaultCode {
                    FaultCode = "F", Description = "Fault"
                }
            };

            this.FacadeService.Add(Arg.Any <PartFailResource>())
            .Returns(new CreatedResult <PartFail>(partFail));

            this.Response = this.Browser.Post(
                "/production/quality/part-fails",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Header("Content-Type", "application/json");
                with.JsonBody(this.requestResource);
            }).Result;
        }
Esempio n. 5
0
        public void SetUp()
        {
            this.updatedFail = new PartFail
            {
                Id   = 13434,
                Part = new Part {
                    PartNumber = "PART"
                },
                SerialNumber        = 1,
                PurchaseOrderNumber = 1,
                WorksOrder          = new WorksOrder {
                    OrderNumber = 1
                }
            };

            this.Sut.UpdateFrom(this.updatedFail);
        }
Esempio n. 6
0
        public void SetUp()
        {
            this.Candidate = new PartFail
            {
                Id   = 1,
                Part = new Part {
                    PartNumber = "PART"
                },
                PurchaseOrderNumber = 1,
                WorksOrder          = new WorksOrder {
                    OrderNumber = 1
                },
                SerialNumber = 101
            };

            this.PartRepository.FindById("PART").Returns(new Part {
                PartNumber = "PART"
            });
            this.WorksOrderRepository.FindById(1).Returns(new WorksOrder {
                OrderNumber = 1
            });
            this.PurchaseOrderRepository.FindById(1).Returns(
                new PurchaseOrder
            {
                OrderNumber = 1,
                Details     = new List <PurchaseOrderDetail>
                {
                    new PurchaseOrderDetail
                    {
                        PartNumber = "PART"
                    }
                }
            });

            this.result = this.Sut.Create(this.Candidate);
        }
Esempio n. 7
0
 public void SetUpContext()
 {
     this.Sut = new PartFail {
         Id = 246
     };
 }
Esempio n. 8
0
        public void SetUp()
        {
            var a = new PartFail
            {
                Id         = 2,
                WorksOrder = new WorksOrder {
                    OrderNumber = 1, PartNumber = "A", Part = new Part {
                        Description = "desc"
                    }
                },
                EnteredBy = new Employee {
                    Id = 1, FullName = "name"
                },
                Part = new Part {
                    PartNumber = "A", Description = "B"
                },
                StorageLocation = new StorageLocation {
                    LocationId = 1, LocationCode = "LOC-A"
                },
                ErrorType = new PartFailErrorType {
                    ErrorType = "Error A", DateInvalid = null
                },
                FaultCode = new PartFailFaultCode {
                    FaultCode = "F", Description = "Fault"
                }
            };
            var b = new PartFail
            {
                Id         = 22,
                WorksOrder = new WorksOrder {
                    OrderNumber = 1, PartNumber = "A", Part = new Part {
                        Description = "desc"
                    }
                },
                EnteredBy = new Employee {
                    Id = 1, FullName = "name"
                },
                Part = new Part {
                    PartNumber = "A", Description = "B"
                },
                StorageLocation = new StorageLocation {
                    LocationId = 1, LocationCode = "LOC-B"
                },
                ErrorType = new PartFailErrorType {
                    ErrorType = "Error B", DateInvalid = null
                },
                FaultCode = new PartFailFaultCode {
                    FaultCode = "F", Description = "Fault"
                }
            };
            var c = new PartFail
            {
                Id         = 222,
                WorksOrder = new WorksOrder {
                    OrderNumber = 1, PartNumber = "A", Part = new Part {
                        Description = "desc"
                    }
                },
                EnteredBy = new Employee {
                    Id = 1, FullName = "name"
                },
                Part = new Part {
                    PartNumber = "A", Description = "B"
                },
                StorageLocation = new StorageLocation {
                    LocationId = 1, LocationCode = "LOC-C"
                },
                ErrorType = new PartFailErrorType {
                    ErrorType = "Error C", DateInvalid = null
                },
                FaultCode = new PartFailFaultCode {
                    FaultCode = "F", Description = "Fault"
                }
            };

            var results = new List <PartFail> {
                a, b, c
            };

            this.FacadeService.Search("2").Returns(new SuccessResult <IEnumerable <PartFail> >(results));

            this.Response = this.Browser.Get(
                "/production/quality/part-fails",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Query("searchTerm", "2");
            }).Result;
        }