コード例 #1
0
ファイル: DataTest.cs プロジェクト: basia-224085/PT_Lab
        public void TestRandomCustomer()
        {
            RndIdCustomer customer1 = new RndIdCustomer("John", 1000);
            RndIdCustomer customer2 = new RndIdCustomer("John", 2000);
            RndIdCustomer customer3 = new RndIdCustomer("Paul", 3000);

            Assert.AreEqual(customer1.Name, "John");
            Assert.AreEqual(customer1.MoneyInCents, 1000);

            Assert.AreNotEqual(customer1, customer2);
            Assert.AreNotEqual(customer3, customer2);
            Assert.AreNotEqual(customer1, customer3);

            RndIdBook     book1    = new RndIdBook("Dune", "Frank Herbert", BType.SciFi, 25);
            RndIdCustomer customer = new RndIdCustomer("Paul", 10000);

            customer.Borrowed.Add(book1);

            Assert.AreEqual(customer.Borrowed.Count, 1);
            Assert.IsTrue(customer.Borrowed.Contains(book1));

            customer.Basket.Add(book1);

            Assert.AreEqual(customer.Basket.Count, 1);
            Assert.IsTrue(customer.Basket.Contains(book1));
        }
コード例 #2
0
ファイル: LogicTest.cs プロジェクト: basia-224085/PT_Lab
        public void RandomCustomerLogicTest()
        {
            LibraryLogic logic = new LibraryLogic(new Library());

            AbstCustomer c = new RndIdCustomer("Paul", 10000);

            logic.AddCustomer(c);

            Assert.IsTrue(logic.GetLibrary.Customers.Contains(c));
            Assert.IsTrue(logic.IsCustomer(c));

            logic.AddCustomer(c);
            Assert.AreEqual(logic.GetLibrary.Customers.Count(), 1);

            logic.AddFunds(c, 10000);
            Assert.AreEqual(logic.GetLibrary.Customers[0].MoneyInCents, 20000);

            logic.RemoveCustomer(logic.GetLibrary.Customers[0]);
            Assert.AreEqual(logic.GetLibrary.Customers.Count(), 0);
        }