コード例 #1
0
        public static GameObject CreateHighway(OsmWay highwayData, OsmBounds bounds, Transform parent)
        {
            Vector3[] linePoints = new Vector3[highwayData.Nodes.Count];

            for (int i = 0; i < highwayData.Nodes.Count; i++)
            {
                linePoints[i] = OsmToUnityConverter.GetPointFromUnityPointVec3(highwayData.Nodes[i].Point, bounds);
            }

            HighwayTypeEnum type = OSMtoSharp.Enums.Helpers.EnumExtensions.
                                   GetTagKeyEnum <HighwayTypeEnum>
                                       (highwayData.Tags[TagKeyEnum.Highway]);

            float width = GetHighwayWidth(type);
            Color color = GetHighwayColor(type);

            GameObject result = LineFactory.CreateLine(linePoints, width, color, new Material(Shader.Find("Sprites/Default")));

            if (highwayData.Tags.ContainsKey(TagKeyEnum.Name))
            {
                result.name = highwayData.Tags[TagKeyEnum.Name];
                CreateRoadNameLabel(linePoints, result.name, result.transform);
            }
            else
            {
                result.name = "<highway>";
            }

            result.transform.parent = parent;

            return(result);
        }
コード例 #2
0
        public async Task Should_UpdateStockProduct_When_MerchantProductExist(string no1, string no2)
        {
            topSoldProductServiceMock.GetOrderTopSoldProducts(LineFactory.CreateLines(
                                                                  LineFactory.CreateLine(no1),
                                                                  LineFactory.CreateLine(no2)
                                                                  ));
            var handler = new UpdateStockCommandHandler(topSoldProductServiceMock.Object, dataSourceMock.Object);

            await handler.Handle(new UpdateStockCommand(no2), CancellationToken.None);
        }
コード例 #3
0
        public static List <Line> GetLinesFromString(string input)
        {
            var lastPoint = new Point(0, 0);
            var lines     = new List <Line>();

            foreach (var lineString in input.Split(','))
            {
                var newLine = LineFactory.CreateLine(lastPoint, lineString);
                lines.Add(newLine);
                lastPoint = newLine.EndPoint;
            }

            return(lines);
        }
コード例 #4
0
        public static void CreatePower(OsmNode towerData, OsmBounds bounds, Transform parent)
        {
            Vector3[] linePoints = new Vector3[2];

            linePoints[0]   = OsmToUnityConverter.GetPointFromUnityPointVec3(towerData.Point, bounds);
            linePoints[1]   = linePoints[0];
            linePoints[1].y = GetPowerTowerHeight();

            float width = GetPowerTowerWidth();
            Color color = GetPowerTowerColor();

            GameObject result = LineFactory.CreateLine(linePoints, width, color, new Material(Shader.Find("Sprites/Default")));

            result.name = "<powertower>";

            result.transform.parent = parent;
        }
コード例 #5
0
        public async Task Should_FillProductsNames(string no1, string no2, string no3, string no4, string no5, string no6)
        {
            dataSourceMock.GetProductsAsyncMock(ProductFactory.CreateProducts(no1, no2, no3, no4, no5, no6));

            topSoldProductServiceMock.GetOrderTopSoldProducts(LineFactory.CreateLines(
                                                                  LineFactory.CreateLine(no1),
                                                                  LineFactory.CreateLine(no2),
                                                                  LineFactory.CreateLine(no3),
                                                                  LineFactory.CreateLine(no4),
                                                                  LineFactory.CreateLine(no5)
                                                                  ));
            var handler = new GetTopSoldProductsQueryHandler(dataSourceMock.Object, topSoldProductServiceMock.Object);

            var products = await handler.Handle(new GetTopSoldProductsQuery(), CancellationToken.None);

            Assert.All(products, x => Assert.NotNull(x.Name));
        }
コード例 #6
0
        public static void CreateRailway(OsmWay railway, OsmBounds bounds, Transform parent)
        {
            RailwayTypeEnum type = OSMtoSharp.Enums.Helpers.EnumExtensions.
                                   GetTagKeyEnum <RailwayTypeEnum>
                                       (railway.Tags[TagKeyEnum.Railway]);

            Vector3[] linePoints = new Vector3[railway.Nodes.Count];

            for (int i = 0; i < railway.Nodes.Count; i++)
            {
                linePoints[i] = OsmToUnityConverter.GetPointFromUnityPointVec3(railway.Nodes[i].Point, bounds);
            }
            float width = GetHighwayWidth(type);
            Color color = GetHighwayColor(type);

            GameObject result = LineFactory.CreateLine(linePoints, width, color, new Material(Shader.Find("Sprites/Default")));

            result.name = "<railway>";

            result.transform.parent = parent;
        }
コード例 #7
0
        public async Task Should_ReturnTopSoldProducts(string no1, string no2, string no3, string no4, string no5, string no6)
        {
            dataSourceMock.GetInProgressOrdersAsyncMock(OrderFactory.CreateOrders(
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no1, 1)),
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no2, 3), LineFactory.CreateLine(no3, 4)),
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no4, 10)),
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no5, 5), LineFactory.CreateLine(no6, 8)))
                                                        );
            var topSoldProductService = new TopSoldProductService(dataSourceMock.Object);

            var products = await topSoldProductService.GetOrderTopSoldProducts();

            Assert.Collection(products,
                              x => Assert.Equal(no4, x.MerchantProductNo),
                              x => Assert.Equal(no6, x.MerchantProductNo),
                              x => Assert.Equal(no5, x.MerchantProductNo),
                              x => Assert.Equal(no3, x.MerchantProductNo),
                              x => Assert.Equal(no2, x.MerchantProductNo)
                              );
        }
コード例 #8
0
        public async Task Should_ReturnUniqueMerchantNumbers(string no1, string no2, string no3, string no4)
        {
            dataSourceMock.GetInProgressOrdersAsyncMock(OrderFactory.CreateOrders(
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no1, 3)),
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no2, 3), LineFactory.CreateLine(no3, 4)),
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no1, 10)),
                                                            OrderFactory.CreateOrdersWithLines(LineFactory.CreateLine(no4, 5), LineFactory.CreateLine(no3, 8)))
                                                        );
            var topSoldProductService = new TopSoldProductService(dataSourceMock.Object);

            var products = await topSoldProductService.GetOrderTopSoldProducts();

            Assert.Equal(products.Select(x => x.MerchantProductNo), products.Select(x => x.MerchantProductNo).Distinct());
        }