Пример #1
0
        public async Task <StockArrival> BuildAsync()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            if (_arrival.Items == null || !_arrival.Items.Any())
            {
                throw new InvalidOperationException(nameof(_arrival.Items));
            }

            var id = await _arrivalsClient.CreateAsync(_arrival, headers);

            return(await _arrivalsClient.GetAsync(id, headers));
        }
Пример #2
0
        public async Task WhenCreate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var productStatus = await _create.ProductStatus.BuildAsync();

            var room = await _create.StockRoom
                       .BuildAsync();

            var product = await _create.Product
                          .WithStatusId(productStatus.Id)
                          .BuildAsync();

            var arrival = new StockArrival
            {
                Id        = Guid.NewGuid(),
                Type      = StockArrivalType.ArrivalFromSupplier,
                IsDeleted = true,
                Items     = new List <StockArrivalItem>
                {
                    new ()
                    {
                        RoomId    = room.Id,
                        ProductId = product.Id,
                        Count     = 1
                    }
                },
            };

            var createdArrivalId = await _stockArrivalsClient.CreateAsync(arrival, headers);

            var createdArrival = await _stockArrivalsClient.GetAsync(createdArrivalId, headers);

            Assert.NotNull(createdArrival);
            Assert.Equal(createdArrivalId, createdArrival.Id);
            Assert.Equal(arrival.Type, createdArrival.Type);
            Assert.True(!createdArrival.CreateUserId.IsEmpty());
            Assert.Equal(arrival.IsDeleted, createdArrival.IsDeleted);
            Assert.True(createdArrival.CreateDateTime.IsMoreThanMinValue());
            Assert.NotEmpty(createdArrival.Items);
        }