コード例 #1
0
        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 });
                    }
        }
コード例 #2
0
        public static IEnumerable <Store> GetStores()
        {
            Store store1 = new Store(CatalogGenerator.PrepareData(), InventoryGenerator.PrepareData(), HistoryGenerator.PrepareData(), .0f);

            yield return(store1);

            Store store2 = new Store(CatalogGenerator.PrepareData(), InventoryGenerator.PrepareData(), HistoryGenerator.PrepareData(), 1000f);

            yield return(store2);

            Store store3 = new Store(CatalogGenerator.PrepareData(), InventoryGenerator.PrepareData(), HistoryGenerator.PrepareData(), 1000000f);

            yield return(store3);
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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());
        }