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); }
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); }
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); }
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; }
public async Task Should_Update_Color() { var color = Color.New("blue", StatusEnum.Enable, TenantId.New()); await _colorRepository.UpdateAsync(color); Assert.True(_update); }
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); }
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); }
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); }
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); }
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); }
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; }
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; }
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); }
public static Measure Map(MeasureCommandDto measureInsertDto) { return(Measure.New(measureInsertDto.Name, measureInsertDto.Status, TenantId.New(measureInsertDto.TenantId))); }
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); }
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))); }
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); }
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; }
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); }
public void Should_Not_Create_TenantId_When_Id_Is_Empty() { Assert.Throws <Exception>(() => TenantId.New(Guid.Empty)); }
public static Color Map(ColorCommandDto colorCommandDto) { return(Color.New(colorCommandDto.Name, StatusEnum.Convert(colorCommandDto.Status), TenantId.New(colorCommandDto.ColorId))); }