public async Task <PricelistAM> CreatePricelistBlank( CatalogKind catalogKind = CatalogKind.Cargo, CatalogItemKind catalogItemKind = CatalogItemKind.Weight) { var catalogItems = await CatalogService.GetCatalogItems(catalogKind, catalogItemKind); var result = new PricelistAM(); foreach (var catalogItem in catalogItems) { var price = new PriceAM { CatalogItemId = catalogItem.Id, CommissionPercentage = Price.DefaultComissionPercentage, Name = catalogItem.Name }; result.Items.Add(price); } return(result); }
public async Task CreatePricelist() { var catalogKind = CatalogKind.Cargo; var catalogItemKind = CatalogItemKind.Weight; var catalogItems = new List <CatalogItemAM> { new CatalogItemAM { Id = 4, Name = "0.5t", Value = 500 }, new CatalogItemAM { Id = 5, Name = "1t", Value = 1000 }, new CatalogItemAM { Id = 6, Name = "1.5t", Value = 1500 } }; Suite.CatalogServiceMock .Setup(m => m.GetCatalogItems(catalogKind, catalogItemKind)) .ReturnsAsync(catalogItems); var pricelist = new PricelistAM { Items = { new PriceAM { CatalogItemId = catalogItems[0].Id }, new PriceAM { CatalogItemId = catalogItems[1].Id }, new PriceAM { CatalogItemId = catalogItems[2].Id } } }; var domainPricelist = new Pricelist { Id = 1 }; Suite.DomainPricelistServiceMock .Setup(m => m.Create()) .ReturnsAsync(domainPricelist); var result = await Suite.PricelistService.CreateDomainPricelist(); Suite.DomainPriceServiceMock .Verify( m => m.Create( domainPricelist.Id, It.IsInRange(4, 6, Range.Inclusive), It.IsAny <string>(), It.IsAny <byte>(), It.IsAny <decimal>(), It.IsAny <decimal>(), It.IsAny <decimal>(), It.IsAny <decimal>(), It.IsAny <decimal>(), It.IsAny <decimal>()), Times.Exactly(pricelist.Items.Count)); }