Пример #1
0
        //=== Manage: Order Data

        /// <summary> Get OrderData. </summary>
        /// <param name="door">Get the Door? Default false.</param>
        /// <param name="window">Get the Window? Default false.</param>
        /// <param name="frame">Get the Frame? Default false.</param>
        public OrderData GetOrderData(int id, bool door = false, bool window = false, bool frame = false)
        {
            if (id < 1)
            {
                throw new CoreException("No Id Specified!");
            }

            OrderData orderData = repository.GetEntity <OrderData>(id);

            if (orderData == null)
            {
                return(null);
            }

            if (door && orderData.IdDoor.HasValue)
            {
                orderData.Door = dMan.GetDoor(orderData.IdDoor.Value);
            }

            if (window && orderData.IdWindow.HasValue)
            {
                orderData.Window = wMan.GetWindow(orderData.IdWindow.Value);
            }

            if (frame && orderData.IdFrame.HasValue)
            {
                orderData.Frame = fMan.GetFrame(orderData.IdFrame.Value);
            }

            return(orderData);
        }
Пример #2
0
        /// <summary> Merge frame into orderdata. </summary>
        public void MergeFramesIntoOrderData(List <OrderData> orderDatas)
        {
            if (orderDatas.IsNullOrEmpty())
            {
                return;
            }

            FrameManager fMan = new FrameManager();

            foreach (OrderData data in orderDatas)
            {
                if (!data.IdFrame.HasValue || data.IdFrame.Value <= 0)
                {
                    continue;
                }

                data.Frame = fMan.GetFrame(data.IdFrame.Value, sill: true, connection: true, glass: true);
            }
        }
Пример #3
0
        public void GetFrameTest()
        {
            // multiple tests simulating different usage scenarios
            var fm = new FrameManager(5);

            for (int i = 0; i < 9; ++i)
            {
                Frame newF = new Frame {
                    frameId = i + 1, frameResource = "Placeholder Content"
                };
                fm.AddFrame(newF);

                Frame[] expect;
                Frame[] actual;
                if (i + 1 == 6)
                {
                    expect = new Frame[6] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 2, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 4, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 6, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 7)
                {
                    expect = new Frame[4] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 7, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 9)
                {
                    expect = new Frame[5] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 7, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 9, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
            }

            // another test case with different target_length
            fm = new FrameManager(3);
            for (int i = 0; i < 9; ++i)
            {
                Frame newF = new Frame {
                    frameId = i + 1, frameResource = "Placeholder Content"
                };
                fm.AddFrame(newF);

                Frame[] expect;
                Frame[] actual;
                if (i + 1 == 3)
                {
                    expect = new Frame[3] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 2, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 4)
                {
                    expect = new Frame[4] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 2, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 4, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 5)
                {
                    expect = new Frame[3] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 6)
                {
                    expect = new Frame[3] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 7)
                {
                    expect = new Frame[4] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 3, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 7, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
                else if (i + 1 == 9)
                {
                    expect = new Frame[3] {
                        new Frame {
                            frameId = 1, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 5, frameResource = "Placeholder Content"
                        },
                        new Frame {
                            frameId = 9, frameResource = "Placeholder Content"
                        }
                    };
                    actual = (Frame[])fm.GetFrame();
                    CollectionAssert.AreEqual(expect, actual);
                }
            }
        }