Exemplo n.º 1
0
        /// <summary>
        /// This constructor contains all fields of Measure <see cref="Measure"/>.
        /// </summary>
        /// <param name="id">Id of measure.</param>
        /// <param name="name">Name of measure.</param>
        /// <param name="status">Status of register.</param>
        /// <param name="creationDate">Date of create.</param>
        /// <param name="updateDate">Date of Update.</param>
        /// <param name="measureId">Measure Id.</param>
        /// <param name="stock">Quantity in stock.</param>
        /// <param name="colorId">Id of color.</param>
        /// <param name="tenantId">Cliente Id.</param>
        /// <returns>Returns new instance of Measure <see cref="Feedstock"/></returns>
        public static Feedstock New(
            FeedstockId feedstockId,
            string name,
            Status status,
            DateTime creationDate,
            DateTime?updateDate,
            MeasureId measureId,
            int stock,
            ColorId colorId,
            TenantId tenantId)
        {
            //Ensure.That(feedstockId, ResourcesReader.Field(nameof(feedstockId))).ArgumentIsNotNull();
            //Ensure.That(colorId, ResourcesReader.Field(nameof(colorId))).ArgumentIsNotNull();
            //Ensure.That(tenantId, ResourcesReader.Field(nameof(tenantId))).ArgumentIsNotNull();
            //Ensure.That(measureId, ResourcesReader.Field(nameof(measureId))).ArgumentIsNotNull();

            var feedstock = new Feedstock
            {
                FeedstockId  = feedstockId,
                Name         = name,
                Status       = status,
                CreationDate = creationDate,
                UpdateDate   = updateDate,
                MeasureId    = measureId,
                Stock        = stock,
                ColorId      = colorId,
                TenantId     = tenantId
            };

            feedstock.Isvalid();

            return(feedstock);
        }
Exemplo n.º 2
0
        public void Should_Create_FeedstockId_Whithout_Id()
        {
            var feedstockId = FeedstockId.New();

            Assert.True(Guid.TryParse(feedstockId.Value.ToString(), out var _));
            Assert.NotEqual(Guid.Empty, feedstockId.Value);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This constructor contains some fields of Measure <see cref="Feedstock"/>.
        /// </summary>
        /// <param name="name">Name of measure.</param>
        /// <param name="status">Status of register.</param>
        /// <param name="measureId">Measure Id.</param>
        /// <param name="stock">Quantity in stock.</param>
        /// <param name="colorId">Id of color.</param>
        /// <param name="tenantId">Cliente Id.</param>
        /// <returns>Returns new instance of Measure <see cref="Feedstock"/></returns>
        public static Feedstock New(
            string name,
            Status status,
            MeasureId measureId,
            int stock,
            ColorId colorId,
            TenantId tenantId)
        {
            var feedstock = new Feedstock
            {
                Name         = name,
                Status       = status,
                CreationDate = DateTime.Now,
                UpdateDate   = null,
                MeasureId    = measureId,
                Stock        = stock,
                ColorId      = colorId,
                TenantId     = tenantId,
                FeedstockId  = FeedstockId.New()
            };

            feedstock.Isvalid();

            return(feedstock);
        }
Exemplo n.º 4
0
 public static GetFeedstockQueryRequest New(FeedstockId colorId)
 {
     return(new GetFeedstockQueryRequest
     {
         FeedstockId = colorId
     });
 }
Exemplo n.º 5
0
        public async Task Should_Get_Feedstock()
        {
            var getFeedstockQueryHandler = new GetFeedstockQueryHandler(_feedstockRepository);
            var request = GetFeedstockQueryRequest.New(FeedstockId.New());

            var feedstockDto = await getFeedstockQueryHandler.Handle(request, new CancellationToken());

            Assert.NotNull(feedstockDto);
        }
Exemplo n.º 6
0
 public FeedstockTest()
 {
     _feedstockName = "leather";
     _status        = StatusEnum.Enable;
     _measureId     = MeasureId.New();
     _tenantId      = TenantId.New();
     _colorId       = ColorId.New();
     _stock         = 10;
     _feedstockId   = FeedstockId.New();
     _creationDate  = DateTime.Now;
     _updateDate    = DateTime.Now.AddHours(1);
     _feedstock     = Domain.Entities.Feedstock.New(_feedstockName, _status, _measureId, _stock, _colorId, _tenantId);
 }
Exemplo n.º 7
0
 public void Should_Not_Create_FeedstockIdd_When_Id_Is_Empty()
 {
     Assert.Throws <Exception>(() => FeedstockId.New(Guid.Empty));
 }
Exemplo n.º 8
0
        public async Task DeleteAsync(FeedstockId feedstockId)
        {
            var feedstock = await GetAsync(feedstockId);

            _repository.Delete(feedstock);
        }
Exemplo n.º 9
0
        public async Task <Domain.Entities.Feedstock> GetAsync(FeedstockId feedstockId)
        {
            Ensure.That(feedstockId, nameof(feedstockId)).ArgumentIsNotNull();

            return(await _repository.GetAsync(x => x.FeedstockId.Equals(feedstockId)));
        }