public void MakePermanent_WithValidData_ShouldMakeItemPermanent()
        {
            // Arrange
            Fixture fixture = commonFixture.GetNewFixture();

            var           definition    = StoreItemDefinition.FromTemporary(true);
            IStoreItem    storeItem     = storeItemFixture.CreateValid(definition);
            PermanentItem permanentItem = fixture.Create <PermanentItem>();
            List <IStoreItemAvailability> availabilities = storeItemAvailabilityFixture.CreateManyValid().ToList();

            // Act
            storeItem.MakePermanent(permanentItem, availabilities);

            // Assert
            using (new AssertionScope())
            {
                storeItem.Name.Should().Be(permanentItem.Name);
                storeItem.Comment.Should().Be(permanentItem.Comment);
                storeItem.QuantityType.Should().Be(permanentItem.QuantityType);
                storeItem.QuantityInPacket.Should().Be(permanentItem.QuantityInPacket);
                storeItem.QuantityTypeInPacket.Should().Be(permanentItem.QuantityTypeInPacket);
                storeItem.Availabilities.Should().BeEquivalentTo(availabilities);
                storeItem.ItemCategoryId.Should().Be(permanentItem.ItemCategoryId);
                storeItem.ManufacturerId.Should().Be(permanentItem.ManufacturerId);
                storeItem.IsTemporary.Should().BeFalse();
            }
        }
        public IStore GetStore(StoreId id = null, bool?isDeleted = null)
        {
            var fixture = commonFixture.GetNewFixture();

            if (id != null)
            {
                fixture.ConstructorArgumentFor <Store, StoreId>("id", id);
            }
            if (isDeleted.HasValue)
            {
                fixture.ConstructorArgumentFor <Store, bool>("isDeleted", isDeleted.Value);
            }

            return(fixture.Create <Store>());
        }
        public async Task ConvertAsync_WithShoppingListIsNull_ShouldThrowArgumentNullException()
        {
            // Arrange
            var fixture = commonFixture.GetNewFixture();
            var service = fixture.Create <ShoppingListReadModelConversionService>();

            // Act
            Func <Task <ShoppingListReadModel> > func = async() => await service.ConvertAsync(null, default);

            // Assert
            using (new AssertionScope())
            {
                await func.Should().ThrowAsync <ArgumentNullException>();
            }
        }
        public async Task HandleAsync_WithCommandIsNull_ShouldThrowArgumentNullException()
        {
            // Arrange
            var fixture = commonFixture.GetNewFixture();
            var handler = fixture.Create <FinishShoppingListCommandHandler>();

            // Act
            Func <Task> function = async() => await handler.HandleAsync(null, default);

            // Assert
            using (new AssertionScope())
            {
                await function.Should().ThrowAsync <ArgumentNullException>();
            }
        }
Example #5
0
        public async Task HandleAsync_WithCommandIsNull_ShouldThrowArgumentNullException()
        {
            // Arrange
            var fixture = commonFixture.GetNewFixture();
            var handler = fixture.Create <DeleteItemCategoryCommandHandler>();

            // Act
            Func <Task <bool> > action = async() => await handler.HandleAsync(null, default);

            // Assert
            using (new AssertionScope())
            {
                await action.Should().ThrowAsync <ArgumentNullException>();
            }
        }
        public IShoppingListSection Create(ShoppingListSectionDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <ShoppingListSection, SectionId>("id", definition.Id);
            }
            if (definition.Name != null)
            {
                fixture.ConstructorArgumentFor <IShoppingListSection, string>("name", definition.Name);
            }
            if (definition.SortingIndex.HasValue)
            {
                fixture.ConstructorArgumentFor <ShoppingListSection, int>("sortingIndex", definition.SortingIndex.Value);
            }
            if (definition.IsDefaultSection.HasValue)
            {
                fixture.ConstructorArgumentFor <ShoppingListSection, bool>("isDefaultSection", definition.IsDefaultSection.Value);
            }
            if (definition.Items != null)
            {
                fixture.ConstructorArgumentFor <ShoppingListSection, IEnumerable <IShoppingListItem> >("shoppingListItems", definition.Items);
            }

            return(fixture.Create <ShoppingListSection>());
        }
Example #7
0
        public void AddItem_WithSectionIdIsNull_ShouldThrowArgumentNullException()
        {
            // Arrange
            var fixure       = commonFixture.GetNewFixture();
            var shoppingList = fixure.Create <DomainModels.ShoppingList>();
            var item         = shoppingListItemFixture.Create(new ItemId(commonFixture.NextInt()));

            // Act
            Action action = () => shoppingList.AddItem(item, null);

            // Assert
            using (new AssertionScope())
            {
                action.Should().Throw <ArgumentNullException>();
            }
        }
Example #8
0
        public IStoreItem Create(StoreItemDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <StoreItem, ItemId>("id", definition.Id);
            }
            if (definition.IsDeleted.HasValue)
            {
                fixture.ConstructorArgumentFor <StoreItem, bool>("isDeleted", definition.IsDeleted.Value);
            }
            if (definition.IsTemporary.HasValue)
            {
                fixture.ConstructorArgumentFor <StoreItem, bool>("isTemporary", definition.IsTemporary.Value);
            }
            if (definition.UseItemCategoryId)
            {
                fixture.ConstructorArgumentFor <StoreItem, ItemCategoryId>("itemCategoryId", definition.ItemCategoryId);
            }
            if (definition.UseManufacturerId)
            {
                fixture.ConstructorArgumentFor <StoreItem, ManufacturerId>("manufacturerId", definition.ManufacturerId);
            }
            if (definition.Availabilities != null)
            {
                fixture.ConstructorArgumentFor <StoreItem, IEnumerable <IStoreItemAvailability> >(
                    "availabilities", definition.Availabilities);
            }

            return(fixture.Create <StoreItem>());
        }
        public IShoppingListItem Create(ShoppingListItemDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <ShoppingListItem, ItemId>("id", definition.Id);
            }
            if (definition.ItemCategoryId != null)
            {
                fixture.ConstructorArgumentFor <ShoppingListItem, ItemCategoryId>("itemCategory", definition.ItemCategoryId);
            }
            if (definition.ManufacturerId != null)
            {
                fixture.ConstructorArgumentFor <ShoppingListItem, ManufacturerId>("manufacturer", definition.ManufacturerId);
            }
            if (definition.IsInBasket.HasValue)
            {
                fixture.ConstructorArgumentFor <ShoppingListItem, bool>("isInBasket", definition.IsInBasket.Value);
            }
            if (definition.Quantity.HasValue)
            {
                fixture.ConstructorArgumentFor <ShoppingListItem, float>("quantity", definition.Quantity.Value);
            }

            return(fixture.Create <ShoppingListItem>());
        }
        public IStoreSection Create(SectionId id)
        {
            var fixture = commonFixture.GetNewFixture();

            fixture.Inject(id);
            return(fixture.Create <IStoreSection>());
        }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                ManufacturerRepositoryMock = new ManufacturerRepositoryMock(Fixture);

                ManufacturerFixture = new ManufacturerFixture(CommonFixture);
            }
Example #12
0
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                ItemCategoryRepositoryMock = new ItemCategoryRepositoryMock(Fixture);

                ItemCategoryFixture = new ItemCategoryFixture(CommonFixture);
            }
            public CreateTemporaryItemCommand CreateCommand(IStoreItemAvailability availability)
            {
                var fixture = CommonFixture.GetNewFixture();

                fixture.ConstructorArgumentFor <TemporaryItemCreation, IStoreItemAvailability>("availability", availability);

                return(fixture.Create <CreateTemporaryItemCommand>());
            }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                ShoppingListMockFixture = new ShoppingListMockFixture(CommonFixture, new ShoppingListFixture(CommonFixture));

                ShoppingListRepositoryMock       = new ShoppingListRepositoryMock(Fixture);
                AddItemToShoppingListServiceMock = new AddItemToShoppingListServiceMock(Fixture);
            }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                StoreRepositoryMock = new StoreRepositoryMock(Fixture);

                StoreItemAvailabilityFixture = new StoreItemAvailabilityFixture(CommonFixture);
                StoreSectionFixture          = new StoreSectionFixture(CommonFixture);
                StoreFixture = new StoreFixture(CommonFixture);
            }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                StoreItemFixture = new StoreItemFixture(new StoreItemAvailabilityFixture(CommonFixture), CommonFixture);

                ItemRepositoryMock   = new ItemRepositoryMock(Fixture);
                StoreItemFactoryMock = new StoreItemFactoryMock(Fixture);
                AvailabilityValidationServiceMock = new AvailabilityValidationServiceMock(Fixture);
            }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                StoreItemFixture        = new StoreItemFixture(new StoreItemAvailabilityFixture(CommonFixture), CommonFixture);
                ShoppingListMockFixture = new ShoppingListMockFixture(CommonFixture, new ShoppingListFixture(CommonFixture));

                ShoppingListRepositoryMock = new ShoppingListRepositoryMock(Fixture);
                ItemRepositoryMock         = new ItemRepositoryMock(Fixture);
            }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                StoreItemFixture     = new StoreItemFixture(new StoreItemAvailabilityFixture(CommonFixture), CommonFixture);
                StoreItemMockFixture = new StoreItemMockFixture(CommonFixture, StoreItemFixture);

                ShoppingListRepositoryMock = new ShoppingListRepositoryMock(Fixture);
                ItemRepositoryMock         = new ItemRepositoryMock(Fixture);
                TransactionGeneratorMock   = new TransactionGeneratorMock(Fixture);
            }
        public IManufacturer Create(ManufacturerDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <Manufacturer, ManufacturerId>("id", definition.Id);
            }

            return(fixture.Create <Manufacturer>());
        }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                ShoppingListItemFixture      = new ShoppingListItemFixture(CommonFixture);
                ShoppingListFixture          = new ShoppingListFixture(CommonFixture);
                ShoppingListMockFixture      = new ShoppingListMockFixture(CommonFixture, ShoppingListFixture);
                StoreItemAvailabilityFixture = new StoreItemAvailabilityFixture(CommonFixture);
                StoreItemFixture             = new StoreItemFixture(StoreItemAvailabilityFixture, CommonFixture);

                ShoppingListRepositoryMock       = new ShoppingListRepositoryMock(Fixture);
                AddItemToShoppingListServiceMock = new AddItemToShoppingListServiceMock(Fixture);
            }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                StoreItemAvailabilityFixture = new StoreItemAvailabilityFixture(CommonFixture);
                StoreItemFixture             = new StoreItemFixture(StoreItemAvailabilityFixture, CommonFixture);
                StoreSectionFixture          = new StoreSectionFixture(CommonFixture);
                StoreFixture        = new StoreFixture(CommonFixture);
                ItemCategoryFixture = new ItemCategoryFixture(CommonFixture);
                ManufacturerFixture = new ManufacturerFixture(CommonFixture);

                ItemCategoryRepositoryMock = new ItemCategoryRepositoryMock(Fixture);
                ManufacturerRepositoryMock = new ManufacturerRepositoryMock(Fixture);
            }
Example #22
0
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                StoreItemFixture        = new StoreItemFixture(new StoreItemAvailabilityFixture(CommonFixture), CommonFixture);
                ShoppingListMockFixture = new ShoppingListMockFixture(CommonFixture, new ShoppingListFixture(CommonFixture));
                ItemCategoryFixture     = new ItemCategoryFixture(CommonFixture);

                ItemRepositoryMock   = new ItemRepositoryMock(Fixture);
                StoreItemFactoryMock = new StoreItemFactoryMock(Fixture);
                ItemCategoryValidationServiceMock = new ItemCategoryValidationServiceMock(Fixture);
                ManufacturerValidationServiceMock = new ManufacturerValidationServiceMock(Fixture);
                AvailabilityValidationServiceMock = new AvailabilityValidationServiceMock(Fixture);
            }
Example #23
0
        public void ChangeName_WithValidData_ShouldChangeName()
        {
            // Arrange
            string newName = commonFixture.GetNewFixture().Create <string>();
            IStore store   = storeFixture.GetStore();

            // Act
            store.ChangeName(newName);

            // Assert
            using (new AssertionScope())
            {
                store.Name.Should().Be(newName);
            }
        }
            public LocalFixture()
            {
                Fixture = CommonFixture.GetNewFixture();

                ShoppingListFixture          = new ShoppingListFixture(CommonFixture);
                ShoppingListMockFixture      = new ShoppingListMockFixture(CommonFixture, ShoppingListFixture);
                ShoppingListSectionFixture   = new ShoppingListSectionFixture(CommonFixture);
                ShoppingListItemFixture      = new ShoppingListItemFixture(CommonFixture);
                StoreItemAvailabilityFixture = new StoreItemAvailabilityFixture(CommonFixture);
                StoreItemFixture             = new StoreItemFixture(StoreItemAvailabilityFixture, CommonFixture);
                StoreSectionFixture          = new StoreSectionFixture(CommonFixture);
                StoreFixture = new StoreFixture(CommonFixture);

                ShoppingListSectionFactoryMock = new ShoppingListSectionFactoryMock(Fixture);
                StoreRepositoryMock            = new StoreRepositoryMock(Fixture);
                ItemRepositoryMock             = new ItemRepositoryMock(Fixture);
                ShoppingListItemFactoryMock    = new ShoppingListItemFactoryMock(Fixture);
            }
        public IStoreItemAvailability Create(StoreItemAvailabilityDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.StoreId != null)
            {
                fixture.ConstructorArgumentFor <StoreItemAvailability, StoreId>("storeId", definition.StoreId);
            }
            if (definition.Price.HasValue)
            {
                fixture.ConstructorArgumentFor <StoreItemAvailability, float>("price", definition.Price.Value);
            }
            if (definition.DefaultSectionId != null)
            {
                fixture.ConstructorArgumentFor <StoreItemAvailability, SectionId>("defaultSectionId", definition.DefaultSectionId);
            }

            return(fixture.Create <StoreItemAvailability>());
        }
        public IItemCategory GetItemCategory(ItemCategoryId id = null, string name = null, bool?isDeleted = null)
        {
            var fixture = commonFixture.GetNewFixture();

            if (id != null)
            {
                fixture.ConstructorArgumentFor <ItemCategory, ItemCategoryId>("id", id);
            }
            if (name != null)
            {
                fixture.ConstructorArgumentFor <ItemCategory, string>("name", name);
            }
            if (isDeleted.HasValue)
            {
                fixture.ConstructorArgumentFor <ItemCategory, bool>("isDeleted", isDeleted.Value);
            }

            return(fixture.Create <ItemCategory>());
        }
Example #27
0
        public IShoppingList Create(ShoppingListDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <ListModels.ShoppingList, ShoppingListId>("id", definition.Id);
            }
            if (definition.StoreId != null)
            {
                fixture.ConstructorArgumentFor <ListModels.ShoppingList, StoreId>("storeId", definition.StoreId);
            }
            if (definition.Sections != null)
            {
                fixture.ConstructorArgumentFor <ListModels.ShoppingList, IEnumerable <IShoppingListSection> >("sections", definition.Sections);
            }
            if (definition.UseCompletionDate)
            {
                fixture.ConstructorArgumentFor <ListModels.ShoppingList, DateTime?>("completionDate", definition.CompletionDate);
            }

            return(fixture.Create <ListModels.ShoppingList>());
        }
        public IStoreSection Create(StoreSectionDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <StoreSection, SectionId>("id", definition.Id);
            }
            if (definition.Name != null)
            {
                fixture.ConstructorArgumentFor <StoreSection, string>("name", definition.Name);
            }
            if (definition.SortingIndex != null)
            {
                fixture.ConstructorArgumentFor <StoreSection, int>("sortingIndex", definition.SortingIndex.Value);
            }
            if (definition.IsDefaultSection != null)
            {
                fixture.ConstructorArgumentFor <StoreSection, bool>("isDefaultSection", definition.IsDefaultSection.Value);
            }

            return(fixture.Create <StoreSection>());
        }