コード例 #1
0
        public void Should_Create_NewTenantId_Whithout_Id()
        {
            var tenantId = TenantId.New();

            Assert.True(Guid.TryParse(tenantId.Value.ToString(), out var _));
            Assert.NotEqual(Guid.Empty, tenantId.Value);
        }
コード例 #2
0
        public void Should_Convert_To_Dto()
        {
            var color = Domain.Entities.Color.New("test", StatusEnum.Enable, TenantId.New());
            var dto   = ColorMapper.Map(color);

            Assert.NotNull(dto);
        }
コード例 #3
0
        public void Should_Convert_To_Dto()
        {
            var measure = Domain.Entities.Measure.New("test", StatusEnum.Enable, TenantId.New());
            var dto     = MeasureMapper.Map(measure);

            Assert.NotNull(dto);
        }
コード例 #4
0
        public ListColorQueryHandlerTest()
        {
            var repository = new Mock <IColorRepository>();

            repository.Setup(x => x.ListAsync(It.IsAny <Expression <Func <Domain.Entities.Color, bool> > >(),
                                              It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync((Expression <Func <Domain.Entities.Color, bool> > filter,
                           string orderBy, int page, int qtyPerPage) =>
            {
                var func  = filter.Compile();
                var value = func.Invoke(Domain.Entities.Color.New("test", StatusEnum.Disable, TenantId.New()));

                if (value)
                {
                    return(Pagination <Domain.Entities.Color> .Empty);
                }
                else
                {
                    return(Pagination <Domain.Entities.Color> .New(new Domain.Entities.Color[]
                    {
                        Domain.Entities.Color.New("test 1", StatusEnum.Disable, TenantId.New())
                    }, 1, 1, 1));
                }
            });

            _colorRepository = repository.Object;
        }
コード例 #5
0
        public async Task Should_Update_Color()
        {
            var color = Color.New("blue", StatusEnum.Enable, TenantId.New());

            await _colorRepository.UpdateAsync(color);

            Assert.True(_update);
        }
コード例 #6
0
        public async Task Should_Get_List_Color()
        {
            var color = Color.New("blue", StatusEnum.Enable, TenantId.New());

            var pagination = await _colorRepository.ListAsync(x => x.ColorId != ColorId.Empty);

            Assert.Single(pagination.Entities);
            Assert.True(_list);
        }
コード例 #7
0
 public MeasureTest()
 {
     _measureName  = "centimeter";
     _status       = StatusEnum.Enable;
     _tenantId     = TenantId.New();
     _measureId    = MeasureId.New();
     _creationDate = DateTime.Now;
     _updateDate   = DateTime.Now.AddHours(1);
     _measure      = Measure.New(_measureName, _status, _tenantId);
 }
コード例 #8
0
 public ColorTest()
 {
     _colorName    = "blue";
     _status       = StatusEnum.Enable;
     _tenantId     = TenantId.New();
     _colorId      = ColorId.New();
     _creationDate = DateTime.Now;
     _updateDate   = DateTime.Now.AddHours(1);
     _color        = Color.New(_colorName, _status, _tenantId);
 }
コード例 #9
0
        public void Should_Convert_To_List_Of_Dto()
        {
            var measures = new Domain.Entities.Measure[]
            {
                Domain.Entities.Measure.New("test 1", StatusEnum.Enable, TenantId.New()),
                Domain.Entities.Measure.New("test 2", StatusEnum.Enable, TenantId.New())
            };
            var dtos = MeasureMapper.Map(measures).ToList();

            Assert.NotEmpty(dtos);
            Assert.NotNull(dtos);
        }
コード例 #10
0
        public void Should_Convert_To_List_Of_Dto()
        {
            var colors = new Domain.Entities.Color[]
            {
                Domain.Entities.Color.New("test 1", StatusEnum.Enable, TenantId.New()),
                Domain.Entities.Color.New("test 2", StatusEnum.Enable, TenantId.New())
            };
            var dtos = ColorMapper.Map(colors).ToList();

            Assert.NotEmpty(dtos);
            Assert.NotNull(dtos);
        }
コード例 #11
0
        public GetColorQueryHandlerTest()
        {
            var repository = new Mock <IColorRepository>();

            repository.Setup(x => x.GetAsync(It.IsAny <ColorId>()))
            .ReturnsAsync((ColorId coloId) =>
            {
                return(Domain.Entities.Color.New("blue", StatusEnum.Enable, TenantId.New()));
            });

            _colorRepository = repository.Object;
        }
コード例 #12
0
        public GetMeasureQueryHandlerTest()
        {
            var repository = new Mock <IMeasureRepository>();

            repository.Setup(x => x.GetAsync(It.IsAny <MeasureId>()))
            .ReturnsAsync((MeasureId coloId) =>
            {
                //TODO: change to full entity
                return(Domain.Entities.Measure.New("blue", StatusEnum.Enable, TenantId.New()));
            });

            _measureRepository = repository.Object;
        }
コード例 #13
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);
 }
コード例 #14
0
 public static Measure Map(MeasureCommandDto measureInsertDto)
 {
     return(Measure.New(measureInsertDto.Name, measureInsertDto.Status, TenantId.New(measureInsertDto.TenantId)));
 }
コード例 #15
0
        private IRepository <Color> CreateRepository()
        {
            var repository = new Mock <IRepository <Color> >();

            repository.Setup(x => x.InsertAsync(It.IsAny <Color>()))
            .Callback((Color color) =>
            {
                if (color is null)
                {
                    throw new DomainException(Enumerable.Empty <DomainError>());
                }

                _insert = true;
            });

            repository.Setup(x => x.UpdateAsync(It.IsAny <Color>()))
            .Callback((Color color) =>
            {
                if (color is null)
                {
                    throw new DomainException(Enumerable.Empty <DomainError>());
                }

                _update = true;
            });

            repository.Setup(x => x.Delete(It.IsAny <Color>()))
            .Callback((Color color) =>
            {
                if (color is null)
                {
                    throw new DomainException(Enumerable.Empty <DomainError>());
                }

                _delete = true;
            });

            repository.Setup(x => x.GetAsync(It.IsAny <Expression <Func <Color, bool> > >()))
            .ReturnsAsync((Expression <Func <Color, bool> > filter) =>
            {
                if (filter is null)
                {
                    throw new DomainException(Enumerable.Empty <DomainError>());
                }

                _get = true;

                return(Color.New("Name", StatusEnum.Enable, TenantId.New()));
            });

            repository.Setup(x => x.ListAsync(It.IsAny <Expression <Func <Color, bool> > >(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns((Expression <Func <Color, bool> > filter, string orderBy, int page, int qtyPerPage) =>
            {
                if (filter is null)
                {
                    throw new DomainException(Enumerable.Empty <DomainError>());
                }

                _list = true;

                var func   = filter.Compile();
                var result = func.Invoke(_color);

                if (result)
                {
                    return(Task.FromResult(Pagination <Color> .New(new Color[] { _color }, 1, 1, 1)));
                }

                return(Task.FromResult(Pagination <Color> .Empty));
            });

            return(repository.Object);
        }
コード例 #16
0
 public static Entities.Feedstock Map(FeedstockCommandDto feedstockInsertDto)
 {
     return(Entities.Feedstock.New(feedstockInsertDto.Name, feedstockInsertDto.Status,
                                   MeasureId.New(feedstockInsertDto.MeasureId), feedstockInsertDto.Stock,
                                   ColorId.New(feedstockInsertDto.ColorId), TenantId.New(feedstockInsertDto.TenantId)));
 }
コード例 #17
0
        public void Should_Convert_To_Dto()
        {
            var feedstock = Domain.Entities.Feedstock.New("test", StatusEnum.Enable, MeasureId.New(), 2, ColorId.New(), TenantId.New());
            var dto       = FeedstockMapper.Map(feedstock);

            Assert.NotNull(dto);
        }
コード例 #18
0
        public GetFeedstockQueryHandlerTest()
        {
            var repository = new Mock <IFeedstockRepository>();

            repository.Setup(x => x.GetAsync(It.IsAny <FeedstockId>()))
            .ReturnsAsync((FeedstockId coloId) =>
            {
                //TODO: change to full entity
                return(Domain.Entities.Feedstock.New("blue", StatusEnum.Enable, MeasureId.New(), 2, ColorId.New(), TenantId.New()));
            });

            _feedstockRepository = repository.Object;
        }
コード例 #19
0
        public void Should_Convert_To_List_Of_Dto()
        {
            var feedstocks = new Domain.Entities.Feedstock[]
            {
                Domain.Entities.Feedstock.New("test 1", StatusEnum.Enable, MeasureId.New(), 2, ColorId.New(), TenantId.New()),
                Domain.Entities.Feedstock.New("test 2", StatusEnum.Enable, MeasureId.New(), 2, ColorId.New(), TenantId.New())
            };
            var dtos = FeedstockMapper.Map(feedstocks).ToList();

            Assert.NotEmpty(dtos);
            Assert.NotNull(dtos);
        }
コード例 #20
0
 public void Should_Not_Create_TenantId_When_Id_Is_Empty()
 {
     Assert.Throws <Exception>(() => TenantId.New(Guid.Empty));
 }
コード例 #21
0
 public static Color Map(ColorCommandDto colorCommandDto)
 {
     return(Color.New(colorCommandDto.Name, StatusEnum.Convert(colorCommandDto.Status), TenantId.New(colorCommandDto.ColorId)));
 }