public static IEnumerable <object[]> GetStoresAndImpossibleSales()
        {
            using (IEnumerator <IActor> actors = ActorDataGenerator.PrepareData().GetEnumerator())
                using (IEnumerator <IBook> books = BookDataGenerator.PrepareData().GetEnumerator())
                    using (IEnumerator <IDescription> descriptions = DescriptionDataGenerator.PrepareData().GetEnumerator())
                    {
                        IActor customer = ActorDataGenerator.PrepareData().First();

                        books.MoveNext();
                        actors.MoveNext();
                        descriptions.MoveNext();

                        Store store = new Store(CatalogGenerator.PrepareData(), InventoryGenerator.PrepareData(), HistoryGenerator.PrepareData(), 1000000f);
                        store.Stock(actors.Current, 100f, 1, books.Current, descriptions.Current);
                        yield return(new object[] { store, customer, books.Current, 0 });

                        books.MoveNext();
                        actors.MoveNext();
                        descriptions.MoveNext();

                        Store store2 = new Store(CatalogGenerator.PrepareData(), InventoryGenerator.PrepareData(), HistoryGenerator.PrepareData(), 1000000f);
                        store2.Stock(actors.Current, 20f, 3, books.Current, descriptions.Current);
                        yield return(new object[] { store2, customer, books.Current, 5 });

                        IBook unavailableBook = books.Current;
                        books.MoveNext();
                        actors.MoveNext();
                        descriptions.MoveNext();

                        Store store3 = new Store(CatalogGenerator.PrepareData(), InventoryGenerator.PrepareData(), HistoryGenerator.PrepareData(), 1000000f);
                        store3.Stock(actors.Current, 4.99f, 45, books.Current, descriptions.Current);
                        yield return(new object[] { store3, customer, unavailableBook, 500 });
                    }
        }
        public static IEnumerable <object[]> GetStoresAndTooExpensiveDeliveries()
        {
            using (IEnumerator <Store> stores = GetStores().GetEnumerator())
                using (IEnumerator <IActor> actors = ActorDataGenerator.PrepareData().GetEnumerator())
                    using (IEnumerator <IBook> books = BookDataGenerator.PrepareData().GetEnumerator())
                        using (IEnumerator <IDescription> descriptions = DescriptionDataGenerator.PrepareData().GetEnumerator())
                        {
                            yield return(new object[] { advance(stores), advance(actors), .1f, 1, advance(books), advance(descriptions) });

                            yield return(new object[] { advance(stores), advance(actors), 100f, 11, advance(books), advance(descriptions) });

                            yield return(new object[] { advance(stores), advance(actors), 100000, 100, advance(books), advance(descriptions) });
                        }
        }
Ejemplo n.º 3
0
        public void GetBookListingTest()
        {
            IBook        book        = BookDataGenerator.PrepareData().First();
            IDescription description = DescriptionDataGenerator.PrepareData().First();

            ICatalog catalog = CatalogGenerator.PrepareData();

            catalog.Add(book, description);

            IInventory inventory = InventoryGenerator.PrepareData();
            IHistory   history   = HistoryGenerator.PrepareData();
            Store      store     = new Store(catalog, inventory, history, .0f);

            Assert.Equal(description, store.GetBookListing(book));
        }
Ejemplo n.º 4
0
        public void GetBookAvailabilityTest(uint number)
        {
            IBook        book        = BookDataGenerator.PrepareData().First();
            IDescription description = DescriptionDataGenerator.PrepareData().First();

            var catalog = CatalogGenerator.PrepareData();

            catalog.Add(book, description);

            var inventory = InventoryGenerator.PrepareData();

            inventory.State.Add(book, number);

            IHistory history = HistoryGenerator.PrepareData();
            Store    store   = new Store(catalog, inventory, history, .0f);

            Assert.Equal(number, store.GetBookAvailability(book));
        }
Ejemplo n.º 5
0
        public void GetBooksTest()
        {
            ICatalog catalog = CatalogGenerator.PrepareData();

            IBook        book        = BookDataGenerator.PrepareData().First();
            IDescription description = DescriptionDataGenerator.PrepareData().First();

            IBook        book2        = BookDataGenerator.PrepareData().Last();
            IDescription description2 = DescriptionDataGenerator.PrepareData().Last();

            catalog.Add(book, description);
            catalog.Add(book2, description2);

            IInventory inventory = InventoryGenerator.PrepareData();
            IHistory   history   = HistoryGenerator.PrepareData();

            Store store = new Store(catalog, inventory, history, .0f);

            Assert.Equal(catalog.Keys, store.GetBooks());
        }