public async Task ConvertAsync_WithInvalidManufacturer_ShouldConvertToReadModel() { // Arrange var local = new LocalFixture(); var service = local.CreateService(); var item = local.CreateItem(); var availability = item.Availabilities.First(); var itemCategory = local.CreateItemCategory(item.ItemCategoryId); var store = local.CreateStore(availability.StoreId, availability.DefaultSectionId); local.ItemCategoryRepositoryMock.SetupFindByAsync(item.ItemCategoryId, itemCategory); local.ManufacturerRepositoryMock.SetupFindByAsync(item.ManufacturerId, null); local.StoreRepositoryMock.SetupFindByAsync(availability.StoreId.ToMonoList(), store.ToMonoList()); // Act Func <Task <StoreItemReadModel> > function = async() => await service.ConvertAsync(item, default); // Assert using (new AssertionScope()) { (await function.Should().ThrowAsync <DomainException>()) .Where(ex => ex.Reason.ErrorCode == ErrorReasonCode.ManufacturerNotFound); } }
public async Task ConvertAsync_WithItemCategoryAndManufacturer_ShouldConvertToReadModel() { // Arrange var local = new LocalFixture(); var service = local.CreateService(); var item = local.CreateItem(); var availability = item.Availabilities.First(); var itemCategory = local.CreateItemCategory(item.ItemCategoryId); var manufacturer = local.CreateManufacturer(item.ManufacturerId); var store = local.CreateStore(availability.StoreId, availability.DefaultSectionId); local.ItemCategoryRepositoryMock.SetupFindByAsync(item.ItemCategoryId, itemCategory); local.ManufacturerRepositoryMock.SetupFindByAsync(item.ManufacturerId, manufacturer); local.StoreRepositoryMock.SetupFindByAsync(availability.StoreId.ToMonoList(), store.ToMonoList()); // Act var result = await service.ConvertAsync(item, default); // Assert var expected = local.ToSimpleReadModel(item, itemCategory, manufacturer, store); using (new AssertionScope()) { result.Should().BeEquivalentTo(expected); } }