Exemplo n.º 1
0
 public static StoreObjectRect FromDto(StoreObjectRectDto dto)
 {
     return(new StoreObjectRect
     {
         X = dto.X,
         Y = dto.Y,
         Color = dto.Color,
         Height = dto.Height,
         Width = dto.Width
     });
 }
Exemplo n.º 2
0
        public static StoreObjectDto CreateShape(ShopObjectType type, int x, int y)
        {
            StoreObjectDto shape;

            switch (type)
            {
            case ShopObjectType.Rect:
                shape = new StoreObjectRectDto();
                break;

            case ShopObjectType.Circle:
                shape = new StoreObjectCircleDto();
                break;

            default:
                throw new ArgumentException("Incorrect shape type");
            }

            shape.X = x;
            shape.Y = y;

            return(shape);
        }
Exemplo n.º 3
0
        public void SaveStoreCommand_WhenNew_ShouldInsert()
        {
            var item = new StoreItemDto
            {
                Id   = Guid.NewGuid(),
                Name = "test store item",
                X    = 1,
                Y    = 2
            };
            var rect = new StoreObjectRectDto
            {
                X      = 1,
                Y      = 2,
                Color  = "test color",
                Height = 3,
                Width  = 4
            };
            var circle = new StoreObjectCircleDto
            {
                Color    = "test color 2",
                Diameter = 1,
                X        = 2,
                Y        = 3
            };
            var store = new StoreDto
            {
                Id         = Guid.NewGuid(),
                Name       = "test store",
                StoreItems = new List <StoreItemDto> {
                    item
                },
                StoreObjects = new List <StoreObjectDto> {
                    rect, circle
                }
            };

            var result = command.Execute(store).Result;

            result.Success.Should().BeTrue();
            result.Message.Should().NotBeNullOrEmpty();
            result.Data.Should().NotBeNull();
            result.Data.Id.Should().Be(store.Id);
            result.Data.Name.Should().Be(store.Name);
            result.Data.StoreItems.Should().NotBeNullOrEmpty();
            result.Data.StoreObjects.Should().NotBeNullOrEmpty();
            var resItem = result.Data.StoreItems.First();

            resItem.Id.Should().Be(item.Id);
            resItem.Name.Should().Be(item.Name);
            resItem.X.Should().Be(item.X);
            resItem.Y.Should().Be(item.Y);

            var resRect = (StoreObjectRectDto)result.Data.StoreObjects.First(x => x is StoreObjectRectDto);

            resRect.Color.Should().Be(rect.Color);
            resRect.Width.Should().Be(rect.Width);
            resRect.Height.Should().Be(rect.Height);
            resRect.X.Should().Be(rect.X);
            resRect.Y.Should().Be(rect.Y);

            var resCircle = (StoreObjectCircleDto)result.Data.StoreObjects.First(x => x is StoreObjectCircleDto);

            resCircle.Color.Should().Be(circle.Color);
            resCircle.Diameter.Should().Be(circle.Diameter);
            resCircle.X.Should().Be(circle.X);
            resCircle.Y.Should().Be(circle.Y);
        }